Пример #1
0
def getCurveArcLenDimNode( curve ):
    arcLenDimNode = connectedNodeOfType( curve, "arcLengthDimension" )
    if not arcLenDimNode:
        max = mc.getAttr( curve+".maxValue" )
        print "adding an arcLengthDimension node to curve: "+curve
        arcLenDimNode = mc.arcLengthDimension( curve+".u[%f]"%max )
    return arcLenDimNode
Пример #2
0
 def curveLenUvalue(self,obj,curve): # baseRig.util   get curveLength and uValue
     self.localLengUval = list()
     tempDCM = cmds.createNode('decomposeMatrix')
     nearestNode = cmds.createNode('nearestPointOnCurve')
     arcLengthDMS = cmds.arcLengthDimension('%s.u[0]' %curve)
     curveShape = cmds.listRelatives(curve,s=1)[0]
     cmds.connectAttr('%s.worldMatrix[0]' %obj , '%s.inputMatrix' %tempDCM)
     cmds.connectAttr('%s.worldSpace[0]' %curveShape , '%s.inputCurve' %nearestNode)
     cmds.connectAttr('%s.outputTranslate' %tempDCM , '%s.inPosition' %nearestNode)
     nearParam = cmds.getAttr('%s.parameter' %nearestNode)
     cmds.setAttr('%s.uParamValue' %arcLengthDMS , nearParam)
     getLength = nearLength = cmds.getAttr('%s.arcLength' %arcLengthDMS)
     cmds.delete(tempDCM,nearestNode,arcLengthDMS)
     # print getLength
     print 'objectPosition.param = "%s"' %nearParam
     print 'objectPosition.length = "%s"' %getLength
     self.localLengUval.append(nearParam)
     self.localLengUval.append(getLength)
Пример #3
0
    def pathCurveSet(self, plusLength):
        self.nearParam_list = list()
        self.getLength_list = list()
        self.pathCrv_attLoc_list = list()
        self.upPathLoc_list = list()

        cmds.addAttr('root_CON', ln='run', at='double', dv=0)
        cmds.setAttr('root_CON.run', e=True, k=True)
        cmds.createNode('transform', n='pathSet_GRP', p='noneTransform_GRP')
        cvStartPos = self.customBodyJointsPos[0]
        setLength = self.disDMS + plusLength
        curvePos = [0, cvStartPos[1], setLength]
        pathSet_crv = cmds.curve(p=[cvStartPos, curvePos], d=1)

        cmds.rebuildCurve(pathSet_crv, d=3, s=10)
        self.pathSet_crv = cmds.rename(pathSet_crv, 'pathSet_CRV')
        self.pathSet_crvShp = cmds.listRelatives(self.pathSet_crv, s=1)[0]
        pathSet_CIF = cmds.createNode('curveInfo', n='pathSet_CIF')

        for i in self.FKNull:
            nearDCM = cmds.createNode('decomposeMatrix')
            nearestNode = cmds.createNode('nearestPointOnCurve')
            arcLengthDMS = cmds.arcLengthDimension('%s.u[0]' %
                                                   self.pathSet_crv)
            curveShape = cmds.listRelatives(self.pathSet_crv, s=1)[0]
            cmds.connectAttr('%s.worldMatrix[0]' % i,
                             '%s.inputMatrix' % nearDCM)
            cmds.connectAttr('%s.worldSpace[0]' % curveShape,
                             '%s.inputCurve' % nearestNode)
            cmds.connectAttr('%s.outputTranslate' % nearDCM,
                             '%s.inPosition' % nearestNode)
            nearParam = cmds.getAttr('%s.parameter' % nearestNode)
            self.nearParam_list.append(nearParam)
            cmds.setAttr('%s.uParamValue' % arcLengthDMS, nearParam)
            getLength = cmds.getAttr('%s.arcLength' % arcLengthDMS)
            self.getLength_list.append(getLength)
            cmds.delete(nearDCM, nearestNode, arcLengthDMS)
            #return getLength
            print '%s.param = "%s"' % (i, nearParam)
            print '%s.length = "%s"' % (i, getLength)
            #return getLength,nearParam
            pathCrv_attLoc = cmds.spaceLocator(
                n=self.FKNull[self.FKNull.index(i)] + '_attatch_LOC')[0]
            self.pathCrv_attLoc_list.append(pathCrv_attLoc)
            cmds.setAttr('%s.template' % pathCrv_attLoc, 1)
            cmds.hide(pathCrv_attLoc)
            adl = cmds.createNode('addDoubleLinear',
                                  n=pathCrv_attLoc.replace(
                                      pathCrv_attLoc.split('_')[-1], 'ADL'))
            clp = cmds.createNode('curveLength2ParamU',
                                  n=pathCrv_attLoc.replace(
                                      pathCrv_attLoc.split('_')[-1], 'CLP'))
            poci = cmds.createNode('pointOnCurveInfo',
                                   n=pathCrv_attLoc.replace(
                                       pathCrv_attLoc.split('_')[-1], 'POCI'))
            cmds.connectAttr('root_CON.run', '%s.input2' % adl)
            cmds.setAttr('%s.input1' % adl, getLength)
            cmds.connectAttr('%s.output' % adl, '%s.inputLength' % clp)
            cmds.connectAttr('%s.worldSpace[0]' % self.pathSet_crvShp,
                             '%s.inputCurve' % clp)
            cmds.connectAttr('%s.worldSpace[0]' % self.pathSet_crvShp,
                             '%s.inputCurve' % poci)
            cmds.connectAttr('%s.outputParamU' % clp, '%s.parameter' % poci)
            cmds.connectAttr('%s.position' % poci,
                             '%s.translate' % pathCrv_attLoc)

        # reverse variable
        pathCrv_attLoc_list_rev_range = list()
        self.pathCrv_attLoc_list_rev = list(
        )  # pathCurve attatch Locator list reverse variable
        FKNull_rev_range = list()
        self.FKNull_rev = list()  # fk null reverse variable
        for j in self.pathCrv_attLoc_list:
            pathCrv_attLoc_list_rev_range.append(
                self.pathCrv_attLoc_list.index(j))
        pathCrv_attLoc_list_rev_range.reverse()
        for i in pathCrv_attLoc_list_rev_range:
            self.pathCrv_attLoc_list_rev.append(self.pathCrv_attLoc_list[i])
        for j in self.FKNull:
            FKNull_rev_range.append(self.FKNull.index(j))
        FKNull_rev_range.reverse()
        for i in FKNull_rev_range:
            self.FKNull_rev.append(self.FKNull[i])

        for k in self.pathCrv_attLoc_list_rev:  # controller upVec set and < pathCrv_attLoc connect to FKNull >
            locXform = cmds.xform(k, ws=True, q=True, t=True)
            upPathLoc = cmds.spaceLocator(
                n=k.replace(k.split('_')[-1], 'upVec_LOC'),
                p=(locXform[0], locXform[1], locXform[2]))[0]
            self.upPathLoc_list.append(upPathLoc)
            cmds.CenterPivot(upPathLoc)
            cmds.setAttr('%s.template' % upPathLoc, 1)
            cmds.setAttr('%s.ty' % upPathLoc, 20)
            temp_MMX = cmds.createNode('multMatrix',
                                       n=k.replace(k.split('_')[-1], 'MMX'))
            temp_DCM = cmds.createNode('decomposeMatrix',
                                       n=k.replace(k.split('_')[-1], 'DCM'))
            if self.pathCrv_attLoc_list_rev.index(k) is 0:
                cmds.connectAttr('%s.worldMatrix[0]' % k,
                                 '%s.matrixIn[0]' % temp_MMX)
                cmds.connectAttr('root_CON.worldInverseMatrix[0]',
                                 '%s.matrixIn[1]' % temp_MMX)
                cmds.connectAttr('%s.matrixSum' % temp_MMX,
                                 '%s.inputMatrix' % temp_DCM)
                cmds.connectAttr(
                    '%s.outputTranslate' % temp_DCM, '%s.translate' %
                    self.FKNull_rev[self.pathCrv_attLoc_list_rev.index(k)])
                cmds.connectAttr(
                    '%s.outputRotate' % temp_DCM, '%s.rotate' %
                    self.FKNull_rev[self.pathCrv_attLoc_list_rev.index(k)])
            elif self.pathCrv_attLoc_list_rev.index(k) is not 0:
                cmds.connectAttr('%s.worldMatrix[0]' % k,
                                 '%s.matrixIn[0]' % temp_MMX)
                cmds.connectAttr(
                    '%s.worldInverseMatrix[0]' % self.pathCrv_attLoc_list_rev[
                        self.pathCrv_attLoc_list_rev.index(k) - 1],
                    '%s.matrixIn[1]' % temp_MMX)
                cmds.connectAttr('%s.matrixSum' % temp_MMX,
                                 '%s.inputMatrix' % temp_DCM)
                cmds.connectAttr(
                    '%s.outputTranslate' % temp_DCM, '%s.translate' %
                    self.FKNull_rev[self.pathCrv_attLoc_list_rev.index(k)])
                cmds.connectAttr(
                    '%s.outputRotate' % temp_DCM, '%s.rotate' %
                    self.FKNull_rev[self.pathCrv_attLoc_list_rev.index(k)])
        # IKSub_loc_list , for curveVis locator
        self.IKSub_loc_list = list()
        for i in self.IKSubCon:
            IKSub_loc = cmds.spaceLocator(
                n=i.replace(i.split('_')[-1], 'LOC'))[0]
            cmds.parentConstraint(i, IKSub_loc, mo=0)
            self.IKSub_loc_list.append(IKSub_loc)
            cmds.parent(IKSub_loc, 'upVecVisCurve_GRP')
            cmds.toggle(IKSub_loc, template=True)
            cmds.hide(IKSub_loc)
        self.IKSub_loc_list.reverse()
        # set upvec con
        self.upVecPathLocControlSet()
        # tangent constraint
        for i in self.pathCrv_attLoc_list:
            cmds.tangentConstraint(
                self.pathSet_crv,
                i,
                aim=[0.0, 0.0, 1.0],
                u=[0.0, 1.0, 0.0],
                wut='object',
                wuo='%s' %
                self.upPathLoc_list[self.pathCrv_attLoc_list_rev.index(i)])
        # set root matrix
        self.addRootMatrix()
        # set node hierachy structure
        self.setNodeHierachy_second()
Пример #4
0
def arcLengthDimension(*args, **kwargs):
    res = cmds.arcLengthDimension(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Пример #5
0

# récupération des variable de la curve et des bones
NameCurve = SelectionList[0]
NameSK = SelectionList[1]

cmds.select( NameCurve )
cmds.pickWalk( direction='down' )
SelectionShape = cmds.ls( sl = True )
NomCurveShape = SelectionShape[0]

print(NameCurve)
print(NameSK)

# Création de l'arclength 
Arc = cmds.arcLengthDimension ( NomCurveShape + '.u[1]' )
print(Arc)
NomArclength = cmds.select( NomCurveShape + '->arcLengthDimension*' )
Arc = cmds.rename( NomArclength , NameCurve + '_Arc_length' )
print(Arc)

# récupération de la longuere de la chaine au repos
Longueurzero = cmds.getAttr( Arc + 'Shape.arcLength' )

print(Longueurzero)

#Création d'un node Multiply divide
MD = cmds.createNode( 'multiplyDivide' , n = NameCurve + '_MD_Arc_length' )

print(MD)