Skip to content

Instantly share code, notes, and snippets.

@Dogydogsun
Dogydogsun / assign_track_to_joint.py
Last active May 20, 2022 20:58
Script to skin all parts of the tank track to joints
sel = cmds.ls(sl=True)[0]
currentJoint = 0
joints = cmds.ls("L_chainTank_*_JNT")
currentV = 0
allSections = []
print("Script is running, please wait a minute")
for n in range(1, len(joints)+1):
@Dogydogsun
Dogydogsun / elements_to_clusters.py
Created May 18, 2022 08:15
Short Maya Python script to create clusters for all sub-elements of a geometry
import maya.cmds as cmds
for sel in cmds.ls(sl=True):
dup = cmds.duplicate(sel)
cmds.polySeparate(dup)
parts = cmds.ls(sl=True)
parentGrp = cmds.listRelatives(p = True)
for part in parts:
cmds.select(part)
@Dogydogsun
Dogydogsun / xform_to_offset_v2.py
Last active May 20, 2022 20:58
A short Maya script for transferring selected object transforms to their offset matrixes.
for sel in cmds.ls(sl=True):
getMatrix=cmds.xform(sel, query=True, matrix=True, worldSpace=True)
cmds.xform(ro=(0,0,0), t=(0,0,0), s=(1,1,1))
cmds.setAttr(sel + ".offsetParentMatrix", getMatrix, type="matrix")
@Dogydogsun
Dogydogsun / xform_to_offset.py
Last active May 2, 2022 12:54
A short Maya script for transferring selected object transforms to their offset matrixes. Deletes old transforms after finishing. Useful for creating controllers when rigging.
"""
To use, paste this code into the script window in Maya. Make sure to paste it into a Python panel.
You can then mark the entire script with ctrl+a, and middle-mouse drag it onto a shelf to create a shortcut button.
Script works with multiple selections. Simply select all the objects that you want to transfer the objects transform to their
offset matrices on, and then run the script.
@author Frederik N. S. Larsen
"""
from maya.api.OpenMaya import MEulerRotation, MMatrix