Last active
December 10, 2019 01:13
-
-
Save kohyuk91/6dfc8f7c8be9f0f733df6471b1f4c29a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| """ | |
| Usage | |
| 1. Select Camera | |
| 2. Select Object Point Group(s) | |
| 3. Run Script | |
| """ | |
| import maya.cmds as mc | |
| selCamTrans = mc.ls(selection=True, long=True)[0] | |
| selObjPGroupTransList = zip( mc.ls(selection=True)[1:], mc.ls(selection=True, long=True)[1:] ) | |
| for selObjPGroupTrans in selObjPGroupTransList: | |
| parentGrpTrans = mc.group(name=selObjPGroupTrans[0]+"_ctrl", empty=True) | |
| childGrpTrans = mc.duplicate(selObjPGroupTrans[1], name=selObjPGroupTrans[0]+"_dup")[0] | |
| mc.parent(childGrpTrans, parentGrpTrans) | |
| ### Add Constraints ### | |
| parentGrpPC = mc.parentConstraint(selCamTrans, parentGrpTrans, maintainOffset=False) | |
| childGrpPC = mc.parentConstraint(selObjPGroupTrans[1], childGrpTrans, maintainOffset=False) | |
| ### Bake ### | |
| minTime = mc.playbackOptions(q=True, minTime=True) | |
| maxTime = mc.playbackOptions(q=True, maxTime=True) | |
| mc.bakeResults(childGrpTrans, attribute=["tx","ty","tz","rx","ry","rz"], time=(minTime, maxTime)) | |
| mc.delete(childGrpPC) | |
| ### Hide Original ### | |
| mc.hide(selObjPGroupTrans[1]) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OLD