Created
September 23, 2013 09:13
-
-
Save tokejepsen/6668207 to your computer and use it in GitHub Desktop.
ghost clip animate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import maya.cmds as cmds | |
import maya.OpenMaya as om | |
import Tapp.Maya.rigging.utils as mru | |
sel=cmds.ls(selection=True) | |
if 0 >= len(sel) <= 2: | |
cmds.warning('Please select a clip or a locator and clip!') | |
else: | |
if len(sel)==1: | |
node=sel[0] | |
if cmds.nodeType(node)=='clipGhostShape': | |
loc=cmds.spaceLocator(n=node+'_loc')[0] | |
mru.Snap(loc,node) | |
grp=cmds.group(n=node+'_grp',empty=True) | |
mru.Snap(grp,node) | |
cmds.parentConstraint(loc,grp,mo=True) | |
cmds.connectAttr(grp+'.translate',node+'.translate') | |
cmds.connectAttr(grp+'.rotate',node+'.rotate') | |
cmds.select(cl=True) | |
om.MGlobal.displayInfo('Success! %s controls the clip.' % loc) | |
else: | |
cmds.warning('Please select a Ghost Clip!') | |
if len(sel)==2: | |
loc='' | |
clip='' | |
for node in sel: | |
if cmds.nodeType(node)=='transform': | |
loc=node | |
if cmds.nodeType(node)=='clipGhostShape': | |
clip=node | |
if loc and clip: | |
grp=cmds.group(n=node+'_grp',empty=True) | |
mru.Snap(grp,clip) | |
cmds.parentConstraint(loc,grp,mo=True) | |
cmds.connectAttr(grp+'.translate',clip+'.translate') | |
cmds.connectAttr(grp+'.rotate',clip+'.rotate') | |
cmds.select(cl=True) | |
om.MGlobal.displayInfo('Success! %s controls the clip.' % loc) | |
else: | |
cmds.warning('Please select a locator and a clip!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment