Skip to content

Instantly share code, notes, and snippets.

View JustinPedersen's full-sized avatar
🐑

Justin Pedersen JustinPedersen

🐑
View GitHub Profile
"""
VIS ATTR MAKER SCRIPT
# Open UI - Add this code to a button in Maya
---
import vis_attr_maker
ui = vis_attr_maker.VisSwitchMakerUI()
ui.show()
@JustinPedersen
JustinPedersen / rig_checker.py
Created May 17, 2023 07:42
Automated Rig Checks V1.0.0
"""
"""
import pymel.core as pm
from pprint import pprint
def line_list(in_list):
""" Convert a list into formatted lines for error output. """
@JustinPedersen
JustinPedersen / unfreeze_transforms.py
Created November 14, 2022 11:42
Unfreeze Transforms in on Maya objects
from maya import cmds
# Get the user selection and iterate through it
for item in cmds.ls(selection=True):
# Get the current world space location of the item. This is not the same
# as the values in the channel box, but the true world space location
world_space = cmds.xform(item, scalePivot=True, query=True, worldSpace=True)
# Move the object to the world center
cmds.move(0,0,0,item, rotatePivotRelative = True)
from maya import cmds
# Iterate through everything in the user's selection
for item in cmds.ls(selection=True):
# Store the current position
orig_pos = cmds.xform(item, query=True, worldSpace=True, translation=True)
# Move the item to the origin. This will move where ever it's current
@JustinPedersen
JustinPedersen / fbx_properties.py
Created April 6, 2022 14:19
Take the output from the cmds.FBXProperties() command and convert it into useable cmds code. This will allow you to quickly set attrs that you want in the FBX export ui and get the results back in code.
import re
fbx_properties = """
# PATH: Import|PlugInGrp|PlugInUIWidth ( TYPE: Integer ) ( VALUE: 500 ) #
# PATH: Import|PlugInGrp|PlugInUIHeight ( TYPE: Integer ) ( VALUE: 500 ) #
# PATH: Import|PlugInGrp|PlugInUIXpos ( TYPE: Integer ) ( VALUE: 100 ) #
# PATH: Import|PlugInGrp|PlugInUIYpos ( TYPE: Integer ) ( VALUE: 100 ) #
# PATH: Import|PlugInGrp|UILIndex ( TYPE: Enum ) ( VALUE: "ENU" ) (POSSIBLE VALUES: "ENU" "DEU" "FRA" "JPN" "KOR" "CHS" "PTB" ) #
# PATH: Import|IncludeGrp|MergeMode ( TYPE: Enum ) ( VALUE: "Add and update animation" ) (POSSIBLE VALUES: "Add" "Add and update animation" "Update animation" ) #
@JustinPedersen
JustinPedersen / undo_decorator.py
Created March 9, 2022 06:49
Simple undo decorator for creating an undo chunk around a function within Maya
from functools import wraps
import maya.cmds as cmds
def one_undo(func):
"""
Decorator - guarantee close chunk.
type: (function) -> function
"""
@JustinPedersen
JustinPedersen / animated_tooltips.py
Last active March 8, 2022 09:54
working implementation of gifs as tool tips for Maya
"""
Implementation of a gif as tool tip for Autodesk Maya.
Modified from: https://stackoverflow.com/questions/60521848/how-to-show-tooltip-image-when-hover-on-button-pyqt5
"""
import sys
from PySide2 import QtCore
from PySide2 import QtGui
import socket
HOST = '127.0.0.1' # the local host
PORT = 54321 # The same port as used by the server
ADDR = (HOST, PORT)
def send_command():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)
@JustinPedersen
JustinPedersen / copy_objects.py
Created June 22, 2021 08:54
Quick script to copy or instance one source object onto multiple other object's locations.
import pymel.core as pm
# Useage: Select the source object, then all of the target objects to copy to.
# Change this to True if you want to use Instances
make_instance = False
user_selection = pm.ls(selection=True)
if not len(user_selection) >= 2:
import maya.cmds as cmds
# Capture the user selection
user_selection = cmds.ls(selection=True)
# Create a duplicate of it
new_geo = cmds.duplicate(user_selection[0])
# Create a twist deformed and two bend deformers.
twist_def, twist_handle = cmds.nonLinear(new_geo[0], type='twist')