Python maya.cmds.parentConstraint() Examples
The following are 15
code examples of maya.cmds.parentConstraint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: ml_puppet.py From ml_tools with MIT License | 7 votes |
def snap(node, snapTo): #duplicate the node we want snap dup = mc.duplicate(node, parentOnly=True)[0] #unlock translates and rotates for a in ('.t','.r'): for b in 'xyz': mc.setAttr(dup+a+b, lock=False) mc.parentConstraint(snapTo, dup) for a in ('.t','.r'): for b in ('x','y','z'): try: mc.setAttr(node+a+b, mc.getAttr(dup+a+b)) except StandardError: pass mc.delete(dup)
Example #2
Source File: dpIsolate.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def dpIsolate(self, attrName, nodeList, *args): """ Function to run isolate setup. """ # get father zero out transform node zeroGrp = cmds.listRelatives(nodeList[2], allParents=True, type="transform")[0] # create parent constraint pConst = cmds.parentConstraint(nodeList[0], nodeList[1], zeroGrp, maintainOffset=True, skipTranslate=["x", "y", "z"])[0] # add isolate attribute to selected control cmds.addAttr(nodeList[2], longName=attrName, defaultValue=1.0, minValue=0, maxValue=1, keyable=True) # create reverse node reverseNode = cmds.createNode('reverse', name=nodeList[2]+"_"+attrName.capitalize()+"_Rev") # do isolate connections cmds.connectAttr(nodeList[2]+"."+attrName, pConst+"."+nodeList[0]+"W0", force=True) cmds.connectAttr(nodeList[2]+"."+attrName, reverseNode+".inputX", force=True) cmds.connectAttr(reverseNode+".outputX", pConst+"."+nodeList[1]+"W1", force=True) cmds.select(nodeList[2])
Example #3
Source File: dpEye.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def createEyelidJoints(self, side, lid, middle, cvEyelidLoc, jointLabelNumber, *args): ''' Create the eyelid joints to be used in the needed setup. Returns EyelidBaseJxt and EyelidJnt created for rotate and skinning. ''' # declating a concatenated name used for base to compose: baseName = side+self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle # creating joints: eyelidBaseZeroJxt = cmds.joint(name=baseName+"_Base_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False) eyelidBaseJxt = cmds.joint(name=baseName+"_Base_Jxt", rotationOrder="yzx", scaleCompensate=False) eyelidZeroJxt = cmds.joint(name=baseName+"_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False) eyelidJnt = cmds.joint(name=baseName+"_Jnt", rotationOrder="yzx", scaleCompensate=False) cmds.addAttr(eyelidJnt, longName='dpAR_joint', attributeType='float', keyable=False) utils.setJointLabel(eyelidJnt, jointLabelNumber, 18, self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle) cmds.select(eyelidZeroJxt) eyelidSupportJxt = cmds.joint(name=baseName+"_Jxt", rotationOrder="yzx", scaleCompensate=False) cmds.setAttr(eyelidSupportJxt+".translateX", self.ctrlRadius*0.1) # positioning and orienting correctely eyelid joints: cmds.delete(cmds.aimConstraint(cvEyelidLoc, eyelidBaseZeroJxt, aimVector=(0,0,1), worldUpType="objectrotation", worldUpObject=self.eyelidJxt)) cmds.delete(cmds.parentConstraint(cvEyelidLoc, eyelidZeroJxt, mo=False)) cmds.setAttr(eyelidZeroJxt+".rotateX", 0) cmds.setAttr(eyelidZeroJxt+".rotateY", 0) cmds.setAttr(eyelidZeroJxt+".rotateZ", 0) cmds.select(self.eyelidJxt) return eyelidBaseJxt, eyelidJnt
Example #4
Source File: dpSuspension.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.addAttr(self.moduleGrp, longName="fatherB", dataType='string') cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvALoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLocA", r=0.3, d=1, guide=True) self.connectShapeSize(shapeSizeCH) self.jAGuide = cmds.joint(name=self.guideName+"_jAGuide", radius=0.001) cmds.setAttr(self.jAGuide+".template", 1) cmds.parent(self.jAGuide, self.moduleGrp, relative=True) self.cvBLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLocB", r=0.3, d=1, guide=True) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvBLoc, self.cvALoc) cmds.setAttr(self.cvBLoc+".tz", 3) cmds.setAttr(self.cvBLoc+".rotateX", 180) self.jBGuide = cmds.joint(name=self.guideName+"_jBGuide", radius=0.001) cmds.setAttr(self.jBGuide+".template", 1) cmds.transformLimits(self.cvBLoc, tz=(0.01, 1), etz=(True, False)) self.ctrls.setLockHide([self.cvBLoc], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvALoc, self.moduleGrp) cmds.parent(self.jBGuide, self.jAGuide) cmds.parentConstraint(self.cvALoc, self.jAGuide, maintainOffset=False, name=self.jAGuide+"_ParentConstraint") cmds.parentConstraint(self.cvBLoc, self.jBGuide, maintainOffset=False, name=self.jBGuide+"_ParentConstraint") cmds.scaleConstraint(self.cvALoc, self.jAGuide, maintainOffset=False, name=self.jAGuide+"_ScaleConstraint") cmds.scaleConstraint(self.cvBLoc, self.jBGuide, maintainOffset=False, name=self.jBGuide+"_ScaleConstraint")
Example #5
Source File: dpFkLine.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long') cmds.setAttr(self.moduleGrp+".nJoints", 1) cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint")
Example #6
Source File: dpSingle.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.addAttr(self.moduleGrp, longName="indirectSkin", attributeType='bool') cmds.setAttr(self.moduleGrp+".indirectSkin", 0) cmds.addAttr(self.moduleGrp, longName='holder', attributeType='bool') cmds.setAttr(self.moduleGrp+".holder", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 1.3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint") cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint")
Example #7
Source File: dpSteering.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def createGuide(self, *args): Base.StartClass.createGuide(self) # Custom GUIDE: cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool') cmds.setAttr(self.moduleGrp+".flip", 0) cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string') self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True) self.connectShapeSize(shapeSizeCH) self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001) cmds.setAttr(self.jGuide1+".template", 1) cmds.parent(self.jGuide1, self.moduleGrp, relative=True) self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True) self.connectShapeSize(shapeSizeCH) cmds.parent(self.cvEndJoint, self.cvJointLoc) cmds.setAttr(self.cvEndJoint+".tz", 3) self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001) cmds.setAttr(self.jGuideEnd+".template", 1) cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False)) self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']) cmds.parent(self.cvJointLoc, self.moduleGrp) cmds.parent(self.jGuideEnd, self.jGuide1) cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint") cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") cmds.setAttr(self.moduleGrp+".translateY", 3) cmds.setAttr(self.moduleGrp+".rotateX", 45)
Example #8
Source File: create.py From maya-spline-ik with GNU General Public License v3.0 | 5 votes |
def __connectJoints(self): # constraint root cmds.parentConstraint(self.rootControl, self.rootJoint, mo=False) cmds.scaleConstraint(self.rootControl, self.rootJoint, mo=False) # constraint joints self.__connectTranslateJoints() self.__connectRotateJoints() return self.__scaleConstraintJoints() # ------------------------------------------------------------------------
Example #9
Source File: orientjoints.py From cmt with MIT License | 5 votes |
def template_joints(joints=None, reorient_children=True, reset_orientation=True): if joints is None: joints = cmds.ls(sl=True, type="joint") if not joints: raise RuntimeError("No joint selected to orient.") if reorient_children: children = cmds.listRelatives(fullPath=True, allDescendents=True, type="joint") joints.extend(children) red, green, blue = create_shaders() orient_group = cmds.createNode("transform", name=ORIENT_GROUP) manips = [] for joint in joints: if reset_orientation: cmds.makeIdentity(joint, apply=True) cmds.joint( joint, edit=True, orientJoint="xyz", secondaryAxisOrient="yup", children=False, zeroScaleOrient=True, ) if not cmds.listRelatives(joint, children=True): zero_orient([joint]) continue group, manip = create_orient_manipulator(joint, blue) manips.append(manip) cmds.parent(group, orient_group) cmds.parentConstraint(joint, group) cmds.setAttr(joint + ".template", 1) cmds.select(manips)
Example #10
Source File: ml_centerOfMass.py From ml_tools with MIT License | 5 votes |
def bakeCenterOfMass(*args): ''' Bake root animation to center of mass. ''' sel = mc.ls(sl=True) if not len(sel) == 1: raise RuntimeError('Please select the root control of your puppet.') root, com = getRootAndCOM(sel[0]) if not root: root = sel[0] if not com: com = createCenterOfMass() start, end = utl.frameRange() with utl.IsolateViews(): mc.bakeResults(com, time=(start,end), sampleBy=1, attribute=['tx','ty','tz'], simulation=True) rootOffset = mc.group(em=True, name='rootOffset') rootOffset = mc.parent(rootOffset, com)[0] #bake utl.matchBake(source=[root], destination=[rootOffset], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, translate=True, rotate=True) mc.cutKey(root, attribute=['tx','ty','tz','rx','ry','rz']) mc.parentConstraint(rootOffset, root) mc.select(com)
Example #11
Source File: ml_utilities.py From ml_tools with MIT License | 5 votes |
def constrain(source, destination, translate=True, rotate=True, scale=False, maintainOffset=False): ''' Constrain two objects, even if they have some locked attributes. ''' transAttr = None rotAttr = None scaleAttr = None if translate: transAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='translate*') if rotate: rotAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='rotate*') if scale: scaleAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='scale*') rotSkip = list() transSkip = list() for axis in ['x','y','z']: if transAttr and not 'translate'+axis.upper() in transAttr: transSkip.append(axis) if rotAttr and not 'rotate'+axis.upper() in rotAttr: rotSkip.append(axis) if not transSkip: transSkip = 'none' if not rotSkip: rotSkip = 'none' constraints = list() if rotAttr and transAttr and rotSkip == 'none' and transSkip == 'none': constraints.append(mc.parentConstraint(source, destination, maintainOffset=maintainOffset)) else: if transAttr: constraints.append(mc.pointConstraint(source, destination, skip=transSkip, maintainOffset=maintainOffset)) if rotAttr: constraints.append(mc.orientConstraint(source, destination, skip=rotSkip, maintainOffset=maintainOffset)) return constraints
Example #12
Source File: dpAddHandFollow.py From dpAutoRigSystem with GNU General Public License v2.0 | 4 votes |
def dpDoAddHandFollow(self, *args): """ Set attributes and call setDrivenKey method. """ sideList = [self.langDic[self.langName]['p002_left'], self.langDic[self.langName]['p003_right']] for side in sideList: armWristIkCtrl = side+"_"+self.langDic[self.langName]['c037_arm']+"_"+self.langDic[self.langName]['c004_arm_extrem']+"_Ik_Ctrl" if cmds.objExists(armWristIkCtrl): if cmds.objExists(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow']): return else: cmds.addAttr(armWristIkCtrl, ln=self.langDic[self.langName]['c032_follow'], at="enum", en=self.defaultName+":"+self.globalName+":"+self.rootName+":"+self.hipsName+":"+self.headName+":") cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], edit=True, keyable=True) parentConst = cmds.parentConstraint(self.spineChestACtrl, self.globalCtrl, self.rootCtrl, self.spineHipsBCtrl, self.headCtrl, armWristIkCtrl+"_Orient_Grp", mo=True, name=armWristIkCtrl+"_Orient_Grp_ParentConstraint") cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.headCtrl+"W4", 0) self.dpSetHandFollowSDK(armWristIkCtrl) cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 1) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineChestACtrl+"W0", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 1) self.dpSetHandFollowSDK(armWristIkCtrl) cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 2) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 1) self.dpSetHandFollowSDK(armWristIkCtrl) cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 3) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 1) self.dpSetHandFollowSDK(armWristIkCtrl) cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 4) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 0) cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.headCtrl+"W4", 1) self.dpSetHandFollowSDK(armWristIkCtrl) cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 0)
Example #13
Source File: ml_worldBake.py From ml_tools with MIT License | 4 votes |
def matchBakeLocators(parent=None, bakeOnOnes=False, constrainSource=False): #get neccesary nodes objs = mc.ls(sl=True) if not objs: OpenMaya.MGlobal.displayWarning('Select an Object') return locs = list() cutIndex = dict() noKeys = list() noKeysLoc = list() for obj in objs: name = mc.ls(obj, shortNames=True)[0] if ':' in name: name = obj.rpartition(':')[-1] locator = mc.spaceLocator(name='worldBake_'+name+'_#')[0] mc.setAttr(locator+'.rotateOrder', 3) mc.addAttr(locator, longName='ml_bakeSource', attributeType='message') mc.connectAttr('.'.join((obj,'message')), '.'.join((locator,'ml_bakeSource'))) mc.addAttr(locator, longName='ml_bakeSourceName', dataType='string') mc.setAttr('.'.join((locator,'ml_bakeSourceName')), name, type='string') if parent: locator = mc.parent(locator, parent)[0] locs.append(locator) #should look through all trans and rot if not mc.keyframe(obj, query=True, name=True): noKeys.append(obj) noKeysLoc.append(locator) utl.matchBake(objs, locs, bakeOnOnes=bakeOnOnes) if not bakeOnOnes and noKeys: utl.matchBake(noKeys, noKeysLoc, bakeOnOnes=True) if constrainSource: mc.cutKey(objs) for loc, obj in zip(locs, objs): mc.parentConstraint(loc, obj)
Example #14
Source File: ml_centerOfMass.py From ml_tools with MIT License | 4 votes |
def bakeRoot(*args): ''' Transfer previously baked animation back to the root. ''' sel = mc.ls(sl=True) if not len(sel) == 1: raise RuntimeError('Please select the root control or COM locator.') root, com = getRootAndCOM(sel[0]) if not root or not com: raise RuntimeError('Could not determine root, please ensure that a COM bake setups has been previously run.') parCon = mc.listConnections(root, source=True, destination=True, type='parentConstraint') if not parCon: raise RuntimeError('Root is not constrained, transfer anim to COM node first.') src = mc.listConnections(parCon[0]+'.target[0].targetParentMatrix', source=True, destination=False) mc.delete(parCon) utl.matchBake(source=[src[0]], destination=[root], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, translate=True, rotate=True) for kid in mc.listRelatives(com, pa=True): if kid.split('|')[-1] == 'rootOffset': mc.delete(kid) break #reconnect constraint con = mc.listRelatives(com, type='pointConstraint', pa=True) if con: mc.cutKey(com) for a in 'XYZ': mc.connectAttr(con[0]+'.constraintTranslate'+a, com+'.translate'+a)
Example #15
Source File: ml_stopwatch.py From ml_tools with MIT License | 4 votes |
def addMarksToScene(marks): ''' This is temp and will possibly be rolled into future releases. ''' start,end = utl.frameRange() camera = utl.getCurrentCamera() camShape = mc.listRelatives(camera, shapes=True)[0] aov = mc.getAttr(camShape+'.horizontalFilmAperture') name = 'ml_stopwatch_' numStopwatches = len(mc.ls(name+'*', type='locator')) top = mc.spaceLocator(name=name+'#') ename = ':'.join([str(x) for x in marks]) mc.addAttr(top, longName='keyTimes', at='enum', enumName=ename, keyable=True) markRange = float(marks[-1]-marks[0]) viewWidth = aov*2 viewHeight = -0.4*aov+(numStopwatches*aov*0.08) depth = 5 for mark in marks[1:-1]: ann = mc.annotate(top, text=str(mark)) mc.setAttr(ann+'.displayArrow', 0) #parent annT = mc.parent(mc.listRelatives(ann, parent=True, path=True), top)[0] annT = mc.rename(annT, 'mark_'+str(round(mark))) ann = mc.listRelatives(annT, shapes=True, path=True)[0] #set the position normalX = float(mark-marks[0])/markRange-0.5 mc.setAttr(annT+'.translateX', viewWidth*normalX*2) mc.setAttr(annT+'.translateY', viewHeight) mc.setAttr(annT+'.translateZ', -depth) #keyframe for color mc.setAttr(ann+'.overrideEnabled', 1) mc.setKeyframe(ann, attribute='overrideColor', value=17, time=(int(marks[0]-1),int(mark+1))) mc.setKeyframe(ann, attribute='overrideColor', value=13, time=(int(mark),)) mc.keyTangent(ann+'.overrideColor', ott='step') mc.select(clear=True) mc.parentConstraint(camera, top)