def traceFrame( self, keyTime ): if keyTime not in self._keyTimeData: return attrDataList = self._keyTimeData[ keyTime ] for attrData in attrDataList: #unpack the node data srcAttrpath, tgtAttrpath, keyItt, keyOtt, ix, iy, ox, oy = attrData #NOTE: setting itt and ott in the keyframe command doesn't work properly - if itt is spline and ott is stepped, maya sets them both to stepped... win. setKeyframe( tgtAttrpath, v=getAttr( srcAttrpath ) ) #check to see if we need to deal with weighted tangents #NOTE: we need to do this BEFORE setting any tangent data! if tgtAttrpath not in self._attrsWeightedTangentsDealtWith: self.dealWithWeightedTangents( tgtAttrpath ) #need to special case this otherwise maya will screw up the stepped tangents on the out curve... holy shit maya sucks :( if keyOtt == 'step': keyTangent( tgtAttrpath, e=True, t=(keyTime,), itt=keyItt, ott=keyOtt )#, ix=ix, iy=iy ) else: keyTangent( tgtAttrpath, e=True, t=(keyTime,), itt=keyItt, ott=keyOtt )#, ix=ix, iy=iy, ox=ox, oy=oy ) #execute any post trace command for the tgt nodes on this keyframe if self._postTraceCmd: postTraceCmdStr = resolveCmdStr( self._postTraceCmd, self._tgt, [] ) if postTraceCmdStr: maya.mel.eval( postTraceCmdStr ) #once the post trace cmd has been executed, make sure to re-key each attribute with a key on this frame for attrData in attrDataList: tgtAttrpath = attrData[1] setKeyframe( tgtAttrpath )
def preTrace(self): if self._isTransform: if self._constraint is None: self._constraint = constructDummyParentConstraint( self._src, self._tgt) #now grab any other keyable attributes keyableAttrs = listAttr( self._src, keyable=True, scalar=True, shortNames=True) or [] for attr in keyableAttrs: tgtAttrpath = '%s.%s' % (self._tgt, attr) if not objExists(tgtAttrpath): continue #check to see if we need to deal with weighted tangents srcAttrpath = '%s.%s' % (self._src, attr) if tgtAttrpath not in self._attrsWeightedTangentsDealtWith: self.dealWithWeightedTangents(tgtAttrpath) #now get the list of keys for the attribute and store that as well srcKeysTimes = keyframe(srcAttrpath, q=True) if srcKeysTimes: srcKeysInTangents = keyTangent(srcAttrpath, q=True, itt=True) srcKeysOutTangents = keyTangent(srcAttrpath, q=True, ott=True) srcKeysInX = keyTangent(srcAttrpath, q=True, ix=True) srcKeysInY = keyTangent(srcAttrpath, q=True, iy=True) srcKeysOutX = keyTangent(srcAttrpath, q=True, ox=True) srcKeysOutY = keyTangent(srcAttrpath, q=True, oy=True) #if the attr is a transform attr - set the srcAttrpath to the appropriate attribute on the constraint if attr in self.SHORT_TRANSFORM_ATTRS: srcAttrpath = '%s.c%s' % (self._constraint, attr) for keyTime, keyItt, keyOtt, ix, iy, ox, oy in zip( srcKeysTimes, srcKeysInTangents, srcKeysOutTangents, srcKeysInX, srcKeysInY, srcKeysOutX, srcKeysOutY): self._keyTimeData.setdefault(keyTime, []) self._keyTimeData[keyTime].append( (srcAttrpath, tgtAttrpath, keyItt, keyOtt, ix, iy, ox, oy)) #finally see if the node has a post trace cmd - if it does, track it postTraceCmdAttrpath = '%s.xferPostTraceCmd' % self._tgt if objExists(postTraceCmdAttrpath): cmdStr = getAttr(postTraceCmdAttrpath) self._postTraceCmd = resolveCmdStr(cmdStr, self._tgt, [])
def preTrace( self ): if self._isTransform: if self._constraint is None: self._constraint = constructDummyParentConstraint( self._src, self._tgt ) #now grab any other keyable attributes keyableAttrs = listAttr( self._src, keyable=True, scalar=True, shortNames=True ) or [] for attr in keyableAttrs: tgtAttrpath = '%s.%s' % (self._tgt, attr) if not objExists( tgtAttrpath ): continue #check to see if we need to deal with weighted tangents srcAttrpath = '%s.%s' % (self._src, attr) if tgtAttrpath not in self._attrsWeightedTangentsDealtWith: self.dealWithWeightedTangents( tgtAttrpath ) #now get the list of keys for the attribute and store that as well srcKeysTimes = keyframe( srcAttrpath, q=True ) if srcKeysTimes: srcKeysInTangents = keyTangent( srcAttrpath, q=True, itt=True ) srcKeysOutTangents = keyTangent( srcAttrpath, q=True, ott=True ) srcKeysInX = keyTangent( srcAttrpath, q=True, ix=True ) srcKeysInY = keyTangent( srcAttrpath, q=True, iy=True ) srcKeysOutX = keyTangent( srcAttrpath, q=True, ox=True ) srcKeysOutY = keyTangent( srcAttrpath, q=True, oy=True ) #if the attr is a transform attr - set the srcAttrpath to the appropriate attribute on the constraint if attr in self.SHORT_TRANSFORM_ATTRS: srcAttrpath = '%s.c%s' % (self._constraint, attr) for keyTime, keyItt, keyOtt, ix, iy, ox, oy in zip( srcKeysTimes, srcKeysInTangents, srcKeysOutTangents, srcKeysInX, srcKeysInY, srcKeysOutX, srcKeysOutY ): self._keyTimeData.setdefault( keyTime, [] ) self._keyTimeData[ keyTime ].append( (srcAttrpath, tgtAttrpath, keyItt, keyOtt, ix, iy, ox, oy) ) #finally see if the node has a post trace cmd - if it does, track it postTraceCmdAttrpath = '%s.xferPostTraceCmd' % self._tgt if objExists( postTraceCmdAttrpath ): cmdStr = getAttr( postTraceCmdAttrpath ) self._postTraceCmd = resolveCmdStr( cmdStr, self._tgt, [] )
def executePostTraceCmd( node ): cmdStr = getPostTraceCmd( node ) resolvedCmdStr = resolveCmdStr( cmdStr, node, [] ) mel.eval( resolvedCmdStr )