def moveFeetFifth(gundamIns): if (gundamIns.currentFeet == "first"): gundamIns.currentFeet = "fifth" mc.select(gundamIns.rightLeg.h_foot) print("here", gundamIns) mc.move(8, 0, 13, r=True) mc.select(gundamIns.leftLeg.h_foot) mc.move(-12, 0, 0, r=True) mc.select(gundamIns.torso.h_hips) currentY = mc.getAttr(".translateY") mc.move(0, -5.3, 0, r=True) if (gundamIns.currentFeet == "parallel"): gundamIns.currentFeet = "fifth" mc.select(gundamIns.rightLeg.h_foot) print("here", gundamIns) mc.rotate(0, -70, 0) mc.move(24.2, 0, 13, r=True) mc.select(gundamIns.leftLeg.h_foot) mc.rotate(0, 70, 0) mc.move(-24.2, 0, 0, r=True) mc.select(cl=True) mc.select(gundamIns.torso.h_hips) currentY = mc.getAttr(".translateY") mc.move(0, -5.3, 0, r=True)
def spawnMolecules(num_molecules): #----------------------Generate X-amount of molecules------------------- setUpMolecule() for i in range(0, num_molecules): #Give each a unique name curName = "molecule" curName = curName+str(i) cmds.duplicate('molecule', n=curName) #---Place in random location cmds.setAttr(curName+".translateX", random.randrange(MAX_DIST)) cmds.setAttr(curName+".translateY", random.randrange(MAX_DIST)) cmds.setAttr(curName+".translateZ", random.randrange(MAX_DIST)) #Random orientation cmds.setAttr(curName+".rotateX", random.randrange(360)) cmds.setAttr(curName+".rotateY", random.randrange(360)) cmds.setAttr(curName+".rotateZ", random.randrange(360)) #Set rotation of legs #These set numbers are arbitrary, but these locations looked good. cmds.setAttr(curName+"|realignGroup1.rotateZ", -39.4)#random.randrange(360)) cmds.setAttr(curName+"|realignGroup2.rotateZ", 217.6)#cmds.getAttr(curName+"|hydroAssembly1.rotateZ")+104) #Get number from 0 to 1. 0=symmetrical 1= asymmetrical stretchType = random.randrange(0,2) #Set up stretching anims based on our assigned type if stretchType == 0: symStretch(curName) else: asymStretch(curName) #Set up bending motion (oscillating animation) bend(curName) #Set some random movement for i in range(1, ANIM_LENGTH): #--------Assign a random animation state---------- #---Move molecule to new location every five frames if i % 5 == 0: curPosX = cmds.getAttr(curName+".translateX") curPosY = cmds.getAttr(curName+".translateY") curPosZ = cmds.getAttr(curName+".translateZ") #Move to random position and keyframe cmds.setKeyframe(curName, at="translateX", t=i, v=curPosX + random.randrange(BROWNIAN_OFFSET)) cmds.setKeyframe(curName, at="translateY", t=i, v=curPosY + random.randrange(BROWNIAN_OFFSET)) cmds.setKeyframe(curName, at="translateZ", t=i, v=curPosZ + random.randrange(BROWNIAN_OFFSET)) #Every five frames, randomly rotate if i % 5 == 0 and i != 0: #Random rotation randNum = random.randrange(3,6) animations[randNum](curName, i, random.randrange(MAX_ROT)) #--_Delete first molecule that we used to duplicate the rest cmds.delete('molecule')
def getCadenceCamLocation(self): """ Returns the current (x, z) location of the CadenceCam. This is useful for placing the camera above a given track, or for snapping a track to the current location of the camera. """ x = cmds.getAttr(self.CADENCE_CAM + '.translateX') z = cmds.getAttr(self.CADENCE_CAM + '.translateZ') return (x, z)
def bend(stringName): keyt = (0, OSC_RATE_ASSEMBLY) curRotation = cmds.getAttr(stringName+"|realignGroup1|hydroAssembly1.rotateZ") cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", t=0, v=-curRotation) cmds.setKeyframe(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", t=OSC_RATE_ASSEMBLY, v=BEND_SWING) cmds.selectKey(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ") cmds.setInfinity(stringName+"|realignGroup1|hydroAssembly1", at="rotateZ", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup1|hydroAssembly1", itt='plateau') #time=(0, OSC_RATE_ASSEMBLY)) curRotation = cmds.getAttr(stringName+"|realignGroup2|hydroAssembly2.rotateZ") cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", t=0, v=-curRotation) cmds.setKeyframe(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", t=OSC_RATE_ASSEMBLY, v=-BEND_SWING) cmds.selectKey(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ") cmds.setInfinity(stringName+"|realignGroup2|hydroAssembly2", at="rotateZ", pri='oscillate', poi='oscillate') cmds.keyTangent(stringName+"|realignGroup2|hydroAssembly2", itt='plateau') #time=(0, OSC_RATE_ASSEMBLY))
def getNextNode(cls, node): """ Returns the next track node to a given node else None. """ if not cmds.attributeQuery('next', node=node, exists=True): return None return cmds.getAttr(node + '.next')
def _handleRun(self): # This callback causes the lego man to run a short distance, along the Z axis. time = cmds.currentTime(q=1) loc = cmds.getAttr('Lego_Man.tz') cmds.setKeyframe('leg_R', v=0.0, at='rotateX') cmds.setKeyframe('leg_L', v=0.0, at='rotateX') cmds.setKeyframe('arm_R', v=0.0, at='rotateX') cmds.setKeyframe('arm_L', v=0.0, at='rotateX') cmds.setKeyframe('Lego_Man', v=loc, at='translateZ') cmds.setKeyframe('leg_R', v=-90.0, at='rotateX', t=time+20) cmds.setKeyframe('leg_L', v=90.0, at='rotateX', t=time+20) cmds.setKeyframe('arm_R', v=90.0, at='rotateX', t=time+20) cmds.setKeyframe('arm_L', v=-90.0, at='rotateX', t=time+20) cmds.setKeyframe('Lego_Man', v=loc+6.0, at='translateZ', t=time+20) cmds.setKeyframe('leg_R', v=90.0, at='rotateX', t=time+40) cmds.setKeyframe('leg_L', v=-90.0, at='rotateX', t=time+40) cmds.setKeyframe('arm_R', v=-90.0, at='rotateX', t=time+40) cmds.setKeyframe('arm_L', v=90.0, at='rotateX', t=time+40) cmds.setKeyframe('Lego_Man', v=loc+12.0, at='translateZ', t=time+40) cmds.setKeyframe('leg_R', v=-90.0, at='rotateX', t=time+60) cmds.setKeyframe('leg_L', v=90.0, at='rotateX', t=time+60) cmds.setKeyframe('arm_R', v=90.0, at='rotateX', t=time+60) cmds.setKeyframe('arm_L', v=-90.0, at='rotateX', t=time+60) cmds.setKeyframe('Lego_Man', v=loc+18.0, at='translateZ', t=time+60)
def getPrevNode(cls, node): """ Returns the previous track node to a given node else None. """ if not cmds.attributeQuery('prev', node=node, exists=True): return None return cmds.getAttr(node + '.prev')
def getNodeDatum(cls, node): """ Returns the numeric datum value, else None. """ if not cmds.attributeQuery('datum', node=node, exists=True): return None return cmds.getAttr(node + '.datum')
def vertexFaceToUVCoordinate(cls, transform, vertexIndex, faceIndex): uvIndexes = cls._getIndexesFromSelectionList( cmds.polyListComponentConversion( '%s.vtxFace[%s][%s]' % (transform, vertexIndex, faceIndex), fvf=True, tuv=True)) if not uvIndexes: return None return cmds.getAttr('%s.uv[%s]' % (transform, uvIndexes[0]))[0]
def _create(self, shapeData): point = None count = 0 while True: count += 1 if count > 10000: return False point = shapeData['box'].getRandomPointInside(padding=self._padding) if not cmds.elixirGeneral_PointInsideMesh(mesh=shapeData['name'], point=point): continue if self._padding > 0: cmds.setAttr(self._meshPointNode + '.inPosition', *point, type='double3') closestPoint = cmds.getAttr(self._meshPointNode + '.result.position')[0] dx = (closestPoint[0] - point[0]) dy = (closestPoint[1] - point[1]) dz = (closestPoint[2] - point[2]) dist = math.sqrt(dx*dx + dy*dy + dz*dz) if dist < self._padding: continue break cube = cmds.polyCube(width=self._size, height=self._size, depth=self._size) cmds.move(point[0], point[1], point[2], cube[0], absolute=True) return True
def plieHalf(self, start, end): if (self.gundamIns.currentFeet != "first"): moveFeetFirst(self.gundamIns) self.gundamIns.currentFeet = "first" mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=self.start) mc.select(self.gundamIns.torso.h_hips, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand) currentY = mc.getAttr(".translateY") print((self.start)) mc.move(0, -31, 0, r=True) mc.select(cl=True) #mc.currentTime((end-start)*2/2) mc.setKeyframe(self.gundamIns.torso.h_hips, self.gundamIns.leftLeg.h_foot, self.gundamIns.rightLeg.h_foot, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand, t=self.end) mc.select(self.gundamIns.torso.h_hips, self.gundamIns.torso.h_shoulders, self.gundamIns.rightArm.h_hand, self.gundamIns.leftArm.h_hand) mc.select(cl=True) print(self.end)
def run(self, *args, **kwargs): uid = self.fetch('uid', None) node = self.fetch('nodeName', None) props = self.fetch('props', dict()) if not uid: self.puts( success=False, error=True, message='Invalid or missing UID') return if node and TrackSceneUtils.checkNodeUidMatch(uid, node): TrackSceneUtils.setTrackProps(node, props) self.puts(success=True, nodeName=node) return trackSetNode = TrackSceneUtils.getTrackSetNode() if not trackSetNode: self.puts( success=False, error=True, message='Scene not initialized for Cadence') return for node in cmds.sets(trackSetNode, query=True): if not cmds.hasAttr(node + '.' + TrackPropEnum.UID.maya): continue if uid == cmds.getAttr(node + '.' + TrackPropEnum.UID.maya): TrackSceneUtils.setTrackProps(node, props) self.puts(success=True, nodeName=node) return self.response.puts(success=False)
def bAlter(bName, timeFrame, changeVal, chStr): mc.select(bName) startTime = mc.currentTime(query=True) endTime = startTime + timeFrame rotBy = mc.getAttr(bName+ "." + chStr) + changeVal mc.setKeyframe(attribute=chStr) mc.currentTime(endTime) mc.setKeyframe(attribute=chStr, v=rotBy)
def getTrackProps(cls, node): out = dict() for enum in Reflection.getReflectionList(TrackPropEnum): if enum.maya is None: continue out[enum.name] = cmds.getAttr(node + '.' + enum.maya) return out
def bAlter(bName, timeFrame, changeVal, chStr): mc.select(bName) startTime = mc.currentTime(query=True) endTime = startTime + timeFrame rotBy = mc.getAttr(bName+ "." + chStr) + changeVal mc.setKeyframe(attribute=chStr) mc.currentTime(endTime) mc.setKeyframe(attribute=chStr, v=rotBy) mc.currentTime(startTimeTime)
def _handleJump(self): cmds.playbackOptions(max=30, aet=30) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY') - 4), t=12) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY') - 4), t=12) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY') + 18), t=18) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY') - 4), t=24) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=30)
def _handleJump(self): cmds.playbackOptions(max=30, aet=30) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=12) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=12) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')+18), t=18) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-4), t=24) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=30)
def moveFeetFirst(gundamIns): if gundamIns.currentFeet == 'parallel': mc.select(gundamIns.rightLeg.h_foot) print("here", gundamIns) mc.rotate(0, -70, 0) mc.move(12.2, 0, 0, r=True) mc.select(gundamIns.leftLeg.h_foot) mc.rotate(0, 70, 0) mc.move(-12.2, 0, 0, r=True) mc.select(cl=True) mc.select(gundamIns.torso.h_hips, gundamIns.torso.h_shoulders, gundamIns.rightArm.h_hand, gundamIns.leftArm.h_hand) if (gundamIns.currentFeet == "second"): mc.select(gundamIns.rightLeg.h_foot) print("here", gundamIns) mc.move(19.8, 0, 0, r=True) mc.select(gundamIns.leftLeg.h_foot) mc.move(-19.8, 0, 0, r=True) mc.select(cl=True) mc.select(gundamIns.torso.h_hips, gundamIns.torso.h_shoulders, gundamIns.rightArm.h_hand, gundamIns.leftArm.h_hand) if (gundamIns.currentFeet == 'fifth'): gundamIns.currentFeet = "first" mc.select(gundamIns.rightLeg.h_foot) print("here", gundamIns) mc.move(-8, 0, -13, r=True) mc.select(gundamIns.leftLeg.h_foot) mc.move(12, 0, 0, r=True) mc.select(gundamIns.torso.h_hips) currentY = mc.getAttr(".translateY") mc.move(0, 5.3, 0, r=True) currentY = mc.getAttr(".translateY") mc.move(0, .5, 0, r=True) mc.select(cl=True)
def getUid(cls, node, trackSetNode =None): """ This returns the UID (or None if nodeName not a track nodeName). """ if not trackSetNode: trackSetNode = cls.getTrackSetNode() if not trackSetNode: return None if not cmds.sets(node, isMember=trackSetNode): return None try: return cmds.getAttr(node + '.' + TrackPropEnum.UID.maya) except Exception as err: return None
def getTrackNode(cls, uid, trackSetNode =None): trackSetNode = cls.getTrackSetNode() if not trackSetNode\ else trackSetNode if not trackSetNode: return None nodes = cmds.sets(trackSetNode, query=True) if not nodes: return None for node in nodes: if not cmds.hasAttr(node + '.' + TrackPropEnum.UID.maya): continue if uid == cmds.getAttr(node + '.' + TrackPropEnum.UID.maya): return node return None
def getTokenProps(cls, node): """ This returns the attributes uid, x, dx, y, dy. Values in Maya are in centimeters, hence the conversion to meters. """ out = dict() out['name'] = cmds.getAttr(node + '.token_name') out['uid'] = cmds.getAttr(node + '.track_uid') out['x'] = cmds.getAttr(node + '.translateZ')/100.0 out['dx'] = cmds.getAttr(node + '.dx')/100.0 out['y'] = cmds.getAttr(node + '.translateX')/100.0 out['dy'] = cmds.getAttr(node + '.dy')/100.0 return out
def getTrackNode(cls, uid): """ This returns the (string) name of the track node for a given UID, else None. """ trackSetNode = cls.getTrackSetNode() if not trackSetNode: return None nodes = cmds.sets(trackSetNode, query=True) if not nodes: return None for node in nodes: if not cmds.hasAttr(node + '.' + TrackPropEnum.UID.maya): continue if uid == cmds.getAttr(node + '.' + TrackPropEnum.UID.maya): return node return None
def getTokenNode(cls, uid, trackSetNode =None): """ This returns the name (string) of the node in the trackSet for the object with matching UID attribute. """ if not trackSetNode: trackSetNode = cls.getTrackSetNode() if not trackSetNode: return None nodes = cmds.sets(trackSetNode, query=True) if not nodes: return None for node in nodes: if not cmds.hasAttr(node + '.' + 'track_uid'): continue if uid == cmds.getAttr(node + '.' + 'track_uid'): return node return None
def on_click_object_flight(self, height=30): ball = get_ball_from_current_selection() if ball is '': return """Was unable to find a "ball" in the current selection!""" starting_ball_height = cmds.getAttr(ball + ".translateY") final_slide = height/10 ball_rotation = 360*random.randint(height/20, height/10) final_slide_time = height/10 # Set initial key frame current_time = cmds.currentTime(query=True) cmds.setKeyframe(ball, at="translateZ", t=current_time, ott="linear") cmds.setKeyframe(ball, at="translateY", t=current_time, ott="linear") cmds.setKeyframe(ball, at="rotate", t=current_time) # Set all remaining key frames programatically in the below loop bounce_height = height bounce_time = bounce_height bounce_distance = 0 while bounce_height > 1: # peak of flight current_time += bounce_time/2 cmds.setKeyframe(ball, v=bounce_height, at="translateY", t=current_time, itt="spline", ott="spline") # touch down to earth current_time += bounce_time/2 cmds.setKeyframe(ball, v=starting_ball_height, at="translateY", t=current_time, itt="linear", ott="linear") bounce_distance += bounce_height*3 bounce_time *= 0.5 bounce_height *= 0.5 # Set final key frame current_time += final_slide_time cmds.setKeyframe(ball, v=bounce_distance + final_slide, at="translateZ", t=current_time, itt="spline") cmds.setKeyframe(ball, v=ball_rotation, at="rotate", t=current_time) cmds.currentTime(current_time)
def _handleCreateH2o(self): """ """ #Sets the animation end time cmds.playbackOptions(max=240, aet=240) #this number sets the number of molecules to create molecules = 10 #Creates each atom in the h2o molecule, aligns them properly, then groups them together . cmds.polySphere(name="oxygen", r=1.2) cmds.polySphere(name="hydrogenA", r=1.06) cmds.select("hydrogenA") cmds.move(0, -1.3, 0) cmds.group('oxygen', 'hydrogenA', n='oxygenHydrogenA') cmds.select('hydrogenA') cmds.rotate(0, 0, '-52.5', p=(0, 0, 0)) cmds.polySphere(name="hydrogenB", r=1.06) cmds.select("hydrogenB") cmds.move(0, -1.3, 0) cmds.group('oxygen', 'hydrogenB', n='oxygenHydrogenB') cmds.select('hydrogenB') cmds.rotate(0, 0, '52.5', p=(0, 0, 0)) cmds.select('hydrogenA', 'hydrogenB') cmds.polyColorPerVertex(rgb=(1, 1, 1), cdo=True) cmds.select('oxygen') cmds.polyColorPerVertex(rgb=(1, 0, 0), cdo=True) cmds.group('oxygenHydrogenB', 'oxygenHydrogenA', n='h2o') #duplicates the original molecule for i in range(1, molecules): cmds.duplicate('h2o') #list of planes for movement xyz = ['X', 'Y'] #Sets movement for the original h2o molecule cmds.select("h2o") plane = random.choice(xyz) cmds.setKeyframe('h2o', at='translate' + plane, v=float(cmds.getAttr('h2o.translate' + plane)), t=1) cmds.setKeyframe('h2o', at='translate' + plane, v=5, t=240) #Iterates through each h2o group and assigns a random position and orientation for each molecule. #It also randomly choose a direction for the molecule to move in. for i in range(1, molecules): #random plane plane = random.choice(xyz) cmds.select("h2o" + str(i)) #random position cmds.move(random.randrange(-9, 9), random.randrange(-9, 9), random.randrange(-9, 9)) #random orientation cmds.rotate(random.randrange(0, 350), random.randrange(0, 350), random.randrange(0, 350)) #sets the start and end position for movement cmds.setKeyframe( 'h2o' + str(i), at='translate' + plane, v=float(cmds.getAttr('h2o' + str(i) + '.translate' + plane)), t=1) cmds.setKeyframe('h2o' + str(i), at='translate' + plane, v=5, t=240) plane = random.choice(xyz) #Selects all the h2o molecules cmds.select("h2o", add=True) for i in range(1, molecules): cmds.select("h2o" + str(i)) #Creates a new animation layer called vibrate and adds all the h2o molecules to it. cmds.animLayer('vibrate', aso=True) #Sets oscillation for original molecule cmds.setKeyframe('h2o', at='translateZ', v=float(cmds.getAttr('h2o.translateZ')), t=1) cmds.setKeyframe('h2o', at='translateZ', v=float(cmds.getAttr('h2o.translateZ')) + .2, t=2) #cmds.selectKey('h2o', t=(1,2), at="translateZ") cmds.selectKey('h2o', at='translateZ') cmds.setInfinity(pri='oscillate', poi='oscillate') #Sets oscillation for all other molecules for i in range(1, molecules): cmds.setKeyframe('h2o' + str(i), at='translateZ', v=float( cmds.getAttr('h2o' + str(i) + '.translateZ')), t=1) cmds.setKeyframe( 'h2o' + str(i), at='translateZ', v=float(cmds.getAttr('h2o' + str(i) + '.translateZ')) + .2, t=2) #cmds.selectKey('h2o'+str(i), t=(1,2), at="translateZ") cmds.selectKey('h2o' + str(i), at="translateZ") cmds.setInfinity(pri='oscillate', poi='oscillate')
def getLength(cls, node): """ Returns the length value directly from the node. """ return cmds.getAttr(node + '.length')
def getPosition(cls, node): """ Returns the pair of coordiantes for this track node directly from the node. """ return (cmds.getAttr(node + '.translateX'), cmds.getAttr(node + '.translateZ'))
def _handleMove(self): cmds.playbackOptions(max=24, aet=24) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')+2), t=6) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')-2), t=18) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')-2), t=6) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')+2), t=18) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')+2), t=6) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')-2), t=18) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')-2), t=6) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')+2), t=18) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')-2), t=6) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')+2), t=18) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')+2), t=6) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')-2), t=18) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')-2), t=6) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')+2), t=18) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')+2), t=6) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')-2), t=18) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=24)
def _handleAttack(self): cmds.playbackOptions(max=54, aet=54) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')), t=1) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=1) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=1) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=1) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=1) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=36) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ') - 3.5), t=36) cmds.setKeyframe( "CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY') + 1.5), t=36) cmds.setKeyframe( "CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY') + 1.5), t=36) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ') + 45), t=36) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ') + 45), t=36) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=48) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ') - 3.5), t=48) cmds.setKeyframe( "CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY') + 1.5), t=48) cmds.setKeyframe( "CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY') + 1.5), t=48) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ') + 45), t=48) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ') + 45), t=48) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY') - 7), t=54) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ') + 5.5), t=54) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=54) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=54) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=54) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=54)
def _handleExampleButton(self): """ This callback creates a polygonal cylinder in the Maya scene. """ random.seed(1234) #check sphereList = cmds.ls('hydrogen1', 'hydrogen2', 'oxygen', 'H2O') if len(sphereList) > 0: cmds.delete(sphereList) #create 2 hydrogen and oxygen h1 = cmds.polySphere(r=12.0, name='hydrogen1') h2 = cmds.polySphere(r=12.0, name='hydrogen2') oxygen = cmds.polySphere(r=15.0, name='oxygen') #move cmds.move(-15, 0, 0, h1) cmds.move(15, 0, 0, h2) cmds.xform(h1, piv=[0, 0, 0], ws=True) cmds.xform(h2, piv=[0, 0, 0], ws=True) cmds.rotate(0, '75', 0, h1) #group hydrogen and oxygen together H2O = cmds.group(empty=True, name='H2O#') cmds.parent('hydrogen1', 'hydrogen2', 'oxygen', 'H2O1') #add color def createMaterial(name, color, type): cmds.sets(renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG') cmds.shadingNode(type, asShader=True, name=name) cmds.setAttr(name + '.color', color[0], color[1], color[2], type='double3') cmds.connectAttr(name + '.outColor', name + 'SG.surfaceShader') def assignMaterial(name, object): cmds.sets(object, edit=True, forceElement=name + 'SG') def assignNewMaterial(name, color, type, object): createMaterial(name, color, type) assignMaterial(name, object) #H is white and O is red assignNewMaterial('Red', (1, 0, 0), 'lambert', 'oxygen') assignNewMaterial('White', (1, 1, 1), 'lambert', 'hydrogen1') assignMaterial('White', 'hydrogen2') #key frame def keyFullRotation(pObjectName, pStartTime, pEndTime, pTargetAttribute, pValueStart, pvalueEnd): keyt = (pStartTime[0], pStartTime[0]) cmds.cutKey(pObjectName, time=(keyt, keyt), attribute=pTargetAttribute) cmds.setKeyframe(pObjectName, time=pStartTime, attribute=pTargetAttribute, value=pValueStart) cmds.setKeyframe(pObjectName, time=pEndTime, attribute=pTargetAttribute, value=pvalueEnd) #cmds.selectKey( pObjectName, time=(pStartTime, [pEndTime]), attribute=pTargetAttribute, keyframe=True ) #duplicate H2O for i in range(1, 52): cmds.duplicate(H2O) #get random coord x = random.uniform(-200, 200) y = random.uniform(0, 300) z = random.uniform(-200, 200) cmds.move(x, y, z, H2O) xRot = random.uniform(0, 360) yRot = random.uniform(0, 360) zRot = random.uniform(0, 360) cmds.rotate(xRot, yRot, zRot, H2O) startTime = cmds.playbackOptions(minTime=1) endTime = cmds.playbackOptions(maxTime=30) h2o = "H2O" + str(i) for y in range(3): coordsX = cmds.getAttr(h2o + '.translateX') coordsY = cmds.getAttr(h2o + '.translateY') coordsZ = cmds.getAttr(h2o + '.translateZ') ranStartX = int(random.uniform(0, 15)) ranStartY = int(random.uniform(0, 15)) ranStartZ = int(random.uniform(0, 15)) ranEndX = int(random.uniform(15, 30)) ranEndY = int(random.uniform(15, 30)) ranEndZ = int(random.uniform(15, 30)) x = random.uniform(coordsX - 50, coordsX + 50) y = random.uniform(coordsY, coordsY + 50) z = random.uniform(coordsZ - 50, coordsZ + 50) #print x,y,z keyFullRotation(h2o, ranStartZ, 15, 'translateZ', coordsZ, z) keyFullRotation(h2o, ranStartX, 15, 'translateX', coordsX, x) keyFullRotation(h2o, ranStartY, 15, 'translateY', coordsY, y) keyFullRotation(h2o, 15, ranEndZ, 'translateZ', z, coordsZ) keyFullRotation(h2o, 15, ranEndX, 'translateX', x, coordsX) keyFullRotation(h2o, 15, ranEndY, 'translateY', y, coordsY) RcoordsX = cmds.getAttr(h2o + '.rotateX') RcoordsY = cmds.getAttr(h2o + '.rotateY') RcoordsZ = cmds.getAttr(h2o + '.rotateZ') xRot = random.uniform(0, 360) yRot = random.uniform(0, 360) zRot = random.uniform(0, 360) keyFullRotation(h2o, ranStartZ, 15, 'rotateZ', RcoordsZ, zRot) keyFullRotation(h2o, ranStartX, 15, 'rotateX', RcoordsX, xRot) keyFullRotation(h2o, ranStartY, 15, 'rotateY', RcoordsY, zRot) keyFullRotation(h2o, 15, ranEndZ, 'rotateZ', zRot, RcoordsZ) keyFullRotation(h2o, 15, ranEndX, 'rotateX', xRot, RcoordsX) keyFullRotation(h2o, 15, ranEndY, 'rotateY', zRot, RcoordsY) print 'done' cmds.delete('H2O52')
def _handleMove(self): cmds.playbackOptions(max=24, aet=24) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ') + 2), t=6) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ') - 2), t=18) cmds.setKeyframe("CTRL_L_legA", at="translateZ", v=float(cmds.getAttr('CTRL_L_legA.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ') - 2), t=6) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ') + 2), t=18) cmds.setKeyframe("CTRL_L_legB", at="translateZ", v=float(cmds.getAttr('CTRL_L_legB.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ') + 2), t=6) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ') - 2), t=18) cmds.setKeyframe("CTRL_L_legC", at="translateZ", v=float(cmds.getAttr('CTRL_L_legC.translateZ')), t=24) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=1) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ') - 2), t=6) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=12) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ') + 2), t=18) cmds.setKeyframe("CTRL_L_legD", at="translateZ", v=float(cmds.getAttr('CTRL_L_legD.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ') - 2), t=6) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ') + 2), t=18) cmds.setKeyframe("CTRL_R_legA", at="translateZ", v=float(cmds.getAttr('CTRL_R_legA.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ') + 2), t=6) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ') - 2), t=18) cmds.setKeyframe("CTRL_R_legB", at="translateZ", v=float(cmds.getAttr('CTRL_R_legB.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ') - 2), t=6) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ') + 2), t=18) cmds.setKeyframe("CTRL_R_legC", at="translateZ", v=float(cmds.getAttr('CTRL_R_legC.translateZ')), t=24) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=1) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ') + 2), t=6) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=12) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ') - 2), t=18) cmds.setKeyframe("CTRL_R_legD", at="translateZ", v=float(cmds.getAttr('CTRL_R_legD.translateZ')), t=24)
def getWidth(cls, node): """ Returns the width value directly from the node. """ return cmds.getAttr(node + '.width')
# test_echoCommunication.py # (C)2012 t # Scott Ernst import nimble from nimble import cmds result = cmds.polyCube(height=10, depth=25) print 'polyCube result:',result cmds.select(result[0]) cmds.move(10, 10, 5, result[0]) conn = nimble.getConnection() print conn.ping().echo(True, True) print 'X:',conn.maya('getAttr', result[0] + '.translateX') print 'Y:',conn.maya('getAttr', result[0] + '.translateY') print 'Z:',conn.maya('getAttr', result[0] + '.translateZ') print 'Translate:', cmds.getAttr(result[0] + '.translate')[0] print 'Test Complete.'
def _handleExampleButton(self): """ This callback creates a polygonal cylinder in the Maya scene. """ random.seed(1234) #check sphereList = cmds.ls('hydrogen1','hydrogen2', 'oxygen','H2O') if len(sphereList)>0: cmds.delete(sphereList) #create 2 hydrogen and oxygen h1 = cmds.polySphere(r=12.0, name='hydrogen1') h2 = cmds.polySphere(r=12.0, name='hydrogen2') oxygen = cmds.polySphere(r=15.0, name='oxygen') #move cmds.move(-15,0,0,h1) cmds.move(15,0,0,h2) cmds.xform(h1, piv=[0,0,0],ws=True) cmds.xform(h2, piv=[0,0,0],ws=True) cmds.rotate(0,'75',0,h1) #group hydrogen and oxygen together H2O = cmds.group(empty=True, name='H2O#') cmds.parent('hydrogen1','hydrogen2','oxygen','H2O1') #add color def createMaterial( name, color, type ): cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG' ) cmds.shadingNode( type, asShader=True, name=name ) cmds.setAttr( name+'.color', color[0], color[1], color[2], type='double3') cmds.connectAttr(name+'.outColor', name+'SG.surfaceShader') def assignMaterial (name, object): cmds.sets(object, edit=True, forceElement=name+'SG') def assignNewMaterial( name, color, type, object): createMaterial (name, color, type) assignMaterial (name, object) #H is white and O is red assignNewMaterial('Red', (1,0,0), 'lambert', 'oxygen'); assignNewMaterial('White',(1,1,1),'lambert', 'hydrogen1'); assignMaterial('White', 'hydrogen2'); #key frame def keyFullRotation( pObjectName, pStartTime, pEndTime, pTargetAttribute,pValueStart, pvalueEnd ): keyt = (pStartTime[0], pStartTime[0]) cmds.cutKey( pObjectName, time=(keyt, keyt), attribute=pTargetAttribute ) cmds.setKeyframe( pObjectName, time=pStartTime, attribute=pTargetAttribute, value=pValueStart ) cmds.setKeyframe( pObjectName, time=pEndTime, attribute=pTargetAttribute, value=pvalueEnd ) #cmds.selectKey( pObjectName, time=(pStartTime, [pEndTime]), attribute=pTargetAttribute, keyframe=True ) #duplicate H2O for i in range(1,52): cmds.duplicate(H2O) #get random coord x = random.uniform(-200,200) y = random.uniform(0,300) z = random.uniform(-200,200) cmds.move(x,y,z, H2O) xRot = random.uniform(0,360) yRot = random.uniform(0,360) zRot = random.uniform(0,360) cmds.rotate(xRot,yRot,zRot,H2O) startTime = cmds.playbackOptions(minTime=1 ) endTime = cmds.playbackOptions( maxTime=30 ) h2o = "H2O"+str(i) for y in range(3): coordsX = cmds.getAttr( h2o+'.translateX' ) coordsY = cmds.getAttr( h2o+'.translateY' ) coordsZ = cmds.getAttr( h2o+'.translateZ' ) ranStartX = int(random.uniform(0,15)) ranStartY = int(random.uniform(0,15)) ranStartZ = int(random.uniform(0,15)) ranEndX = int(random.uniform(15,30)) ranEndY = int(random.uniform(15,30)) ranEndZ = int(random.uniform(15,30)) x = random.uniform(coordsX-50,coordsX+50) y = random.uniform(coordsY,coordsY+50) z = random.uniform(coordsZ-50,coordsZ+50) #print x,y,z keyFullRotation( h2o, ranStartZ, 15, 'translateZ',coordsZ,z) keyFullRotation( h2o, ranStartX, 15, 'translateX', coordsX,x) keyFullRotation( h2o, ranStartY, 15, 'translateY', coordsY,y) keyFullRotation( h2o, 15, ranEndZ, 'translateZ',z,coordsZ) keyFullRotation( h2o, 15, ranEndX, 'translateX', x,coordsX) keyFullRotation( h2o, 15, ranEndY, 'translateY', y,coordsY) RcoordsX = cmds.getAttr( h2o+'.rotateX' ) RcoordsY = cmds.getAttr( h2o+'.rotateY' ) RcoordsZ = cmds.getAttr( h2o+'.rotateZ' ) xRot = random.uniform(0,360) yRot = random.uniform(0,360) zRot = random.uniform(0,360) keyFullRotation( h2o, ranStartZ, 15, 'rotateZ',RcoordsZ,zRot) keyFullRotation( h2o, ranStartX, 15, 'rotateX', RcoordsX,xRot) keyFullRotation( h2o, ranStartY, 15, 'rotateY', RcoordsY,zRot) keyFullRotation( h2o, 15, ranEndZ, 'rotateZ',zRot,RcoordsZ) keyFullRotation( h2o, 15, ranEndX, 'rotateX', xRot,RcoordsX) keyFullRotation( h2o, 15, ranEndY, 'rotateY', zRot,RcoordsY) print 'done' cmds.delete('H2O52')
def _handleAttack(self): cmds.playbackOptions(max=54, aet=54) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=1) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')), t=1) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=1) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=1) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=1) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=1) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=36) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')-3.5), t=36) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')+1.5), t=36) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')+1.5), t=36) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')+45), t=36) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')+45), t=36) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')), t=48) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')-3.5), t=48) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')+1.5), t=48) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')+1.5), t=48) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')+45), t=48) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')+45), t=48) cmds.setKeyframe("MoveAll", at="translateY", v=float(cmds.getAttr('MoveAll.translateY')-7), t=54) cmds.setKeyframe("MoveAll", at="translateZ", v=float(cmds.getAttr('MoveAll.translateZ')+5.5), t=54) cmds.setKeyframe("CTRL_innerFangL", at="translateY", v=float(cmds.getAttr('CTRL_innerFangL.translateY')), t=54) cmds.setKeyframe("CTRL_innerFangR", at="translateY", v=float(cmds.getAttr('CTRL_innerFangR.translateY')), t=54) cmds.setKeyframe("L_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('L_outerFang_JA.rotateZ')), t=54) cmds.setKeyframe("R_outerFang_JA", at="rotateZ", v=float(cmds.getAttr('R_outerFang_JA.rotateZ')), t=54)
def getWidthUncertainty(cls, node): """ Returns the width uncertainty value directly from the node. """ return cmds.getAttr(node + '.widthUncertainty')
def getRotation(cls, node): """ Returns the rotationvalue directly from the node. """ return cmds.getAttr(node + '.rotateY')
def rotZ(stringName, timeEnd, valEnd): curRotation = cmds.getAttr(stringName+"|realignGroup1|hydroAssembly1.rotateZ") #cmds.setKeyframe(stringName, at="rotateZ", t=timeStart, v=curRotation) cmds.setKeyframe(stringName, at="rotateZ", t=timeEnd, v=valEnd)
def getRotationUncertainty(cls, node): """ Returns the rotation uncertainty value directly from the node. """ return cmds.getAttr(node + '.rotationUncertainty')
# test_echoCommunication.py # (C)2012 t # Scott Ernst from __future__ import print_function, absolute_import, unicode_literals, division import nimble from nimble import cmds result = cmds.polyCube(height=10, depth=25) print('polyCube result:', result) cmds.select(result[0]) cmds.move(10, 10, 5, result[0]) conn = nimble.getConnection() print(conn.ping().echo(True, True)) print('X:', conn.maya('getAttr', result[0] + '.translateX')) print('Y:', conn.maya('getAttr', result[0] + '.translateY')) print('Z:', conn.maya('getAttr', result[0] + '.translateZ')) print('Translate:', cmds.getAttr(result[0] + '.translate')[0]) print('Test Complete.')