예제 #1
0
def makeFlake(branches,radius):
    '''
    Creates a single snowflake
    
    branches : number of side branches
    radius   : radius of the snowflake
    
    A cube is created and transformed to taper with a diamond cross-section. 
    It is passed to flakeIterate to generate 1/6 of the snowflake. This branch 
    is duplicated and rotated around the centre to create the full snowflake. 
    The parts are combined, the flake is scaled and transformations are frozen. 
    The snowflake name is returned.
    '''
    name=cmds.polyCube()[0]
    cmds.rotate(45,0,0,name,r=1)
    cmds.move(0.5,0,0,name+'.vtx[0:7]',r=1)
    cmds.scale(0.7,0.2,0.1,p=[0,0,0],r=1)
    cmds.scale(1,0.7,0.7,name+'.f[4]',r=1,p=[0,0,0])
    cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
    partList=flakeIterate(name,7,random.uniform(30,70),0.7)
    branches=[combineParts(partList,'branch')]
    for i in range(1,6):
        branches[len(branches):]=[cmds.duplicate('branch')[0]]
        cmds.rotate(0,i*60,0,branches[-1],r=1)
    flake = combineParts(branches,'snowflake')
    scale = radius/6
    cmds.scale(scale,scale,scale,flake)
    cmds.makeIdentity(flake,apply=True, s=1, n=0)
    return flake
예제 #2
0
    def createLocators(self):
        #create list of loc names (self.name)
        for i in range(len(self.jointList)):
            self.locList.append("%s_%s_Loc"%(self.jointList[i],self.limbName))

        #check that these don't exist already
        if (cmds.objExists(self.locList[0])):
            cmds.error("these limb locators exists already!")
        else:

            #fill dictionary - assign values from list
            self.locPos = {}
            for j in range(len(self.locList)):
                self.locPos[self.locList[j]] = self.locPosValues[j]

            #create the locs
            for key in self.locPos.keys():
                thisLoc = cmds.spaceLocator(n=key)
                cmds.move(self.locPos[key][0], self.locPos[key][1], self.locPos[key][2], thisLoc)

            #parent them together (from list of loc names)
            for k in range((len(self.locList)-1),0,-1):
                cmds.parent(self.locList[k], self.locList[k-1])

######### make this true only for the arms. . . or figure out how to extract which rot this should be
            #rotate second joint to just get a preferred angle
            cmds.setAttr("%s.ry"%self.locList[1], -5)
def maya_move(angular_velocity, time_step):
            
    objects = cmds.ls(sl=True)
    if objects == []:
        print('* Please select at least an object.')
        return
        
    trajectory = cmds.ls('trajectory')
    
    for i, o in enumerate(objects):
        x = cmds.getAttr(o + '.translateX')
        y = cmds.getAttr(o + '.translateY')
        z = cmds.getAttr(o + '.translateZ')
    
        loc = [x, y, z]
        state = make_state(loc)
                
        state = simulate_circle(state, angular_velocity, time_step)
        
        old_loc = loc
        loc = get_location(state)
        
        cmds.select(o)
        cmds.move(loc[0], loc[1], loc[2])
        
        # draw trajectory for the first object
        if i == 0:
            if trajectory == []:
                cv = cmds.curve(point=[old_loc, loc], degree=1)                
                cmds.rename(cv, 'trajectory')
            else:
                cmds.curve('trajectory', point=[loc], degree=1, append=True)
        
    # keep all objects selected
    cmds.select(objects)
예제 #4
0
def	postProcessControl	(	_control,	_function,	_controlled	):	# <<< string, string, list
	lockHideAttributes	(	_control	)

	if (cmds.objExists('anim_control_set') == False):	cmds.createNode('objectSet',name='anim_control_set',skipSelect=True)

	cmds.sets	(	_control,	addElement	=	'anim_control_set'	)
	cmds.toggle	(	localAxis				=	1	)

	if	len	(	_controlled	)	==	0:
		_control	=	cmds.rename	(	'_'	+	_function	+	'_control'	)
		_control	=	cmds.group	( 	world	=	1,	name	=	'_'	+	_function	+	'_control_offSet'	)
		cmds.move					(	0,	0,	0,	_control	+	'.rotatePivot',	_control	+	'.scalePivot'	)

		lockHideAttributes	(	_control	)

	else:
		_k				=	_controlled[0].rfind	(	'|'	)
		_control		=	_controlled[0][_k+1:]
		cmds.rename		(	_control	+	'_'	+	_function	+	'_control'	)
		_control		=	cmds.group	(	world	=	1,	name	=	_control	+	'_'	+ _function	+	'_control_offSet'	)
		cmds.move			(	0, 0, 0, _control + '.rotatePivot', _control + '.scalePivot' )

		lockHideAttributes	(	_control	)

		cmds.select		(	_controlled[0],	toggle	=	True	)
		cmds.parent		()
		cmds.xform		(	translation	=	(	0,	0,	0	),	rotation	=	(	0,	0,	0	)	)
		cmds.parent		(	world		= 	1	)
	
	cmds.pickWalk	(	direction	=	"down"	)
예제 #5
0
def bestFitPlane(ptList,upVector=(0,1,0)):
	'''
	'''
	# Initialize plane normal
	norm = OpenMaya.MVector()
	pt = OpenMaya.MVector()
	
	# Calculate plane
	for i in range(len(ptList)):
		
		prev = OpenMaya.MVector(ptList[i-1][0],ptList[i-1][1],ptList[i-1][2])
		curr = OpenMaya.MVector(ptList[i][0],ptList[i][1],ptList[i][2])
		norm += OpenMaya.MVector((prev.z + curr.z) * (prev.y - curr.y), (prev.x + curr.x) * (prev.z - curr.z), (prev.y + curr.y) *  (prev.x - curr.x))
		pt += curr
	
	# Normalize result
	norm.normalize()
	pt /= len(ptList)
	
	# Build rotation matrix
	mat = glTools.utils.matrix.buildRotation(norm,upVector,'y','x')
	rot = glTools.utils.matrix.getRotation(mat,'xyz')
	
	# Create Plane
	plane = mc.polyPlane(w=1,h=1,sx=1,sy=1,ax=[0,1,0],cuv=2,ch=False)[0]
	
	# Position Plane
	mc.rotate(rot[0],rot[1],rot[2],plane,os=True,a=True)
	mc.move(pt[0],pt[1],pt[2],plane,ws=True,a=True)
	
	# Return result
	return plane
예제 #6
0
    def goToObject(self, first, second, *args ):
        
        if cmds.nodeType( first ) == 'joint':
            
            jo = cmds.getAttr( first+'.jo' )[0]
            mpxTransform = mpx.MPxTransformationMatrix()
            rotVector = om.MVector( math.radians( jo[0] ), math.radians( jo[1] ), math.radians( jo[2] ) ) 
            mpxTransform.rotateTo( om.MEulerRotation( rotVector ) )
            joMtx = mpxTransform.asMatrix()
            
            fMtx = om.MMatrix()
            fPMtx = om.MMatrix()
            fMtxList = cmds.getAttr( first+'.wm' )
            fPMtxList = cmds.getAttr( first+'.pm' )
            sMtx = om.MMatrix()
            sMtxList = cmds.getAttr( second+'.wm' )
            
            om.MScriptUtil.createMatrixFromList( fMtxList, fMtx )
            om.MScriptUtil.createMatrixFromList( fPMtxList, fPMtx )
            om.MScriptUtil.createMatrixFromList( sMtxList, sMtx )
            
            sMtxPose = [ sMtx(3,0), sMtx(3,1), sMtx(3,2) ]
            
            rMtx = sMtx*(joMtx*fPMtx).inverse()
            rTransform = mpx.MPxTransformationMatrix( rMtx )
            rVector = rTransform.eulerRotation().asVector()
            
            rot = [ math.degrees( rVector.x ), math.degrees( rVector.y ), math.degrees( rVector.z ) ]

            cmds.setAttr( first+'.r', *rot )
            cmds.move( sMtxPose[0], sMtxPose[1], sMtxPose[2], first, ws=1 )

        else:
            rigbase.goToSamePosition( first, second )
예제 #7
0
def moveMirrorPosObj(obj,targetObj):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Attempts to mirror an objects position and rotation

    ARGUMENTS:
    obj(string)
    targetObj(string)

    RETURNS:
    Nothin
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    objTrans = mc.xform (targetObj, q=True, ws=True, sp=True)
    actualName = mc.spaceLocator ()
    if objTrans[0] > 0:
        mc.xform (actualName[0],translation = [-objTrans[0],objTrans[1],objTrans[2]], ws=True)
        objTrans = mc.xform (actualName[0], q=True, ws=True, sp=True)
        mc.move (objTrans[0],objTrans[1],objTrans[2], [obj])
    else:
        mc.xform (actualName[0],translation = [objTrans[0],objTrans[1],objTrans[2]], a=True)
        objTrans = mc.xform (actualName[0], q=True, ws=True, sp=True)
        mc.move (-objTrans[0],objTrans[1],objTrans[2], [obj])
    mc.delete (actualName[0])
예제 #8
0
def placeGem(pt, norm):
	cmds.select('gem')
	cmds.instance()

	r_angle = getRotAngle(norm)
	cmds.rotate(r_angle[0],r_angle[1],r_angle[2], r = True)
	cmds.move(pt[0], pt[1], pt[2])
예제 #9
0
def m(p, _t=None):
    if not _t:
        _t = mc.ls(sl=1)

    for i in range (0,len(_t)):
        mc.select(_t[i])
        mc.move(p[0],p[1],p[2])
예제 #10
0
def returnClosestPointOnMeshInfoFromPos(pos, mesh):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns pertinent info of the closest point of a mesh to a position in space -
    position, normal, parameterU,parameterV,closestFaceIndex,closestVertexIndex

    ARGUMENTS:
    pos(string)
    mesh(string)

    RETURNS:
    closestPointInfo(dict)
    Keys:
    position
    normal
    parameterU
    parameterV
    closestFaceIndex
    closestVertexIndex
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """

    """ make the closest point node """
    closestPointNode = mc.createNode ('closestPointOnMesh')
    controlSurface = mc.listRelatives(mesh,shapes=True)

    """ to account for target objects in heirarchies """
    locBuffer = mc.spaceLocator()
    mc.move (pos[0],pos[1],pos[2], locBuffer[0])

    pointInfo = returnClosestPointOnMeshInfo(locBuffer[0],mesh)
    
    mc.delete(locBuffer[0],closestPointNode)
    return pointInfo
예제 #11
0
def snapPtsToSurface(surface,pointList):
	'''
	@param surface: Nurbs surface to snap points to
	@type surface: str
	@param pointList: Point to snap to the specified surface
	@type pointList: list
	'''
	# Check surface
	if not isSurface(surface): raise UserInputError('Object '+surface+' is not a valid surface!')
	
	# Check points
	pointList = mc.ls(pointList,fl=True)
	
	# Transform types
	transform = ['transform','joint','ikHandle','effector']
	
	# Snap points
	for pt in pointList:
		# Check Transform
		if transform.count(mc.objectType(pt)):
			snapToSurface(surface,pt,0.0,0.0,True,snapPivot=False)
			continue
		# Move Point
		pos = mc.pointPosition(pt)
		(uParam,vParam) = closestPoint(surface,pos)
		sPt = mc.pointOnSurface(surface,u=uParam,v=vParam,position=True)
		mc.move(sPt[0],sPt[1],sPt[2],pt,ws=True,a=True)
예제 #12
0
def ShapeInverterCmdold(base=None, corrective=None, name=None):
    mc.undoInfo(openChunk=True)
    if not base or not corrective:
        sel = mc.ls(sl=True)
        base, corrective = sel
    shapes = mc.listRelatives(base, children=True, shapes=True)
    for s in shapes:
        if mc.getAttr("%s.intermediateObject" % s) and mc.listConnections("%s.worldMesh" % s, source=False):
            origMesh = s
            break
    deformed = mc.polyPlane(ch=False)[0]
    mc.connectAttr("%s.worldMesh" % origMesh, "%s.inMesh" % deformed)
    mc.setAttr("%s.intermediateObject" % origMesh, 0)
    mc.delete(deformed, ch=True)
    mc.setAttr("%s.intermediateObject" % origMesh, 1)
    if not name:
        name = "%s_inverted#" % corrective
    invertedShape = duplicateMesh(base, name=name)
    deformer = mc.deformer(invertedShape, type="ShapeInverter")[0]
    mc.ShapeInverterCmd(baseMesh=base, invertedShape=invertedShape, ShapeInverterdeformer=deformer, origMesh=deformed)
    # correctiveShape = duplicateMesh(base,name=corrective+"_corrective#")
    # mc.connectAttr('%s.outMesh' % getShape(correctiveShape), '%s.correctiveMesh' % deformer)
    # transferMesh(corrective,[correctiveShape])
    mc.connectAttr("%s.outMesh" % getShape(corrective), "%s.correctiveMesh" % deformer)
    mc.setAttr("%s.activate" % deformer, True)
    mc.delete(deformed)
    bdingBx = mc.polyEvaluate(corrective, boundingBox=True)
    xDifVal = bdingBx[0][1] - bdingBx[0][0]
    # mc.move(xDifVal*1.10,correctiveShape,r=True,moveX=True)
    mc.move(xDifVal * 2.20, invertedShape, r=True, moveX=True)
    mc.undoInfo(closeChunk=True)
    return invertedShape  # ,correctiveShape
def bt_moveObjToCamera():
    
    #Check for hotkey and make if possible
    bt_checkCtrFHotkey()

    activePanel = cmds.getPanel(wf=1)
    if "model" in activePanel:
        activeCamera = cmds.modelEditor(activePanel,q=1,camera=1)   
    else:
        cmds.error ('No active panel/camera to frame to')    
         
    selected = cmds.ls(sl=1)
    
    locator = cmds.spaceLocator()
    cmds.select(activeCamera,add=1)
    cmds.parent(r=1)
    cmds.move(0,0,-5,locator,r=1,os=1)
    location = cmds.xform(q=1,t=1,ws=1)
    
    for object in selected:
        cmds.move(location[0],location[1],location[2],object,ws=1,a=1)
        #cmds.move(location[0],location[1],location[2],'pCube1',ws=1,a=1)
        
    cmds.delete(locator)   
    cmds.select(selected,r=1)
예제 #14
0
def setup_scene(name=sys.argv[1]):
    # imports shirt, scales to fit, converts to ncloth
    try:
        cmds.loadPlugin("objExport")
    except:
        pass
    mel.eval('file -f -options "mo=1" -ignoreVersion -typ "OBJ" -o "%s";' \
         % name)
    try:
        mel.eval('rename "Mesh" "shirt";')
    except:
        pass
    # scale shirt to fit
    create_table()
    if (fold_num == 0):
        bbx = cmds.xform("shirt", q=True, bb=True, ws=True)
        s_x_len = abs(bbx[3] - bbx[0])
        s_y_len = abs(bbx[4] - bbx[1])
        global GLOBAL_SCALE
        if (s_x_len >= s_y_len):
            GLOBAL_SCALE = s_x_len/(SHIRT_SCALE * TABLE_SIZE)
        else:
            GLOBAL_SCALE = s_y_len/(SHIRT_SCALE * TABLE_SIZE)
        cmds.select("shirt")
        cmds.move(0, 0.0001, 0, relative = True)
    cmds.scale(GLOBAL_SCALE, GLOBAL_SCALE, GLOBAL_SCALE, "table", centerPivot = True)
    shirt_to_nCloth()
    create_camera()
예제 #15
0
def create_pointer(m):
    if (BAXER_POINTER == True):
        # import Baxter Pointer model and use it
        try:
            cmds.loadPlugin("objExport")
        except:
            pass
        name = os.path.dirname(os.path.realpath(__file__)) + "/models/baxter_gripper.obj"
        mel.eval('file -import -type "OBJ"  -ignoreVersion -ra true -mergeNamespacesOnClash false -rpr "gripper" -options "mo=1"  -pr "%s";' \
             % name)
        try:
            mel.eval('rename "gripper_Mesh" "pointer' + str(m) + '";')
        except:
            pass
    else:
        # Create a pointer mesh that represents the robot claw
        cmds.polyCone(name="pointer" + str(m), sx=3, r=0.5, h=2)
        cmds.select("pointer" + str(m))
        cmds.rotate("180deg", 0, 0, r=True)
        cmds.move(0, -1, 0, "pointer" + str(m) + ".scalePivot", "pointer" + str(m) + ".rotatePivot")
        cmds.move(0, 1, 0, absolute=True)
        cmds.makeIdentity(apply=True, t=1, r=1, s=1)
    bbx = cmds.xform("table", q=True, bb=True, ws=True)
    cur_size = abs(bbx[3] - bbx[0])
    cmds.scale(cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, "pointer" + str(m), centerPivot = True)
    mel.eval('select -r pointer' + str(m) + '; sets -e -forceElement pointer_matSG;')
    mel.eval("makeCollideNCloth")
예제 #16
0
def autoMirror():
	'''
	Perform standard auto mirror based on selected center mesh edge.
	Mesh must be topologically symmetrical.
	'''
	# Load plugin
	loadPlugin()
	
	# Get middle edge selection
	edgeSel = mc.ls(sl=1,fl=1)[0]
	meshSel = mc.ls(edgeSel,o=True)[0]
	mc.select(meshSel)
	
	# Duplicate mesh
	meshDup = mc.duplicate(meshSel,rr=True,n=meshSel+'_symmetry')[0]
	
	# Get base vertex array
	pts = glTools.utils.base.getMPointArray(meshSel)
	
	# Get Symmetry map
	map = mm.eval('edgeFlowMirror -task "getMapArray" -middleEdge '+edgeSel)
	
	# Flip mesh
	for i in range(len(map)):
		mc.move(-pts[i][0],pts[i][1],pts[i][2],meshDup+'.vtx['+str(map[i])+']',a=True,ws=True)
	
	# BlendShape original
	bs = mc.blendShape(meshDup,meshSel)[0]
	bsAlias = mc.listAttr(bs+'.w',m=True)[0]
	mc.setAttr(bs+'.'+bsAlias,0.5)
	
	# Delete history
	mc.delete(meshDup)
	mc.delete(meshSel,ch=True)
예제 #17
0
	def generateForm(self) :
		"""
		This method returns the position of all vertices of an object. 
		"""
 		
		vtxWorldPosition = []
		mainObject = self.lineEditMainObject.displayText()
		usedObject = self.lineEditUsedObject.displayText()
		
		if mainObject:	
			# create a group for the new objects
			self.groupObject.createGroup("NewObjectsGroup")
			mc.SnapToPoint()

			vtxIndexList = mc.getAttr( mainObject+".vrts", multiIndices=True )
		 
			for i in vtxIndexList :
				curPointPosition = mc.xform( str(mainObject)+".pnts["+str(i)+"]", query=True, translation=True, worldSpace=True ) 
				mc.select( usedObject )
				newObject = mc.duplicate ( rr=True )
				self.groupObject.addInGroup("NewObjectsGroup", newObject)
				self.listNewObjects.append(newObject)
				mc.move(curPointPosition[0], curPointPosition[1], curPointPosition[2], newObject, rpr=True)

			mc.SnapToPoint()
		else:
			self.messageObject.showWindowMessage( "Please import objects!", "Select" )
	 
		mc.select( clear=True )
예제 #18
0
def createBlendshape(source, blendshape, AllP0, AllPDef):
    #------------MOTION VECTOR TRANSFER-------------#
    # create array of all vertices of the blendshape
    print blendshape
    cmds.move(0,0,0, blendshape)
    cmds.select(clear=True)
    cmds.select(blendshape+".vtx[*]")
    AllPBlend = cmds.ls(sl=1, fl=True)

    #vertex list original source mesh
    O = getVtxPos( source )

    #vertex list source mesh blendshape
    B = getVtxPos( blendshape )

    # matrix of motion vectors from source to blendshape vertex positions
    MV = numpy.matrix(B)-numpy.matrix(O) 
    MV = numpy.asmatrix(MV)
    
    '''
    # rotating and scaling of motion vectors using these functions gives wrong results,
    # I have not been able to debug this in the given time and have therefore taken these parts out for the moment.
    # Simply using the motion vectors on the deformed source mesh will result in acceptable blend shapes
    # given that the proportions of source and target meshes are not too different
    #-------------------------ROTATION-----------------------------#

    N0 = normalMatrix(AllP0) # normal matrix for source

    N1 = normalMatrix(AllPDef) # normal matrix for deformed source
    #------------

    # list of motion vector rotations
    R = []
    # find local source vertex coordinate systems before deformation, then after deformation
    for i in range(0, len(P0)):
        localOrig = findLocal(AllP0[i], N0[i])
        localDef = findLocal(AllPDef[i], N1[i])
        ODR = findRotationMatrix(localOrig, localDef)
        R.append(ODR)
    R = numpy.asarray(R)
        
    #--------------------------MAGNITUDE---------------------------#
        
    S = []
    for i in AllP0: 
        S.append(findScaleMatrix(i, AllP0, P0, R))
    S = numpy.asarray(S)

    #--------OVERALL MOTION VECTOR ROTATION AND MAGNITUDE ADJUSTMENT--------#

    # duplicate deformed source to make blendshape
    cmds.duplicate("sourceDeformed", n = blendName)
    cmds.select(clear=True)
    cmds.select(blendName+".vtx[*]")
    defBlend = cmds.ls(sl=1, fl=True)
    '''

    for i in range(0,n):
        cmds.move(float(MV[i, 0]), float(MV[i, 1]), float(MV[i, 2]), defBlend[i], r=True)
        '''
def cameraFrustum_build(cam_shape):
    #make sure a camera is loaded
    if cam_shape==0:
        cmds.error('no camera loaded...select a camera and load')
    else:
    #create frustum only if one doesnt already exist
        selCamXform = cmds.listRelatives(cam_shape[0], p=1)
        prefix = 'frust_'
        frustumGrpName = prefix + 'camera_frustum_all_grp'
        if cmds.objExists(frustumGrpName)==0:
        #create main grp
            frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
            cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
            cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)

        #create frustum geo
            frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
            cmds.delete(frustumGeo[0], constructionHistory=True)
            cmds.parent(frustumGeo[0], frustumMainGrp)

        #load plugin "nearestPointOnMesh.mll" if needed and connect
            plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
            if plugin==0:
                cmds.loadPlugin('nearestPointOnMesh.mll')

            nearNodeName = prefix + 'npomNode'
            npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
            cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')

        #create clusters
            cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
            nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
            cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
            farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')

        #create near/far/camera locs
            cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
            cmds.parent(cameraLoc[0], frustumMainGrp)
            nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
            cmds.move(0, 0, -1)
            farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
            cmds.move(0, 0, 1)

        #parent clusters under loc -- parent locs under camera loc
            cmds.parent(nearCluster[1], nearLoc[0])
            cmds.parent(farCluster[1], farLoc[0])
            cmds.parent(nearLoc[0], cameraLoc[0])
            cmds.parent(farLoc[0], cameraLoc[0])
        #constrain camera loc to camera
            cmds.parentConstraint(selCamXform, cameraLoc, weight=1)

        return frustumGeo[0]
def myCube():
    myCubeWidth = mc.intSliderGrp( cubW, q=True, v=True )
    myCubeHigth = mc.intSliderGrp( cubH, q=True, v=True )
    myCubeDepth = mc.intSliderGrp( cubD, q=True, v=True )
    # ch stands for construction history
    finalCube = mc.polyCube( w=myCubeWidth, h=myCubeHigth, d=myCubeDepth, n="myCube#", ch=False )
    mc.move( 0,myCubeHigth/2.0,0, finalCube, relative=True ) 
예제 #21
0
def snapObjectsOnSupport(objects, support):
	"""
	Snaps objects on support.

	:param objects: Objects to snap.
	:type objects: list
	:param value: Support.
	:type value: str
	"""

	if cmds.pluginInfo("nearestPointOnMesh", q=True, loaded=False):
		cmds.loadPlugin("nearestPointOnMesh")

	nearestPointOnMesh = cmds.createNode("nearestPointOnMesh")
	supportShape = getShapes(support)[0]
	cmds.connectAttr(supportShape + ".outMesh", nearestPointOnMesh + ".inMesh", f=True)

	allAxis = ("X", "Y", "Z")
	for object in objects:
		position = cmds.xform(object, q=True, rp=True, ws=True, a=True)
		for i, axis in enumerate(allAxis):
			cmds.setAttr(nearestPointOnMesh + ".inPosition" + axis, position[i])

		cmds.select(object)
		cmds.move(cmds.getAttr(nearestPointOnMesh + ".positionX"),
				cmds.getAttr(nearestPointOnMesh + ".positionY"),
				cmds.getAttr(nearestPointOnMesh + ".positionZ"),
				rpr=True)

	cmds.delete(nearestPointOnMesh)
예제 #22
0
def locMeCvFromCvIndex(shape,cvIndex):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Places locators on the cv's closest position on a curve

	ARGUMENTS:
	curve(string)

	RETURNS:
	locList(list)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	cv = ('%s%s%i%s'%(shape,'.cv[',cvIndex,']'))
	if mc.objExists(cv):
		cvPos = mc.pointPosition (cv,w=True)
		wantedName = (cv + 'loc')
		actualName = mc.spaceLocator (n= wantedName)
		mc.move (cvPos[0],cvPos[1],cvPos[2], [actualName[0]])
		uPos = distance.returnClosestUPosition (actualName[0],shape)
		mc.move (uPos[0],uPos[1],uPos[2], [actualName[0]])
		return actualName[0]
	else:
		guiFactory.warning  ('Shape does not exist')
		return False
예제 #23
0
def doPositionLocator(locatorName,locInfo):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Position a locator with locator info generated from returnInfoForLoc

	ARGUMENTS:
	locatorName(string)
	locInfo(dict)

	RETURNS:
	success(bool)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	if search.returnObjectType(locatorName) == 'locator':
		objTrans = locInfo['position']
		objRot = locInfo['rotation']
		correctRo = locInfo['rotationOrder']

		mc.move (objTrans[0],objTrans[1],objTrans[2], locatorName)
		mc.setAttr ((locatorName+'.rotateOrder'), correctRo)

		#Rotate
		if locInfo['objectType'] == 'polyFace':
			constBuffer = mc.normalConstraint((locInfo['createdFrom']),locatorName)
			mc.delete(constBuffer[0])
		else:
			mc.rotate (objRot[0], objRot[1], objRot[2], locatorName, ws=True)

		return True
	else:
		guiFactory.warning('Not a locator.')
		return False
    def duplicate_button( self, *args  ):
        self.original_selected_objects = cmds.ls( selection=True )

        if( len(self.original_selected_objects) == 0 ):
            print "Nothing selected"
            return 0

        elif( len(self.original_selected_objects) == 1 ):
            self.relatives = cmds.listRelatives( children=True )

            if( len(self.relatives) == 1 ):
                print "Skip combine"
                cmds.duplicate( self.original_selected_objects, name=self.original_selected_objects[0] + "_Copy" )
                cmds.delete( constructionHistory=True )
                the_parent = cmds.listRelatives( parent=True )
                if( the_parent != None ):
                    cmds.parent( self.original_selected_objects[0] + "_Copy", world=True )

            else:
                self.combine()

        else:
            self.combine()

        self.newOriginCopy = cmds.ls( selection=True )[0]
        self.bbox = cmds.exactWorldBoundingBox( self.newOriginCopy )
        cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, self.newOriginCopy + ".scalePivot", self.newOriginCopy + ".rotatePivot", absolute=True)
        cmds.move( 0, 0, 0, self.newOriginCopy, rpr=True )
        cmds.makeIdentity( apply=True, t=1, r=1, s=1 )
        cmds.delete( constructionHistory=True )
예제 #25
0
def locMeCenter(objList,forceBBCenter = False):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Pass  an object into it and get a named locator with stored info for updating it

	ARGUMENTS:
	obj(string)

	RETURNS:
	name(string)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	# make it
	nameBuffer = mc.spaceLocator()

	#store info
	attributes.storeInfo(nameBuffer[0],'cgmSource',(','.join(objList)),False)
	attributes.storeInfo(nameBuffer[0],'cgmLocMode','selectCenter',False)
	attributes.storeInfo(nameBuffer[0],'cgmName',(str('_to_'.join(objList))),False)
	attributes.storeInfo(nameBuffer[0],'cgmTypeModifier','midPoint',False)

	posList = []

	for obj in objList:
		if mc.objExists(obj) == True:
			objInfo = returnInfoForLoc(obj,forceBBCenter)
			posList.append(objInfo['position'])

	objTrans = distance.returnAveragePointPosition(posList)

	mc.move (objTrans[0],objTrans[1],objTrans[2], nameBuffer[0])

	#return ( NameFactory.doNameObject(nameBuffer[0]) )
	return cgmMeta.NameFactory(nameBuffer[0]).doNameObject()
예제 #26
0
def buildTargent(blendShape, targentname, weightID):
    postions = mc.getAttr('%s.it[0].itg[%s].iti[6000].ipt'%(blendShape, weightID))
    if postions == None :return
    points = mc.ls(['%s.%s'%(targentname, pnt)  for pnt in mc.getAttr('%s.it[0].itg[%s].iti[6000].ict'%(blendShape, weightID))], fl=True)
    
    for pnt, posi in zip(points, postions):
        mc.move(posi[0], posi[1], posi[2], pnt, r=True)
    def bulge_button( self, *args  ):
        if( cmds.objExists( "ZBend" ) ):
            cmds.confirmDialog( title="Error", message="First delete the bulge history on the previously\ndeformed object before bulging another.", button="Okie Dokie" )
            return 0

        latestSelection = cmds.ls( selection=True )
        if( len( latestSelection ) == 0 ):
            return 0

        if( len( latestSelection ) == 1 ):
            self.relatives = cmds.listRelatives( children=True )

            if( len(self.relatives) == 1 ):
                self.bbox = cmds.exactWorldBoundingBox( latestSelection )

                cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "x_bulge_slider", value=True, query=True ) )
                cmds.rename( "XBend" )
                cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "XBend", rpr=True )
                cmds.setAttr( "XBend.rotateZ", -90 )

                cmds.select( latestSelection )

                cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "z_bulge_slider", value=True, query=True ) )
                cmds.rename( "ZBend" )
                cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "ZBend", rpr=True )
                cmds.setAttr( "ZBend.rotateZ", -90 )
                cmds.setAttr( "ZBend.rotateX", 90 )
                cmds.connectControl( "x_bulge_slider", "bend1.curvature" )
                cmds.connectControl( "z_bulge_slider", "bend2.curvature" )
                cmds.select( latestSelection )
예제 #28
0
def locMeCVOnCurve(curveCV):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Places locators on the cv's closest position on a curve

	ARGUMENTS:
	curve(string)

	RETURNS:
	locList(list)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	if search.returnObjectType(curveCV) == 'curveCV':
		cvPos = mc.pointPosition (curveCV,w=True)
		wantedName = (curveCV + '_loc')
		actualName = mc.spaceLocator (n= wantedName)
		mc.move (cvPos[0],cvPos[1],cvPos[2], [actualName[0]])
		splitBuffer = curveCV.split('.')
		uPos = distance.returnClosestUPosition (actualName[0],splitBuffer[0])
		mc.move (uPos[0],uPos[1],uPos[2], [actualName[0]])
		return actualName[0]
	else:
		guiFactory.warning  ('Not a curveCV')
		return False
예제 #29
0
def align():
	obj1, obj2 = cmds.ls(selection=True, o=True)
	objPos = cmds.xform(obj2, q=1, ws=1, rp=1)
	objRot = cmds.xform(obj2, q=1, ro=True)
	cmds.move(objPos[0], objPos[1], objPos[2], obj1, rpr=True)
	cmds.rotate(objRot[0], objRot[1], objRot[2], obj1, r=True)
	cmds.select(obj1)
예제 #30
0
	def apply( self, nodes=None, applySettings=None, worldSpace=False ):
		if nodes is None:
			nodes = self._nodeAttrDict.iterkeys()

		for node in nodes:
			if node in self._nodeAttrDict:
				for attr, value in self._nodeAttrDict[ node ].iteritems():
					attrpath = '%s.%s' % (node, attr)
					if objExists( attrpath ):
						setAttr( attrpath, value )

			if worldSpace:
				if node in self._nodeWorldDict:
					if cmd.objectType( node, isAType='transform' ):
						pos, rot, rotateOrder = self._nodeWorldDict[node]
						move( pos[0], pos[1], pos[2], node, ws=True, a=True, rpr=True )

						roAttrpath = '%s.ro' % node
						initialRotateOrder = getAttr( roAttrpath )
						rotateOrderMatches = initialRotateOrder == rotateOrder

						if rotateOrderMatches:
							rotate( rot[0], rot[1], rot[2], node, ws=True, a=True )
						else:
							setAttr( roAttrpath, rotateOrder )
							rotate( rot[0], rot[1], rot[2], node, ws=True, a=True )
							xform( node, ro=constants.ROTATE_ORDER_STRS[ initialRotateOrder ], p=True )
예제 #31
0
    def Main_Side(self, side):
        sign = 1
        sideindex = 0
        if side == "L":
            sign = 1
            sideindex = 0
        else:
            sign = -1
            sideindex = 1

        # Eye
        self.CreatePrixyNode(self.Proxies_Eyes[sideindex],
                             PC=self.Proxies_Head,
                             mMvoe=[0.57 * sign, 1.53, 1.64],
                             isConnect=True)

        # Arm
        Clavicle = self.Proxies_Clavicles[sideindex]
        self.CreatePrixyNode(Clavicle,
                             PC=self.Proxies_SpineTop,
                             mMvoe=[sign * 1.25, 0.5, 0],
                             isConnect=True,
                             isParent=True)

        Shoulder = self.Proxies_Shoulders[sideindex]
        self.CreatePrixyNode(Shoulder,
                             PC=Clavicle,
                             mMvoe=[sign * 1.7, 0, 0],
                             isConnect=True,
                             isParent=True)

        Elbow = self.Proxies_Elbows[sideindex]
        self.CreatePrixyNode(Elbow,
                             PC=Shoulder,
                             mMvoe=[sign * 3.5, 0, 0],
                             isConnect=True)

        Wrist = self.Proxies_Wrists[sideindex]
        self.CreatePrixyNode(Wrist,
                             PC=Elbow,
                             mMvoe=[sign * 3.5, 0, 0],
                             isConnect=True)

        ElbowG = Elbow + "_GRP"
        cmds.group(n=ElbowG, em=True)
        PCons = cmds.pointConstraint(Elbow, ElbowG)
        cmds.delete(PCons)
        cmds.parent(Elbow, ElbowG)
        cmds.makeIdentity(ElbowG, apply=True, t=1, r=1, s=1)
        cmds.move(0,
                  0,
                  0.001,
                  "%s.scalePivot" % ElbowG,
                  "%s.rotatePivot" % ElbowG,
                  r=True)
        cmds.pointConstraint(Shoulder, Wrist, ElbowG, mo=True)
        cmds.parent(ElbowG, Wrist, self.Main)

        Palm = self.Proxies_Palms[sideindex]
        self.CreatePrixyNode(Palm,
                             PC=Wrist,
                             mMvoe=[sign * 0.7, 0, 0],
                             mScale=[0.7, 0.7, 0.7],
                             lScale=[0.175, 0.175, 0.175],
                             isConnect=True,
                             isParent=True)

        # Hand
        if self.thumbsOn:
            ThumbJ1 = self.Proxies_Thumbs[sideindex][0]
            self.CreatePrixyNode(ThumbJ1,
                                 PC=Wrist,
                                 mMvoe=[sign * 0.45, 0, 0.51],
                                 mScale=[0.75, 0.75, 0.75],
                                 lScale=[0.1875, 0.1875, 0.1875],
                                 isConnect=True,
                                 isParent=True)

            ThumbJ2 = self.Proxies_Thumbs[sideindex][1]
            self.CreatePrixyNode(ThumbJ2,
                                 PC=ThumbJ1,
                                 mMvoe=[sign * 0, 0, 0.75],
                                 mScale=[0.75, 0.75, 0.75],
                                 lScale=[0.1875, 0.1875, 0.1875],
                                 isConnect=True,
                                 isParent=True)

            ThumbJ3 = self.Proxies_Thumbs[sideindex][2]
            self.CreatePrixyNode(ThumbJ3,
                                 PC=ThumbJ2,
                                 mMvoe=[sign * 0, 0, 0.75],
                                 mScale=[0.75, 0.75, 0.75],
                                 lScale=[0.1875, 0.1875, 0.1875],
                                 isConnect=True,
                                 isParent=True)

            ThumbJTip = self.Proxies_Thumbs[sideindex][3]
            self.CreatePrixyNode(ThumbJTip,
                                 PC=ThumbJ3,
                                 mMvoe=[sign * 0, 0, 0.75],
                                 mScale=[0.75, 0.75, 0.75],
                                 lScale=[0.1875, 0.1875, 0.1875],
                                 isConnect=True,
                                 isParent=True)

            FingerList = self.Proxies_Fingers[sideindex]
            jointindex = 0
            for i, Finger in enumerate(FingerList):
                FingerJ1 = Finger[jointindex]
                if i == 0:
                    self.ProxyBase(FingerJ1)
                    PCons = cmds.pointConstraint(Wrist, FingerJ1)
                    cmds.delete(PCons)
                    cmds.move(sign * 1.47,
                              0,
                              0,
                              FingerJ1,
                              r=True,
                              os=True,
                              wd=True)
                    if self.fingersNum == 2:
                        cmds.move(0, 0, 0.25, FingerJ1, r=True)
                        cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                    elif self.fingersNum >= 3:
                        cmds.move(0, 0, 0.5, FingerJ1, r=True)
                        cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                else:
                    FingerJ0 = FingerList[i - 1][0]
                    self.ProxyBase(FingerJ1)
                    PCons = cmds.pointConstraint(FingerJ0, FingerJ1)
                    cmds.delete(PCons)
                    cmds.move(0, 0, -0.4, FingerJ1, r=True, os=True, wd=True)

                cmds.scale(0.62, 0.62, 0.62, FingerJ1)
                cmds.makeIdentity(FingerJ1, apply=True, t=1, r=1, s=1)
                cmds.setAttr("%sSnapShape.localScaleX" % FingerJ1, 0.155)
                cmds.setAttr("%sSnapShape.localScaleY" % FingerJ1, 0.155)
                cmds.setAttr("%sSnapShape.localScaleZ" % FingerJ1, 0.155)
                cmds.parent(FingerJ1, Palm)
                self.ProxyConnectors(Palm, FingerJ1)

                FingerJ2 = Finger[1]
                self.CreatePrixyNode(FingerJ2,
                                     PC=FingerJ1,
                                     mMvoe=[sign * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

                FingerJ3 = Finger[2]
                self.CreatePrixyNode(FingerJ3,
                                     PC=FingerJ2,
                                     mMvoe=[sign * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

                FingerJTip = Finger[3]
                self.CreatePrixyNode(FingerJTip,
                                     PC=FingerJ3,
                                     mMvoe=[sign * 0.61, 0, 0],
                                     mScale=[0.62, 0.62, 0.62],
                                     lScale=[0.155, 0.155, 0.155],
                                     isConnect=True,
                                     isParent=True)

            cmds.makeIdentity(Wrist, apply=True, t=1, r=1, s=1)

        # Leg
        Hip = self.Proxies_Hips[sideindex]
        self.CreatePrixyNode(Hip,
                             PC=self.Proxies_Root,
                             mMvoe=[sign * 1.72, -0.8, 0],
                             isConnect=True,
                             isParent=True)

        Knee = self.Proxies_Knees[sideindex]
        self.CreatePrixyNode(Knee,
                             PC=Hip,
                             mMvoe=[0, -6.4, 0],
                             mRotate=[0, 180, 90],
                             isConnect=True,
                             isParent=True)

        Ankle = self.Proxies_Ankles[sideindex]
        self.CreatePrixyNode(Ankle,
                             PC=Knee,
                             mMvoe=[0, -6.4, 0],
                             isConnect=True,
                             isParent=True)

        Ball = self.Proxies_Balls[sideindex]
        self.CreatePrixyNode(Ball,
                             PC=Ankle,
                             mMvoe=[0, -1.65, 2.26],
                             isConnect=True,
                             isParent=True)

        Toe = self.Proxies_Toes[sideindex]
        self.CreatePrixyNode(Toe, PC=Ball, mMvoe=[0, 0, 1.7])

        if self.toesNum == 1:
            self.ProxyConnectors(Ball, Toe)

        BallG = Ball + "_GRP"
        cmds.group(n=BallG, em=True)
        cmds.parent(BallG, Ball)
        cmds.parent(Toe, BallG)

        KneeLocator = Knee + "_Locator"
        cmds.spaceLocator(n=KneeLocator)
        PCons = cmds.pointConstraint(Knee, KneeLocator)
        cmds.delete(PCons)
        cmds.parent(KneeLocator, Knee)
        cmds.move(0, 0, 1.5, KneeLocator, r=True)
        cmds.setAttr("%s.v" % KneeLocator, 0)

        # toe num
        cmds.makeIdentity(Ball, apply=True, t=1, r=1, s=1)

        KneeG = Knee + "_GRP"
        cmds.group(n=KneeG, em=True)
        PCons = cmds.pointConstraint(Knee, KneeG)
        cmds.delete(PCons)
        cmds.parent(Knee, KneeG)
        cmds.makeIdentity(KneeG, apply=True, t=1, r=1, s=1)
        cmds.move(0,
                  0,
                  0.001,
                  "%s.scalePivot" % KneeG,
                  "%s.rotatePivot" % KneeG,
                  r=True)
        cmds.cycleCheck(e=0)
        cmds.pointConstraint(Hip, Ankle, KneeG, mo=True)
        cmds.cycleCheck(e=1)
        cmds.parent(KneeG, Ankle, self.Main)
        pass
import maya.cmds as mc

import pcCreateRig00AUtilities
from pcCreateRig00AUtilities import pcCreateRigUtilities as CRU

reload(pcCreateRig00AUtilities)

sels = mc.ls(sl=True)
sel = sels[0]

if len(sels) == 1:
    if CRU.checkObjectType(sel) == "mesh":
        if sel[:2] == "l_":
            toReplace = "l_"
            replaceWith = "r_"
        elif sel[:2] == "r_":
            toReplace = "r_"
            replaceWith = "l_"
        replaceName = sel.replace(toReplace, replaceWith)
        dupMesh = mc.duplicate(sel, n=replaceName, rc=True)[0]
        mc.move(0, 0, -50, replaceName, r=True)

    else:
        print("Please select a geometry")
else:
    print("Please select a single object")
예제 #33
0
    def dpMatchMesh(self, *args):
        """ Get selection and transfere vertice information.
        """
        # declaring variables
        fromTransformDic, toTransformDic = {}, {}
        attrList = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']

        # get a list of selected items
        selList = cmds.ls(selection=True)

        if (len(selList) <= 1):
            cmds.warning(
                "Select the FROM mesh first and the TO mesh after to transfer vertice data."
            )
        else:
            # declaring current variables
            fromFather = None
            fromTransform = selList[0]
            toTransform = selList[1]
            fromMesh = selList[0]
            toMesh = selList[1]
            gotMeshes = True

            # getting transforms
            if cmds.objectType(selList[0]) != "transform":
                parentList = cmds.listRelatives(selList[0],
                                                allParents=True,
                                                type="transform")
                if parentList:
                    fromTransform = parentList[0]
            if cmds.objectType(selList[1]) != "transform":
                parentList = cmds.listRelatives(selList[1],
                                                allParents=True,
                                                type="transform")
                if parentList:
                    toTransform = parentList

            # getting fromTransform father
            fromFatherList = cmds.listRelatives(fromTransform,
                                                allParents=True,
                                                type="transform")
            if fromFatherList:
                fromFather = fromFatherList[0]

            # getting meshes
            if cmds.objectType(selList[0]) != "mesh":
                childrenList = cmds.listRelatives(selList[0],
                                                  children=True,
                                                  type="mesh")
                if childrenList:
                    fromMesh = childrenList[0]
                else:
                    gotMeshes = False
            if cmds.objectType(selList[1]) != "mesh":
                childrenList = cmds.listRelatives(selList[1],
                                                  children=True,
                                                  type="mesh")
                if childrenList:
                    toMesh = childrenList[0]
                else:
                    gotMeshes = False

            if gotMeshes:
                # storing transformation data
                for attr in attrList:
                    fromTransformDic[attr] = cmds.getAttr(fromTransform + "." +
                                                          attr)
                    toTransformDic[attr] = cmds.getAttr(toTransform + "." +
                                                        attr)

                # get list of mesh vertice proccess
                # selecting meshes
                cmds.select([fromMesh, toMesh])
                meshList = om.MSelectionList()
                om.MGlobal_getActiveSelectionList(meshList)

                # declaring from and to objects, dagPaths and vertice lists
                fromObject = om.MObject()
                fromDagPath = om.MDagPath()
                toObject = om.MObject()
                toDagPath = om.MDagPath()
                fromVerticeList = om.MPointArray()
                toVerticeList = om.MPointArray()

                # getting dagPaths
                meshList.getDagPath(0, fromDagPath, fromObject)
                meshList.getDagPath(1, toDagPath, toObject)
                # getting open maya API mesh
                fromMeshFn = om.MFnMesh(fromDagPath)
                toMeshFn = om.MFnMesh(toDagPath)

                # verify the same number of vertices
                if fromMeshFn.numVertices() == toMeshFn.numVertices():
                    # put fromTransform in the same location then toTransform
                    if fromFather != None:
                        cmds.parent(fromTransform, world=True)
                    for attr in attrList:
                        cmds.setAttr(fromTransform + "." + attr, lock=False)
                        cmds.setAttr(toTransform + "." + attr, lock=False)
                        if not "s" in attr:
                            cmds.setAttr(fromTransform + "." + attr, 0)
                            cmds.setAttr(toTransform + "." + attr, 0)
                        else:
                            cmds.setAttr(fromTransform + "." + attr, 1)
                            cmds.setAttr(toTransform + "." + attr, 1)
                    tempToDeleteA = cmds.parentConstraint(fromTransform,
                                                          toTransform,
                                                          maintainOffset=False)
                    tempToDeleteB = cmds.scaleConstraint(fromTransform,
                                                         toTransform,
                                                         maintainOffset=False)
                    cmds.delete(tempToDeleteA, tempToDeleteB)

                    # getting vertices as points
                    fromMeshFn.getPoints(fromVerticeList)
                    toMeshFn.getPoints(toVerticeList)

                    # progress window
                    progressAmount = 0
                    cmds.progressWindow(title='Match Mesh Data',
                                        progress=progressAmount,
                                        status='Tranfering: 0%',
                                        isInterruptable=True)
                    cancelled = False

                    # transfer vetex position from FROM mesh to TO mesh selected
                    nbVertice = fromVerticeList.length()
                    for i in range(0, fromVerticeList.length()):
                        # update progress window
                        progressAmount += 1
                        # check if the dialog has been cancelled
                        if cmds.progressWindow(query=True, isCancelled=True):
                            cancelled = True
                            break
                        cmds.progressWindow(
                            edit=True,
                            maxValue=nbVertice,
                            progress=progressAmount,
                            status=('Transfering: ' + ` progressAmount ` +
                                    ' vertex'))

                        # transfer data
                        cmds.move(fromVerticeList[i].x,
                                  fromVerticeList[i].y,
                                  fromVerticeList[i].z,
                                  toMesh + ".vtx[" + str(i) + "]",
                                  absolute=True)

                    cmds.progressWindow(endProgress=True)

                    if fromFather != None:
                        cmds.parent(fromTransform, fromFather)
                    # restore transformation data
                    for attr in attrList:
                        cmds.setAttr(fromTransform + "." + attr,
                                     fromTransformDic[attr])
                        cmds.setAttr(toTransform + "." + attr,
                                     toTransformDic[attr])

                    if not cancelled:
                        print self.langDic[
                            self.langName]['i035_transfData'], self.langDic[
                                self.langName]['i036_from'].upper(
                                ), ":", fromMesh, ",", self.langDic[
                                    self.langName]['i037_to'].upper(
                                    ), ":", toMesh
                    else:
                        print self.langDic[self.langName]['i038_canceled']

                else:
                    mel.eval("warning \"" +
                             self.langDic[self.langName]['i039_notMatchDif'] +
                             "\";")
                cmds.select(selList)

            else:
                mel.eval("warning \"" +
                         self.langDic[self.langName]['i040_notMatchSel'] +
                         "\";")
예제 #34
0
 def move_link(self, ring):
     """Translate the ring based on its position in the chain."""
     magnitudeOfTranslate = (ring.get_ringNumber()) * (self.radius) + (
         ring.get_ringNumber()) * (self.radius - 2 * (self.linkRadius))
     cmds.move(magnitudeOfTranslate, 0, 0, ring.get_transform())
예제 #35
0
def main(name="spine", positions=None, radius=1):

    # create template joints if needed
    tmp = None
    if not positions:
        positions = template()
        tmp = positions[:]  # copy

    # positions from template transforms/joints
    for i in range(6):
        if type(positions[i]) == str or type(positions[i]) == unicode:
            positions[i] = mc.xform(positions[i], q=True, rp=True, ws=True)

    grp = mc.createNode("transform", n=name)

    #
    # joints, part 1
    #

    ik = [None] * 9
    mc.select(cl=True)
    ik[0] = mc.joint(p=positions[0], n=name + "_ik1_off")
    ik[2] = mc.joint(p=positions[1], n=name + "_ik2")
    mc.joint(ik[0], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    # insert an "offset" joint for proper ik spline twist
    ik[3] = mc.joint(p=[i * 0.5 for i in map(add, positions[1], positions[2])],
                     n=name + "_ik3_off")
    mc.joint(ik[2], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    ik[4] = mc.joint(p=positions[2], n=name + "_ik3")
    mc.joint(ik[3], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    ik[5] = mc.joint(p=positions[3], n=name + "_ik4")
    mc.joint(ik[4], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    ik[6] = mc.joint(p=positions[4], n=name + "_ik5")
    mc.joint(ik[5], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    mc.setAttr(ik[6] + ".jo", 0, 0, 0)
    # insert an "offset" joint for proper ik spline twist
    ik[7] = mc.joint(p=[i * 0.5 for i in map(add, positions[4], positions[5])],
                     n=name + "_ik6_off")
    mc.joint(ik[6], e=True, oj="xyz", sao="xup", ch=False, zso=True)
    ik[8] = mc.joint(p=positions[5], n=name + "_ik6")
    mc.joint(ik[7], e=True, oj="xyz", sao="xup", ch=False, zso=True)

    ik[1] = mc.duplicate(ik[0])[0]
    ik[1] = mc.rename(ik[1], name + "_ik1")
    mc.delete(mc.listRelatives(ik[1], pa=True, ad=True))
    ik[1] = mc.parent(ik[1], ik[0])[0]

    for n in ik:
        mc.setAttr(n + ".radius", radius * 0.5)
    for n in [ik[0], ik[3], ik[7]]:
        mc.setAttr(n + ".drawStyle", 2)

    #
    # controls
    #

    ctrl_grp = [None] * 5
    ctrl = [None] * 5
    ctrl_grp[0], ctrl[0] = common.control(name=name + "_ik1",
                                          parent=grp,
                                          position=ik[0],
                                          radius=radius * 2,
                                          lockAttr=["s", "v"],
                                          hideAttr=["sx", "sy", "sz", "v"])
    mc.addAttr(ctrl[0], ln="joints", at="bool", dv=True, k=True)
    mc.addAttr(ctrl[0], ln="editJoints", at="bool", k=True)

    ctrl_grp[1], ctrl[1] = common.control(name=name + "_ik2",
                                          parent=ctrl[0],
                                          position=ik[2],
                                          radius=radius * 2,
                                          lockAttr=["s", "v"],
                                          hideAttr=["sx", "sy", "sz", "v"])

    ctrl_grp[2], ctrl[2] = common.control(name=name + "_ik3",
                                          parent=ctrl[1],
                                          position=ik[4],
                                          radius=radius * 2,
                                          lockAttr=["s", "v"],
                                          hideAttr=["sx", "sy", "sz", "v"])
    mc.addAttr(ctrl[2], ln="stretchAbove", at="bool", k=True)
    mc.addAttr(ctrl[2], ln="stretchBelow", at="bool", k=True)

    ctrl_grp[3], ctrl[3] = common.control(name=name + "_ik5",
                                          parent=ctrl[2],
                                          position=ik[6],
                                          radius=radius,
                                          lockAttr=["s", "v"],
                                          hideAttr=["sx", "sy", "sz", "v"])
    anchor = mc.createNode("transform", n="spine_ik4_anchor", p=ik[4])
    mc.delete(mc.parentConstraint(ik[5], anchor))
    c = mc.parentConstraint(anchor, ctrl_grp[3], mo=True)[0]
    mc.rename(c, ctrl_grp[3] + "_parcon")

    ctrl_grp[4], ctrl[4] = common.control(name=name + "_ik6",
                                          parent=ctrl[3],
                                          position=ik[8],
                                          radius=radius,
                                          lockAttr=["s", "v"],
                                          hideAttr=["sx", "sy", "sz", "v"])
    mc.addAttr(ctrl[4], ln="stretch", at="bool", k=True)

    md = mc.createNode("multiplyDivide")
    mc.setAttr(md + ".operation", 2)
    mc.setAttr(md + ".input1X", 1)
    mc.connectAttr(ik[4] + ".sx", md + ".input2X")
    mc.connectAttr(md + ".outputX", anchor + ".sx")

    #
    # joints, part 2
    #

    c = mc.orientConstraint(ctrl[2], ik[4], mo=True)[0]
    mc.rename(c, ik[4] + "_oricon")

    #
    # ik handles
    #

    mc.select(ik[0], ik[4])
    ikh, eff, crv = mc.ikHandle(sol="ikSplineSolver")
    crv = mc.parent(crv, grp)[0]
    mc.setAttr(crv + ".it", False)
    mc.setAttr(ikh + ".dTwistControlEnable", True)
    mc.setAttr(ikh + ".dWorldUpType", 4)
    mc.setAttr(ikh + ".dWorldUpAxis", 3)
    mc.setAttr(ikh + ".dWorldUpVector", 0, 0, -1)
    mc.setAttr(ikh + ".dWorldUpVectorEnd", 0, 0, -1)
    ikh = mc.parent(ikh, grp)[0]
    mc.hide(ikh, crv)
    ikh = mc.rename(ikh, name + "_ikh#")
    mc.rename(eff, name + "_eff#")

    # adjust "offset" joint position for proper ik spline twist
    mc.move(positions[2][0], positions[2][1], positions[2][2],
            ik[3] + ".scalePivot", ik[3] + ".rotatePivot")
    mc.move(0,
            -0.001,
            0,
            ik[3] + ".scalePivot",
            ik[3] + ".rotatePivot",
            r=True)

    c1 = mc.cluster(crv + ".cv[0]")[1]
    c2 = mc.cluster(crv + ".cv[1]", crv + ".cv[2]")[1]
    c3 = mc.cluster(crv + ".cv[3]")[1]
    mc.hide(c1, c2, c3)
    mc.parent(c1, ctrl[0])
    mc.parent(c2, ctrl[1])
    mc.parent(c3, ctrl[2])

    mc.connectAttr(ctrl[0] + ".worldMatrix", ikh + ".dWorldUpMatrix")
    mc.connectAttr(ctrl[2] + ".worldMatrix", ikh + ".dWorldUpMatrixEnd")

    mc.select(ik[5], ik[8])
    ikh, eff, crv2 = mc.ikHandle(sol="ikSplineSolver")
    crv2 = mc.parent(crv2, grp)[0]
    mc.setAttr(crv2 + ".t", 0, 0, 0)
    mc.setAttr(crv2 + ".r", 0, 0, 0)
    mc.setAttr(crv2 + ".s", 1, 1, 1)
    mc.setAttr(crv2 + ".it", False)
    mc.setAttr(ikh + ".dTwistControlEnable", True)
    mc.setAttr(ikh + ".dWorldUpType", 4)
    mc.setAttr(ikh + ".dWorldUpAxis", 3)
    mc.setAttr(ikh + ".dWorldUpVector", 0, 0, -1)
    mc.setAttr(ikh + ".dWorldUpVectorEnd", 0, 0, -1)
    ikh = mc.parent(ikh, grp)[0]
    mc.hide(ikh, crv2)
    ikh = mc.rename(ikh, name + "_ikh#")
    mc.rename(eff, name + "_eff#")

    # adjust "offset" joint position for proper ik spline twist
    mc.move(positions[5][0], positions[5][1], positions[5][2],
            ik[7] + ".scalePivot", ik[7] + ".rotatePivot")
    mc.move(0,
            -0.001,
            0,
            ik[7] + ".scalePivot",
            ik[7] + ".rotatePivot",
            r=True)

    c1 = mc.cluster(crv2 + ".cv[0]")[1]
    c2 = mc.cluster(crv2 + ".cv[1]", crv2 + ".cv[2]")[1]
    c3 = mc.cluster(crv2 + ".cv[3]")[1]
    mc.hide(c1, c2, c3)
    mc.parent(c1, ik[4])
    mc.parent(c2, ctrl[3])
    mc.parent(c3, ctrl[4])

    mc.connectAttr(ctrl[2] + ".worldMatrix", ikh + ".dWorldUpMatrix")
    mc.connectAttr(ctrl[4] + ".worldMatrix", ikh + ".dWorldUpMatrixEnd")

    mc.delete(mc.ls(typ="tweak"))

    c = mc.orientConstraint(ctrl[0], ik[1], mo=True)[0]
    mc.rename(c, ik[1] + "_oricon")
    c = mc.orientConstraint(ctrl[4], ik[8], mo=True)[0]
    mc.rename(c, ik[8] + "_oricon")

    #
    # stretch math
    #

    ci = mc.createNode("curveInfo")
    mc.connectAttr(crv + ".worldSpace", ci + ".inputCurve")

    ci2 = mc.createNode("curveInfo")
    mc.connectAttr(crv2 + ".worldSpace", ci2 + ".inputCurve")

    n = mc.listRelatives(crv, pa=True, s=True)[1]
    tg = mc.createNode("transformGeometry")
    mc.connectAttr(n + ".worldSpace", tg + ".inputGeometry")
    mc.connectAttr(grp + ".worldMatrix", tg + ".transform")
    ci3 = mc.createNode("curveInfo")
    mc.connectAttr(tg + ".outputGeometry", ci3 + ".inputCurve")

    n = mc.listRelatives(crv2, pa=True, s=True)[1]
    tg = mc.createNode("transformGeometry")
    mc.connectAttr(n + ".worldSpace", tg + ".inputGeometry")
    mc.connectAttr(grp + ".worldMatrix", tg + ".transform")
    ci4 = mc.createNode("curveInfo")
    mc.connectAttr(tg + ".outputGeometry", ci4 + ".inputCurve")

    md1 = mc.createNode("multiplyDivide")
    mc.setAttr(md1 + ".operation", 2)
    mc.connectAttr(ci + ".arcLength", md1 + ".input1X")
    mc.connectAttr(ci3 + ".arcLength", md1 + ".input2X")
    md2 = mc.createNode("multiplyDivide")
    mc.connectAttr(md1 + ".outputX", md2 + ".input1X")
    mc.connectAttr(ctrl[2] + ".stretchBelow", md2 + ".input2X")
    c = mc.createNode("condition")
    mc.setAttr(c + ".secondTerm", 1)
    mc.setAttr(c + ".operation", 3)
    mc.connectAttr(md1 + ".outputX", c + ".colorIfTrueR")
    mc.connectAttr(md2 + ".outputX", c + ".firstTerm")
    mc.connectAttr(c + ".outColorR", ik[0] + ".sx")
    mc.connectAttr(c + ".outColorR", ik[2] + ".sx")

    md2 = mc.createNode("multiplyDivide")
    mc.connectAttr(md1 + ".outputX", md2 + ".input1X")
    mc.connectAttr(ctrl[2] + ".stretchAbove", md2 + ".input2X")
    c = mc.createNode("condition")
    mc.setAttr(c + ".secondTerm", 1)
    mc.setAttr(c + ".operation", 3)
    mc.connectAttr(md1 + ".outputX", c + ".colorIfTrueR")
    mc.connectAttr(md2 + ".outputX", c + ".firstTerm")
    mc.connectAttr(c + ".outColorR", ik[4] + ".sx")

    md1 = mc.createNode("multiplyDivide")
    mc.setAttr(md1 + ".operation", 2)
    mc.connectAttr(ci2 + ".arcLength", md1 + ".input1X")
    mc.connectAttr(ci4 + ".arcLength", md1 + ".input2X")
    md2 = mc.createNode("multiplyDivide")
    mc.connectAttr(md1 + ".outputX", md2 + ".input1X")
    mc.connectAttr(ctrl[4] + ".stretch", md2 + ".input2X")
    c = mc.createNode("condition")
    mc.setAttr(c + ".secondTerm", 1)
    mc.setAttr(c + ".operation", 3)
    mc.connectAttr(md1 + ".outputX", c + ".colorIfTrueR")
    mc.connectAttr(md2 + ".outputX", c + ".firstTerm")
    mc.connectAttr(c + ".outColorR", ik[5] + ".sx")
    mc.connectAttr(c + ".outColorR", ik[6] + ".sx")

    j = 0
    jnt = [None] * 6
    for i in range(1, 9):
        if i == 3 or i == 7: continue
        jnt[j] = mc.createNode("joint", n=name + "_jnt" + str(j + 1), p=grp)
        mc.setAttr(jnt[j] + ".radius", radius * 0.5)
        mc.connectAttr(ctrl[0] + ".joints", jnt[j] + ".v")
        c = mc.parentConstraint(ik[i], jnt[j])[0]
        mc.rename(c, name + "_jnt" + str(j) + "_parcon")
        j += 1

    # selection sets
    common.sets(name, jnt, None, ctrl)

    # selectable joints
    common.selectable(ctrl[0] + ".editJoints", jnt)

    if tmp: mc.delete(tmp)
    ik[0] = mc.parent(ik[0], grp)[0]
    mc.hide(ik[0])
    mc.select(grp)
    mc.dgdirty(a=True)

    return grp
예제 #36
0
    def KneeIndicator(self, side):
        sign = 1
        sideindex = 0
        if side == "L":
            sign = 1
            sideindex = 0
        else:
            sign = -1
            sideindex = 1

        # fetch & name
        Hip = self.Proxies_Hips[sideindex]
        Ankle = self.Proxies_Ankles[sideindex]
        Knee = self.Proxies_Knees[sideindex]

        KneeG = Knee + "_GRP"
        Proxies_KneeParent = Knee + "_Parent"
        Proxies_KneeAim = Knee + "_Aim"
        Proxies_KneeParentUp = Knee + "_ParentUp"
        Proxies_KneeParentUp_GRP = Knee + "_ParentUp_GRP"

        # Locator
        cmds.spaceLocator(n=Proxies_KneeParent)
        cmds.parent(Proxies_KneeParent, self.Main)
        cmds.spaceLocator(n=Proxies_KneeAim)
        cmds.move(0, -2, 0, Proxies_KneeAim, r=True)
        cmds.parent(Proxies_KneeAim, Proxies_KneeParent)
        cmds.spaceLocator(n=Proxies_KneeParentUp, p=(0, 0, 0))
        cmds.group(n=Proxies_KneeParentUp_GRP)
        cmds.pointConstraint(Hip, Proxies_KneeParentUp_GRP, offset=(0, 2, 0))
        cmds.parent(Proxies_KneeParentUp_GRP, self.Main)

        # connect
        Proxies_KneeParentUp_MD = "%s_MD" % Proxies_KneeParentUp
        cmds.shadingNode("multiplyDivide",
                         asUtility=True,
                         n=Proxies_KneeParentUp_MD)
        cmds.setAttr("%s.operation" % Proxies_KneeParentUp_MD, 2)
        cmds.setAttr("%s.input2X" % Proxies_KneeParentUp_MD, -2)
        cmds.connectAttr("%s.translateX" % Ankle,
                         "%s.input1X" % Proxies_KneeParentUp_MD)
        cmds.connectAttr("%s.outputX" % Proxies_KneeParentUp_MD,
                         "%s.translateX" % Proxies_KneeParentUp)
        cmds.pointConstraint(Hip, Proxies_KneeParent)
        cmds.pointConstraint(Hip, Ankle, Proxies_KneeAim)

        cmds.connectAttr("%s.rotate" % Proxies_KneeParent, "%s.rotate" % KneeG)

        cmds.aimConstraint(Ankle,
                           Proxies_KneeParent,
                           aimVector=[0, -1, 0],
                           upVector=[0, 1, 0],
                           worldUpType="object",
                           worldUpObject=Proxies_KneeParentUp)

        cmds.aimConstraint(Proxies_KneeAim,
                           Knee,
                           aimVector=[0, 0, -1],
                           upVector=[0, 1, 0],
                           worldUpType="objectrotation",
                           worldUpVector=[0, 1, 0],
                           worldUpObject=Proxies_KneeAim,
                           skip=['x', 'z'])

        # Hidden
        cmds.setAttr("%s.v" % Proxies_KneeAim, 0)
        cmds.setAttr("%s.v" % Proxies_KneeParent, 0)
        cmds.setAttr("%s.v" % Proxies_KneeParentUp, 0)

        pass
예제 #37
0
    def ElbowIndicator(self, side):
        sign = 1
        sideindex = 0
        if side == "L":
            sign = 1
            sideindex = 0
        else:
            sign = -1
            sideindex = 1

        # fetch
        Proxies_Elbow = self.Proxies_Elbows[sideindex]
        Proxies_Shoulder = self.Proxies_Shoulders[sideindex]
        Proxies_Wrist = self.Proxies_Wrists[sideindex]

        Proxies_Elbow_GRP = Proxies_Elbow + "_GRP"
        Proxies_ElbowParent = Proxies_Elbow + "_Parent"
        Proxies_ElbowAim = Proxies_Elbow + "_Aim"
        Proxies_ElbowParentUp = Proxies_Elbow + "_ParentUp"
        Proxies_ElbowParentUp_GRP = Proxies_Elbow + "_ParentUp_GRP"

        # Locator
        cmds.spaceLocator(n=Proxies_ElbowParent)
        cmds.parent(Proxies_ElbowParent, self.Main)
        cmds.spaceLocator(n=Proxies_ElbowAim)
        cmds.move(2 * sign, 0, 0, Proxies_ElbowAim, r=True)
        cmds.parent(Proxies_ElbowAim, Proxies_ElbowParent)
        cmds.spaceLocator(n=Proxies_ElbowParentUp, p=(0, 0, 0))
        cmds.group(n=Proxies_ElbowParentUp_GRP)
        cmds.pointConstraint(Proxies_Shoulder,
                             Proxies_ElbowParentUp_GRP,
                             skip=['x', 'z'])
        cmds.parent(Proxies_ElbowParentUp_GRP, self.Main)

        # connect
        Proxies_ElbowParentUp_MD = "%s_MD" % Proxies_ElbowParentUp
        cmds.shadingNode("multiplyDivide",
                         asUtility=True,
                         n=Proxies_ElbowParentUp_MD)
        cmds.setAttr("%s.operation" % Proxies_ElbowParentUp_MD, 2)
        cmds.setAttr("%s.input2X" % Proxies_ElbowParentUp_MD, -2)
        cmds.connectAttr("%s.translateY" % Proxies_Wrist,
                         "%s.input1X" % Proxies_ElbowParentUp_MD)
        cmds.connectAttr("%s.outputX" % Proxies_ElbowParentUp_MD,
                         "%s.translateY" % Proxies_ElbowParentUp)
        cmds.pointConstraint(Proxies_Shoulder, Proxies_ElbowParent)
        cmds.pointConstraint(Proxies_Shoulder, Proxies_Wrist, Proxies_ElbowAim)
        cmds.connectAttr("%s.rotate" % Proxies_ElbowParent,
                         "%s.rotate" % Proxies_Elbow_GRP)
        cmds.aimConstraint(Proxies_Wrist,
                           Proxies_ElbowParent,
                           aimVector=[1 * sign, 0, 0],
                           upVector=[-1 * sign, 0, 0],
                           worldUpType="object",
                           worldUpObject=Proxies_ElbowParentUp)
        cmds.aimConstraint(Proxies_ElbowAim,
                           Proxies_Elbow,
                           aimVector=[0, 0, 1],
                           upVector=[0, 1, 0],
                           worldUpType="none",
                           skip=['y', 'z'])

        # Hidden
        cmds.setAttr("%s.v" % Proxies_ElbowAim, 0)
        cmds.setAttr("%s.v" % Proxies_ElbowParent, 0)
        cmds.setAttr("%s.v" % Proxies_ElbowParentUp, 0)

        pass
예제 #38
0
def orientSegment(limbJoints, posTemplateObjects, orientation):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Basic limb skeletonizer
    
    ARGUMENTS:
    limbJoints(list)
    templeateObjects(list)
    orientation(string) - ['xyz','yzx','zxy','xzy','yxz','zyx']
    
    RETURNS:
    limbJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    """ orientation vectors"""
    orientationVectors = search.returnAimUpOutVectorsFromOrientation(
        orientation)
    wantedAimVector = orientationVectors[0]
    wantedUpVector = orientationVectors[1]
    """put objects in order of closeness to root"""
    limbJoints = distance.returnDistanceSortedList(limbJoints[0], limbJoints)

    #>>> Segment our joint list by names
    jointSegmentsList = []
    cullList = []
    """ gonna be culling items from the list so need to rebuild it, just doing a list1 = list2 
    somehow keeps the relationship....odd """
    for obj in limbJoints:
        cullList.append(obj)

    while len(cullList) > 0:
        matchTerm = search.returnTagInfo(cullList[0], 'cgmName')
        objSet = search.returnMatchedTagsFromObjectList(
            cullList, 'cgmName', matchTerm)
        jointSegmentsList.append(objSet)
        for obj in objSet:
            cullList.remove(obj)

    #>>> get our orientation helpers
    helperObjects = []
    for obj in posTemplateObjects:
        templateObj = attributes.returnMessageObject(obj, 'cgmName')
        helperObjects.append(
            attributes.returnMessageObject(templateObj, 'orientHelper'))

    #>>> un parenting the chain
    for joint in limbJoints[1:]:
        mc.parent(joint, world=True)

    #>>>per segment stuff
    cnt = 0
    for segment in jointSegmentsList:
        if len(segment) > 1:
            """ creat our up object from from the helper object """
            helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt],
                                                        shapes=True)
            upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0],
                                                30)
            print upLoc
            """ make a pair list"""
            pairList = lists.parseListToPairs(segment)
            for pair in pairList:
                """ set up constraints """
                constraintBuffer = mc.aimConstraint(pair[1],
                                                    pair[0],
                                                    maintainOffset=False,
                                                    weight=1,
                                                    aimVector=wantedAimVector,
                                                    upVector=wantedUpVector,
                                                    worldUpVector=[0, 1, 0],
                                                    worldUpObject=upLoc,
                                                    worldUpType='object')
                mc.delete(constraintBuffer[0])
            for obj in segment[-1:]:
                constraintBuffer = mc.orientConstraint(segment[-2],
                                                       obj,
                                                       maintainOffset=False,
                                                       weight=1)
                mc.delete(constraintBuffer[0])
            """ increment and delete the up loc """
            cnt += 1
            mc.delete(upLoc)
        else:
            helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt],
                                                        shapes=True)
            upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0],
                                                30)
            """ make an aim object """
            aimLoc = locators.locMeObject(helperObjects[cnt])
            aimLocGroup = rigging.groupMeObject(aimLoc)
            mc.move(10, 0, 0, aimLoc, localSpace=True)
            constraintBuffer = mc.aimConstraint(aimLoc,
                                                segment[0],
                                                maintainOffset=False,
                                                weight=1,
                                                aimVector=wantedAimVector,
                                                upVector=wantedUpVector,
                                                worldUpVector=[0, 1, 0],
                                                worldUpObject=upLoc,
                                                worldUpType='object')
            mc.delete(constraintBuffer[0])
            mc.delete(aimLocGroup)
            mc.delete(upLoc)
            cnt += 1
    #>>>reconnect the joints
    pairList = lists.parseListToPairs(limbJoints)
    for pair in pairList:
        mc.parent(pair[1], pair[0])
    """ Freeze the rotations """
    mc.makeIdentity(limbJoints[0], apply=True, r=True)
    return limbJoints
예제 #39
0
    def testUndoRedo(self):
        self._StartTest('capsule')

        mayaUtils.loadPlugin("ufeSupport")

        cmds.move(3, -3, 3, 'persp')
        cmds.rotate(60, 0, 45, 'persp')

        # modify the capsule's height, then undo and redo that operation and
        # make sure the viewport updates as expected.
        mayaPathSegment = mayaUtils.createUfePathSegment('|stage|stageShape')
        capsuleUsdPathSegment = usdUtils.createUfePathSegment('/Capsule1')
        capsulePath = ufe.Path([mayaPathSegment, capsuleUsdPathSegment])
        capsuleItem = ufe.Hierarchy.createItem(capsulePath)
        capsuleAttrs = ufe.Attributes.attributes(capsuleItem)
        heightAttr = capsuleAttrs.attribute('height')

        # get the undo queue into a clean state with nothing on the queue
        # and no open chunks

        # disable and flush the undo queue
        cmds.undoInfo(state=False)

        # the undo queue could still have some open chunks which were in the
        # process of being created when I turned the undo queue off. For example,
        # this test gets run from the mel "python" command (see test.cmake), and
        # that chunk is currently open.
        # If I try to query the current chunk string to see if something IS open,
        # it is always the command I used to try to query the current chunk name!
        # Experimentally, I found have that there are typically two open chunks.
        # So just close two chunks.
        cmds.undoInfo(closeChunk=True)
        cmds.undoInfo(closeChunk=True)
        # flush those truncated chunks if they are on the undo queue. They shouldn't
        # be, because I already disabled the undo queue, but I am paranoid.
        cmds.flushUndo()

        # Now run the actual test I want to run. Enable the undo queue for each command
        # that I want on the queue, and disable the undo queue again, without flushing,
        # immediately after.

        cmds.undoInfo(stateWithoutFlush=True)
        ufeCmd.execute(heightAttr.setCmd(3))
        cmds.undoInfo(stateWithoutFlush=False)
        
        self.assertSnapshotClose('%s_set_height.png' % self._testName)
        
        cmds.undoInfo(stateWithoutFlush=True)
        cmds.undo()
        cmds.undoInfo(stateWithoutFlush=False)
        
        self.assertSnapshotClose('%s_undo_set_height.png' % self._testName)
        
        cmds.undoInfo(stateWithoutFlush=True)
        cmds.redo()
        cmds.undoInfo(stateWithoutFlush=False)
        
        self.assertSnapshotClose('%s_redo_set_height.png' % self._testName)
        
        # Now the test is over, turn the undo queue back on incase this Maya session
        # gets re-used for more tests.
        cmds.undoInfo(stateWithoutFlush=True)
예제 #40
0
def reset_selection_callback(*args):
    selected_controllers = cmds.ls( selection=True )
    for button in ctrlManager.buttons:
        if button.controller in selected_controllers:
            cmds.rotate( 0, 0, 0, button.controller, absolute=True)
            cmds.move( 0, 0, 0, button.controller, absolute=True)
예제 #41
0
def optimizeCVsForImage(mirror,
                        screen,
                        pupilPoints,
                        virtualImage,
                        costFunction=normalCost,
                        start=-1.,
                        iterations=5,
                        border=False):
    # work your way through each cv improving until it can't get better
    best = mc.group(em=1, n='best')
    bMirror = mc.duplicate(mirror, n='best%s' % mirror)[0]
    mc.parent(bMirror, best)
    cvU = mc.getAttr('%s.spansU' % mirror) + mc.getAttr('%s.degreeU' % mirror)
    cvV = mc.getAttr('%s.spansV' % mirror) + mc.getAttr('%s.degreeV' % mirror)
    shape = (cvU, cvV)
    order = radiallySort(shape)
    cost = costFunction(mirror, screen, pupilPoints, virtualImage)
    for factor in [start / 3.**exp for exp in range(0, iterations)]:  #13)]:
        print factor
        for i in order:
            u, v = np.unravel_index(i, shape)
            if not border:
                if u == 0 or u == cvU - 1 or v == 0 or v == cvV - 1:
                    continue
            print '%s,%s' % (u, v)
            update = 0
            pos = np.zeros((3))
            while (np.sum(pos) < np.sum(cost)):
                print update
                if update > 0:
                    cost = pos
                mc.move(0,
                        factor,
                        0,
                        '%s.cv[%s][%s]' % (bMirror, u, v),
                        r=1,
                        os=1,
                        wd=1)
                pos = costFunction(bMirror, screen, pupilPoints, virtualImage)
                update += 1
                if update > 10:
                    break
            mc.move(0,
                    -factor,
                    0,
                    '%s.cv[%s][%s]' % (bMirror, u, v),
                    r=1,
                    os=1,
                    wd=1)
            if update < 2:
                update = 0
                neg = np.zeros((3))
                while (np.sum(neg) < np.sum(cost)):
                    print update
                    if update > 0:
                        cost = neg
                    mc.move(0,
                            -factor,
                            0,
                            '%s.cv[%s][%s]' % (bMirror, u, v),
                            r=1,
                            os=1,
                            wd=1)
                    neg = costFunction(bMirror, screen, pupilPoints,
                                       virtualImage)
                    update += 1
                    if update > 10:
                        break
                mc.move(0,
                        factor,
                        0,
                        '%s.cv[%s][%s]' % (bMirror, u, v),
                        r=1,
                        os=1,
                        wd=1)
    return bMirror
예제 #42
0
 def leg_createIKControls(self, joints):
     
     ikHandle = cmds.ikHandle(startJoint='IK_'+joints[0], endEffector='IK_'+joints[2], solver='ikRPsolver', name='ikHandle_leg')
     cmds.rename(ikHandle[1], 'effectorleg')
     print ikHandle
     
     """Create IK leg Control"""
     legIKCTL = cmds.circle(name='CTL_IKleg')
     print legIKCTL
     cmds.setAttr(legIKCTL[0] + ".overrideEnabled",1)
     cmds.setAttr(legIKCTL[0] + ".overrideColor",12)
     temp = cmds.pointConstraint("IK_" + joints[2], legIKCTL[0])
     cmds.delete(temp)
     
     scaleAttr = [ '.scaleX', '.scaleY', '.scaleZ' ]
     for x in scaleAttr:
         scaleAttr = cmds.setAttr(legIKCTL[0] + x, 1.5)
     cmds.setAttr(legIKCTL[0] + '.rx', 90)
     IKGrpName = (legIKCTL[0] + '_GRP') 
     adjIKCTL = cmds.group(empty = True, name=legIKCTL[0] + '_ADJ')
     temp = cmds.parentConstraint("IK_" + joints[2], adjIKCTL)
     cmds.delete(temp)
     cmds.parent(legIKCTL[0], adjIKCTL)
     cmds.makeIdentity(legIKCTL, apply=True)
     cmds.delete(constructionHistory = True)
     
     "Create CTL_IKLeg Group"
     groupIK  = cmds.group(empty = True, name = legIKCTL[0] + '_GRP')
     temp = cmds.pointConstraint(legIKCTL[0], groupIK)
     cmds.delete(temp)
     
     """Parent the ikHandle_Leg under adj node and under the CTL_IKLeg Group"""
     adjIKHandle = cmds.group(empty = True, name = ikHandle[0] + '_ADJ')
     temp = cmds.pointConstraint(legIKCTL[0], adjIKHandle)
     cmds.delete(temp)
     cmds.parent(ikHandle[0], adjIKHandle)
     cmds.parent(adjIKHandle, legIKCTL[0])
     cmds.parent(adjIKCTL, groupIK)
     
     
     """Lock Attributes for the legIKCTL"""
     lockAttr = [ '.scaleX', '.scaleY', '.scaleZ', '.visibility' ]
     for items in lockAttr:
         lock = cmds.setAttr(legIKCTL[0] + items, lock=True, keyable=False, channelBox=False)
     
     """Create IK Leg pole vector constraint"""
     locator1 = cmds.spaceLocator(name='CTL_' + joints[1] + 'Aim')
     print locator1
     temp = cmds.pointConstraint("IK_" + joints[1], locator1[0])
     cmds.delete(temp)
     cmds.move(20, z = True)
     cmds.setAttr(locator1[0] + ".overrideEnabled",1)
     cmds.setAttr(locator1[0] + ".overrideColor",13)
     elbowPoleVector = cmds.poleVectorConstraint(locator1[0], ikHandle[0], weight=1)
     elbAdjNode = cmds.group(empty = True, name = locator1[0] + '_ADJ')
     temp = cmds.pointConstraint(locator1, elbAdjNode)
     cmds.delete(temp)
     cmds.parent(locator1[0], elbAdjNode)
     cmds.parent(elbAdjNode, groupIK)
     
     """Lock Attributes for the CTL_elbowAim"""
     lockAttr = [ '.rotateX', '.rotateY', '.rotateZ', '.scaleX', '.scaleY', '.scaleZ', '.visibility' ]
     for items in lockAttr:
         lock = cmds.setAttr(locator1[0] + items, lock=True, keyable=False, channelBox=False)
     
     legCTLVariables = [ikHandle[0], legIKCTL[0], IKGrpName, adjIKCTL, groupIK, adjIKHandle]
     print legCTLVariables
     for index in range (len(legCTLVariables)):
         cmds.setAttr(legCTLVariables[index] + ".rotateOrder", 1)
예제 #43
0
def optimizeRankedMirrorShape(mirror,
                              screen,
                              pupilPoints,
                              remap,
                              rank,
                              iterations=5,
                              uRange=np.arange(.1, 1, .1),
                              vRange=np.arange(.1, 1, .1),
                              costFunction=calcSmoothness,
                              factor=1):
    best = mc.group(em=1, n='best')
    bMirror = mc.duplicate(mirror, n='best%s' % mirror)[0]
    mc.parent(bMirror, best)
    points = reflectImagePlane(mirror,
                               screen,
                               pupilPoints,
                               uRange=uRange,
                               vRange=vRange,
                               precision=3)
    cost = costFunction(points)
    shape = cost.shape
    skip = 0
    for n in range(iterations):
        print n
        # find the cv to optimize
        i = rank[skip]
        x, y = np.unravel_index(i, shape)
        u, v = remap[x, y]
        mc.move(0,
                factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        pPoints = reflectImagePlane(bMirror,
                                    screen,
                                    pupilPoints,
                                    uRange=uRange,
                                    vRange=vRange,
                                    precision=3)
        pos = costFunction(pPoints)
        if (np.sum(pos) < np.sum(cost)):  #  pos[x,y] < cost[x,y]
            points = pPoints
            cost = pos
            continue
        mc.move(0,
                -factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        mc.move(0,
                -factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        nPoints = reflectImagePlane(bMirror,
                                    screen,
                                    pupilPoints,
                                    uRange=uRange,
                                    vRange=vRange,
                                    precision=3)
        neg = costFunction(nPoints)
        if (np.sum(pos) < np.sum(cost)):  #  neg[x,y] < cost[x,y]
            points = nPoints
            cost = neg
            #factor=-factor
            continue
        mc.move(0,
                factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        #if random() < (skip/2. + 1.5):
        #    skip -= 1
        #else:
        #    skip += 1
        skip += 1
        print('No improvement, skipping to %s' % skip)
    return points
예제 #44
0
def create_CON_combine_CT () :
    selObjs_J_CT = cmds.ls(sl=1)
    if 'GRP' in selObjs_J_CT[0] :
        selobjs_PGRP_CT = cmds.listRelatives (selObjs_J_CT, p=1) # PGRP : Parent GRP
        selobjs_J_CT_tempGRP = cmds.group (n=selObjs_J_CT[0].replace ('GRP', 'tempGRP'))
        boundingBox_Info () # JGC : Join Group CON
        selobjs_JGC_CT = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) 
        CL.con_overrideColor_SET ()
        selobjs_JGC_CT_rename = cmds.rename (selObjs_J_CT[0].replace ('GRP', 'CON'))
        selobjs_JGC_CT_NUL = cmds.group (em=1, n=selobjs_JGC_CT_rename.replace ('CON', 'NUL'))
        cmds.parent (selobjs_JGC_CT_NUL, selobjs_JGC_CT_rename)
        cmds.move (0, 0, 0, selobjs_JGC_CT_NUL, ls=1)
        cmds.rotate (0, 0, 0, selobjs_JGC_CT_NUL)
        cmds.scale (1, 1, 1, selobjs_JGC_CT_NUL, ls=1)
        cmds.parent (selobjs_JGC_CT_NUL, w=1)
        cmds.parent (selobjs_JGC_CT_rename, selobjs_JGC_CT_NUL)
        cmds.scale (propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], selobjs_JGC_CT_NUL)
        cmds.move (propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], selobjs_JGC_CT_NUL)
        cmds.move (0, 0, 0, "%s.scalePivot" %selobjs_JGC_CT_NUL, "%s.rotatePivot" %selobjs_JGC_CT_NUL)
        cmds.move (0, 0, 0, "%s.scalePivot" %selobjs_JGC_CT_rename, "%s.rotatePivot" %selobjs_JGC_CT_rename)
        cmds.makeIdentity (selobjs_JGC_CT_NUL, a=1)
        cmds.parent (selobjs_JGC_CT_NUL, 'control_GRP')
        cmds.parent (selObjs_J_CT, selobjs_PGRP_CT)
        cmds.delete (selobjs_J_CT_tempGRP)
        for JGCC in selObjs_J_CT :
            cmds.parentConstraint (selobjs_JGC_CT_rename, JGCC, mo=1)
            cmds.scaleConstraint (selobjs_JGC_CT_rename, JGCC, mo=1)
        
    else :                
        combCON_selPLY_copy_CT = cmds.duplicate (selObjs_J_CT)
        combCON_tempPLY_CT = cmds.polyUnite(combCON_selPLY_copy_CT, mergeUVSets=1, constructionHistory=True, n=selObjs_J_CT[0].replace('PLY', 'RE'))
        cmds.delete (combCON_tempPLY_CT, ch=1) # like a historyDelete and delete emptyGroup, Also Node Check
        # CON
        combCON_CT = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) 
        combCON_rename_CT = cmds.rename (selObjs_J_CT[0].replace('PLY', 'CON'))
        combCON_Shape_CT = cmds.listRelatives (combCON_rename_CT, shapes=1)
        CL.con_overrideColor_SET ()
        combCON_NUL_CT = cmds.group (em=True, n=selObjs_J_CT[0].replace('PLY', 'NUL'))
        cmds.parent (combCON_rename_CT, combCON_NUL_CT)
        cmds.select (combCON_tempPLY_CT[0])
        boundingBox_Info ()
        cmds.scale (propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combCON_NUL_CT)
        cmds.move (propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combCON_NUL_CT)
        cmds.move (0, 0, 0, "%s.scalePivot" %combCON_NUL_CT, "%s.rotatePivot" %combCON_NUL_CT)
        cmds.move (0, 0, 0, "%s.scalePivot" %combCON_rename_CT, "%s.rotatePivot" %combCON_rename_CT)    
        cmds.makeIdentity (combCON_NUL_CT, apply=1)
        cmds.delete (combCON_tempPLY_CT[0])
        cmds.parent (combCON_NUL_CT, 'control_GRP')
        for d in selObjs_J_CT :
            cmds.parentConstraint (combCON_rename_CT, d, mo=1)
            cmds.scaleConstraint (combCON_rename_CT, d, mo=1)
            
    con_ChannelBox ()
    cmds.select (deselect=1)
예제 #45
0
def distribute(edgeLoop):

    edgeSel = cmds.ls(edgeLoop, fl=True)
    vertList = cmds.ls(cmds.polyListComponentConversion(edgeSel,
                                                        toVertex=True),
                       fl=True)

    tempCurveName = uniqueNameGenerator()

    if cmds.radioCollection('interpolation_radioCollection',
                            select=True,
                            q=True) == 'curved_radioButton':
        cmds.polyToCurve(n=tempCurveName, form=2, degree=3, ch=False)

    else:
        cmds.polyToCurve(n=tempCurveName, form=2, degree=1, ch=False)
        CVtoDelete = []
        for i in range(1, len(vertList) - 1):
            CVtoDelete.append(tempCurveName + '.cv[' + str(i) + ']')
        cmds.delete(CVtoDelete)

    cmds.rebuildCurve(tempCurveName,
                      ch=False,
                      replaceOriginal=True,
                      rt=0,
                      end=1,
                      kr=0,
                      kep=1,
                      kt=0,
                      s=len(vertList) - 1,
                      d=3,
                      tol=0.01)

    accuracy = 4

    firstEPPos = [
        round(elem, accuracy)
        for elem in cmds.pointPosition(tempCurveName + '.ep[0]')
    ]
    vertListOrdered = []
    for edge in edgeSel:

        edgeVert = cmds.ls(cmds.polyListComponentConversion(edge,
                                                            toVertex=True),
                           fl=True)

        for v in edgeVert:

            vPos = [round(elem, accuracy) for elem in cmds.pointPosition(v)]

            if vPos == firstEPPos:
                vertListOrdered.append(v)

    while len(vertListOrdered) < len(vertList):
        for edge in edgeSel:
            vertEdge = cmds.ls(cmds.polyListComponentConversion(edge,
                                                                toVertex=True),
                               fl=True)

            counter = []

            for v in vertEdge:
                if v not in vertListOrdered:
                    counter.append(v)
                else:
                    pass

            if len(counter) == 1:
                vertListOrdered.append(counter[0])
            else:
                pass

    for v in vertListOrdered:
        epPos = cmds.pointPosition(tempCurveName + '.ep[' +
                                   str(vertListOrdered.index(v)) + ']')
        cmds.move(epPos[0], epPos[1], epPos[2], v, absolute=True)

    cmds.delete(tempCurveName)
예제 #46
0
def optimizeMirrorForImage(mirror,
                           screen,
                           pupilPoints,
                           virtualImage,
                           remap,
                           iterations=5,
                           costFunction=normalCost,
                           factor=-1):
    best = mc.group(em=1, n='best')
    bMirror = mc.duplicate(mirror, n='best%s' % mirror)[0]
    mc.parent(bMirror, best)
    cost = costFunction(mirror, screen, pupilPoints, virtualImage)
    shape = cost.shape
    skip = -1
    count = 0
    for n in range(iterations):
        print n
        # find the cv to optimize
        i = np.argsort(cost)[skip]
        #x,y = np.unravel_index(i,shape)
        u, v = remap[i]
        mc.move(0,
                factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        pos = costFunction(bMirror, screen, pupilPoints, virtualImage)
        if (np.sum(pos) < np.sum(cost)):  #  pos[x,y] < cost[x,y]
            cost = pos
            count = 0
            continue
        mc.move(0,
                -factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        mc.move(0,
                -factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        neg = costFunction(bMirror, screen, pupilPoints, virtualImage)
        if (np.sum(pos) < np.sum(cost)):  #  neg[x,y] < cost[x,y]
            cost = neg
            print "neg"
            #factor=-factor
            count = 0
            continue
        mc.move(0,
                factor,
                0,
                '%s.cv[%s][%s]' % (bMirror, u, v),
                r=1,
                os=1,
                wd=1)
        #if random() < (skip/2. + 1.5):
        #    skip -= 1
        #else:
        #    skip += 1
        skip -= 1
        print('No improvement, skipping to %s' % skip)
        count += 1
        if count > 10:
            factor /= 10.
            print('New factor: %s' % factor)
            count = 0
            skip = -1
    return bMirror
예제 #47
0
    def testAnimNurbsCurveGrpRW(self):

        # create Nurbs Curve group
        knotVec = [0, 0, 0, 1, 2, 2, 2]
        curve1CV = [(0, 0, 0), (3, 5, 0), (5, 6, 0), (9, 9, 0), (12, 10, 0)]
        curve2CV = [(0, 0, 3), (3, 5, 3), (5, 6, 3), (9, 9, 3), (12, 10, 3)]
        curve3CV = [(0, 0, 6), (3, 5, 6), (5, 6, 6), (9, 9, 6), (12, 10, 6)]

        MayaCmds.curve(d=3, p=curve1CV, k=knotVec, name='curve1')
        MayaCmds.curve(d=3, p=curve2CV, k=knotVec, name='curve2')
        MayaCmds.curve(d=3, p=curve3CV, k=knotVec, name='curve3')

        MayaCmds.group('curve1', 'curve2', 'curve3', name='group')
        MayaCmds.addAttr('group', longName='riCurves', at='bool', dv=True)

        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:4]',
                        'curve2.cv[0:4]',
                        'curve3.cv[0:4]',
                        replace=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:4]')
        MayaCmds.rotate(0.0, '90deg', 0.0, relative=True)
        MayaCmds.select('curve2.cv[0:4]')
        MayaCmds.move(0.0, 0.5, 0.0, relative=True)
        MayaCmds.select('curve3.cv[0:4]')
        MayaCmds.scale(1.0, 0.5, 1.0, relative=True)
        MayaCmds.select('curve1.cv[0:4]',
                        'curve2.cv[0:4]',
                        'curve3.cv[0:4]',
                        replace=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName('testAnimNCGrp.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp01_14.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp15_24.abc'))

        MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' %
                           ('group', self.__files[-2]))
        MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' %
                           ('group', self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        # reading test
        MayaCmds.AbcImport(self.__files[-3], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(12, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(24, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
예제 #48
0
def bdCreateGroup(objects, grpName, pivot, rot=False):
    grp = cmds.group(objects, n=grpName)
    footJntPos = cmds.xform(pivot, q=True, ws=True, t=True)
    cmds.move(footJntPos[0], footJntPos[1], footJntPos[2], grp + '.rp',
              grp + '.sp')
    return grp
예제 #49
0
 def modelTete(self):
     cmds.polyCube(name="tete")
     cmds.move(10, y=True)
     cmds.polySmooth('tete.f[0:5]', dv=1)
예제 #50
0
def create_curve(control, transform=None):
    """Create a curve.

    Args:
        control: A data dictionary generated from the dump function.
        transform: A transform node to add curveShape to.

    Returns: 
        Curve name.
    """
    curve = control['name']
    curveShape = control['shape']

    periodic = control['form'] == 2
    degree = control['degree']
    points = control['cvs']

    if periodic and not cmds.objExists(curveShape):
        points = points + points[:degree]

    if cmds.objExists(curveShape):
        i = 0
        while i < len(points):
            cmds.move(points[i][0],
                      points[i][1],
                      points[i][2],
                      '%s.cv[%s]' % (curveShape, i),
                      os=True)
            i = i + 1
    else:
        if cmds.objExists(curve):
            curve = cmds.curve(degree=degree,
                               p=points,
                               n="TEMP" + control['name'],
                               per=periodic,
                               k=control['knots'])
        else:
            curve = cmds.curve(degree=degree,
                               p=points,
                               n=control['name'],
                               per=periodic,
                               k=control['knots'])
        curveShape = cmds.rename(
            cmds.listRelatives(curve, shapes=True)[0], curveShape)

        if 'parent' in control:
            if cmds.objExists(control['parent']):
                if control['parent'] != cmds.listRelatives(curveShape,
                                                           parent=True)[0]:
                    try:
                        cmds.parent(curveShape,
                                    control['parent'],
                                    relative=True,
                                    shape=True)
                        cmds.delete(curve)
                    except:
                        pass
    # parenting
    if (transform and (transform is not cmds.listRelatives(
            curveShape, p=True, type='transform')[0])):
        try:
            cmds.parent(curveShape, transform, s=1, r=1)
            cmds.delete(curve)
        except:
            pass

    if cmds.objExists(curve):
        cmds.delete(curve, constructionHistory=True)

        cmds.setAttr('{0}.overrideEnabled'.format(curve),
                     control['overrideEnabled'])
        cmds.setAttr('{0}.overrideColor'.format(curve),
                     control['overrideColor'])
        try:
            cmds.setAttr('{0}.overrideRGBColors'.format(curve),
                         control['overrideRGBColors'])
            cmds.setAttr('{0}.overrideColorRGB'.format(curve),
                         *control['overrideColorRGB'])
        except:
            pass

    if cmds.objExists(curveShape):
        cmds.setAttr('{0}.overrideEnabled'.format(curveShape),
                     control['overrideEnabled'])
        cmds.setAttr('{0}.overrideColor'.format(curveShape),
                     control['overrideColor'])
        try:
            cmds.setAttr('{0}.overrideRGBColors'.format(curveShape),
                         control['overrideRGBColors'])
            cmds.setAttr('{0}.overrideColorRGB'.format(curveShape),
                         *control['overrideColorRGB'])
        except:
            pass

    return curve
예제 #51
0
 def modelRightArm(self):
     cmds.polyCube(name="rightArm", w=2, h=0.25)
     cmds.scale(0.3, z=True)
     cmds.move(-1.3, 9, 0)
     cmds.polySmooth('rightArm.f[0:5]', dv=1)
예제 #52
0
def cube_at_point(pos):
    """Spawns a cube with the origin at a specified point"""
    o, n = cmds.polyCube()
    cmds.select(o)
    cmds.move(*pos, a=True, ws=True)
예제 #53
0
 def modelCorp(self):
     cmds.polyCube(name="corp", w=1, h=3)
     cmds.move(8, y=True)
     cmds.polySmooth('corp.f[0:5]', dv=1)
예제 #54
0
 def modelRightLeg(self):
     cmds.polyCube(name="rightLeg", w=0.3, h=3.5)
     cmds.scale(0.3, z=True)
     cmds.move(0.3, 6, 0)
     cmds.polySmooth('rightLeg.f[0:5]', dv=1)
예제 #55
0
파일: scripts.py 프로젝트: yupei0318/MayaPy
# cylinder with a squash:
#
cmds.cylinder( ax=(0, 1, 0), r=1, hr=10, d=3, s=8, nsp=20, ch=1 )
cmds.select( 'nurbsCylinder1', r=True )
cmds.deformer( type="squash" )

# To query the membership of the deformer
#
cmds.deformer( 'squash1',q=True, g=True )

# To add additional geometries from your deformer, type:
#
cmds.select( 'nurbsCylinder1', r=True )
cmds.duplicate()
# Result: nurbsCylinder2 #
cmds.move( -2.749017, 0, 0, r=True )
cmds.deformer( 'squash1', e=True, g='nurbsCylinder2' )

# To remove a geometry from your deformer, type:
#
cmds.deformer( 'squash1', e=True, rm=True, g='nurbsCylinder2' )


########################


#for maya
import maya.cmds as cmds
cmds.playbackOptions( minTime='0', maxTime='71' ) # set playback range

size=0.2
예제 #56
0
 def modelLeftArm(self):
     cmds.polyCube(name="leftArm", w=2, h=0.25)
     cmds.scale(0.3, z=True)
     cmds.move(1.3, 9, 0)
     cmds.polySmooth('leftArm.f[0:5]', dv=1)
예제 #57
0
import maya.cmds as cmds

myHeight = 6
myCube = cmds.polyCube(w=2, h=myHeight, d=2, n='block#')
cmds.move(0, myHeight / 2.0, 0, myCube, r=True)
cmds.rotate(50, 50, 50, myCube, r=True)

sel = cmds.ls(sl=True)
x, y, z = cmds.xform(sel, q=True, ws=True, ro=True)
print x, y, z
x = -1.0 * x
#y = -1.0*y
#z = -1.0*z
print x, y, z
#cmds.xform(sel, r=True, ro=[x, y, z])
cmds.xform(sel, ws=True, ro=[x, y, z])
예제 #58
0
             sao='yup')
mc.curve(n=curveName, p=[(0, 0, 0), (5 - 1, 0, 0)], d=1)
mc.ikHandle(sj='advanced_1_JNT',
            ee='advanced_' + str(5) + '_JNT',
            c='advancedCurve1',
            p=2,
            w=.5,
            ccv=False,
            scv=False,
            sol='ikSplineSolver',
            tws="Linear",
            roc=True,
            pcv=False)
mc.rename('ikHandle1', 'TwistIKhandle')
start = mc.spaceLocator(n='Start')
mc.move(0, 1, 0)
end = mc.spaceLocator(n='End')
mc.move(5 - 1, 1, 0)

mc.select('TwistIKhandle')
mc.setAttr("TwistIKhandle.dTwistControlEnable", 1)
mc.setAttr("TwistIKhandle.dWorldUpType", 2)
mc.connectAttr('Start.xformMatrix', 'TwistIKhandle.dWorldUpMatrix')
mc.connectAttr('End.xformMatrix', 'TwistIKhandle.dWorldUpMatrixEnd')

mc.select(clear=True)
mc.joint(n='joint1Con', p=(0, 0, 0))
mc.joint(n='joint2Con', p=(5 - 1, 0, 0))

#create cluster
degree = mc.getAttr('advancedCurve1.degree')
예제 #59
0
def create(geo, prefix=''):
    '''
	'''
    # Check prefix
    if not prefix: prefix = geo

    # Create Deformer
    sMod = mc.softMod(geo, n=prefix + '_softMod')
    sModHandle = sMod[1]
    sMod = sMod[0]
    sModBase = mc.duplicate(sModHandle, po=True, n=prefix + '_softModBase')[0]

    # Get Handle pivot
    piv = mc.xform(sModHandle, q=True, ws=True, rp=True)

    # Initiate Control Builder
    ctrlBuilder = glTools.tools.controlBuilder.ControlBuilder()

    # Create Base control
    base_grp = mc.createNode('transform', n=prefix + '_softModBase_grp')
    base_ctrl = mc.createNode('transform',
                              n=prefix + '_softModBase_ctrl',
                              p=base_grp)
    base_ctrlShape = ctrlBuilder.controlShape(base_ctrl, 'box', scale=2)

    # Create Offset control
    offset_grp = mc.createNode('transform',
                               n=prefix + '_softModOffset_grp',
                               p=base_ctrl)
    offset_ctrl = mc.createNode('transform',
                                n=prefix + '_softModOffset_ctrl',
                                p=offset_grp)
    offset_ctrlShape = ctrlBuilder.controlShape(offset_ctrl,
                                                'sphere',
                                                scale=0.25)

    # Create Falloff control
    falloff_grp = mc.createNode('transform',
                                n=prefix + '_softModFalloff_grp',
                                p=base_ctrl)
    falloff_ctrl = mc.createNode('transform',
                                 n=prefix + '_softModFalloff_ctrl',
                                 p=falloff_grp)
    falloff_ctrlShape = ctrlBuilder.controlShape(falloff_ctrl,
                                                 'circle',
                                                 scale=1)
    falloff_loc = mc.spaceLocator(n=prefix + '_softModFalloff_loc')[0]
    mc.parent(falloff_loc, falloff_ctrl)
    mc.addAttr(falloff_ctrl, ln='radius', min=0.001, dv=1, k=True)
    mc.setAttr(falloff_loc + '.v', 0)

    # Move hierarchy into place
    mc.move(piv[0], piv[1], piv[2], base_grp, a=True)

    # Connect to deformer
    mc.connectAttr(falloff_loc + '.worldPosition[0]',
                   sMod + '.falloffCenter',
                   f=True)
    mc.connectAttr(falloff_ctrl + '.radius', sMod + '.falloffRadius', f=True)
    mc.connectAttr(sModBase + '.worldInverseMatrix[0]',
                   sMod + '.bindPreMatrix',
                   f=True)

    # Parent and constrain softMod elements
    mc.parentConstraint(offset_ctrl, sModHandle, mo=True)
    mc.scaleConstraint(offset_ctrl, sModHandle, mo=True)
    mc.parentConstraint(base_ctrl, sModBase, mo=True)
    mc.scaleConstraint(base_ctrl, sModBase, mo=True)
    mc.parent(sModHandle, sModBase)
    mc.parent(sModBase, base_grp)

    # Return result
    return sMod
예제 #60
0
    def createLeg(self, *args):
        """
		  Create the rig
		"""
        prefix = mc.textFieldGrp(self.prefixFld, query=True, text=True)
        fkRootJnt = mc.textFieldButtonGrp(self.jointFld, query=True, text=True)
        stretchy = mc.radioButtonGrp(self.stretchyFld, query=True, sl=True)
        kneeNum = mc.radioButtonGrp(self.kneesFld, query=True, sl=True)
        aim = mc.radioButtonGrp(self.aimFld, query=True, sl=True)
        foot_cnt = mc.textFieldGrp(self.ikCntFld, query=True, text=True)
        normal = mc.radioButtonGrp(self.nrFld, query=True, sl=True)
        radius = mc.floatFieldGrp(self.rFld, query=True, value1=True)
        build = mc.radioButtonGrp(self.buildFld, query=True, sl=True)

        if aim == 1:
            aim = 'X'
        if aim == 2:
            aim = 'Y'
        if aim == 3:
            aim = 'Z'

        if normal == 1:
            normal = (1, 0, 0)
        if normal == 2:
            normal = (0, 1, 0)
        if normal == 3:
            normal = (0, 0, 1)

        if build == 1:
            build = 'positive'
        if build == 2:
            build = 'negative'

        #
        #--- Creating duplicate joint chains
        #
        # First, we duplicate and store the original joint chain
        # for building the IK leg later on down the line.
        #
        ikChain = []
        temp = mc.duplicate(fkRootJnt, rc=True)
        for each in temp:
            name = '%sik_%s' % (prefix, each)
            mc.rename(each, name)
            ikChain.append(name)

        #
        # Now, the bind leg joint chain
        #
        bindChain = []
        temp = mc.duplicate(fkRootJnt, rc=True)
        for each in temp:
            name = '%sbind_%s' % (prefix, each)
            mc.rename(each, name)
            bindChain.append(name)

        #
        # Now, the FK leg joint chain
        #
        fkChain = []
        mc.select(fkRootJnt, hi=True)
        temp = mc.ls(sl=True, fl=True)
        for each in temp:
            name = '%sfk_%s' % (prefix, each)
            mc.rename(each, name)
            fkChain.append(name)

        #
        # Creating two separate chains for: no flip-knee and pole vector
        #
        noFlipChain = []
        temp = mc.duplicate(ikChain[0], rc=True)
        mc.select(temp[0], hi=True)
        temp = mc.ls(sl=True, fl=True)
        for each in temp:  #Search and replace: _ik_ with _noFlip_
            if 'effector' in each:
                mc.delete(each)
                continue
            newName = each.replace('_ik_', '_noFlip_')
            mc.rename(each, newName)
            noFlipChain.append(newName)

        #
        # PV chain
        #
        pvChain = []
        temp = mc.duplicate(ikChain[0], rc=True)
        mc.select(temp[0], hi=True)
        temp = mc.ls(sl=True, fl=True)
        for each in temp:  #Search and replace: _ik_ with _pv_
            if 'effector' in each:
                mc.delete(each)
                continue
            newName = each.replace('_ik_', '_pv_')
            mc.rename(each, newName)
            pvChain.append(newName)

        #
        #--- IK Control
        #
        #Hiding atts
        mc.setAttr(foot_cnt + '.visibility', channelBox=False)
        mc.setAttr(foot_cnt + '.scaleX', channelBox=False)
        mc.setAttr(foot_cnt + '.scaleY', channelBox=False)
        mc.setAttr(foot_cnt + '.scaleZ', channelBox=False)

        #Knee controls
        mc.addAttr(foot_cnt, ln='knee_controls', at='float', k=True)
        mc.setAttr(foot_cnt + '.knee_controls', lock=True)
        mc.addAttr(foot_cnt,
                   ln='Type',
                   at='enum',
                   enumName='Pv:NoFlip',
                   k=True)
        mc.setAttr(foot_cnt + '.Type', 1)

        #
        # Create state node for this leg rig and add attribute to it.
        #
        self.stateNode = mc.createNode('transform',
                                       n=('%s_stateNode' % prefix))
        mc.addAttr(self.stateNode,
                   ln='FK_IK',
                   min=0,
                   max=1,
                   at='float',
                   k=True)

        #Hide all unneeded atts
        mc.setAttr(self.stateNode + '.translateX',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.translateY',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.translateZ',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.rotateX',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.rotateY',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.rotateZ',
                   keyable=False,
                   channelBox=False)
        mc.setAttr(self.stateNode + '.scaleX', keyable=False, channelBox=False)
        mc.setAttr(self.stateNode + '.scaleY', keyable=False, channelBox=False)
        mc.setAttr(self.stateNode + '.scaleZ', keyable=False, channelBox=False)
        mc.setAttr(self.stateNode + '.visibility',
                   keyable=False,
                   channelBox=False)

        #
        #--- Connect IK/FK to Bind via 'blendColors' nodes
        #

        #
        # leg_top blendColors node creation/connections
        # Connecting rotates, translates not needed

        #leg_top blendColors creation/linking
        temp = mc.createNode('blendColors')
        legTop_node1 = '%s_topLegRotate' % prefix
        mc.rename(temp, legTop_node1)

        #legTop_node1 attributes to connect
        nodeColor1 = (legTop_node1 + ".color1")
        nodeColor2 = (legTop_node1 + ".color2")
        nodeOutput = (legTop_node1 + ".output")

        src1 = '%s.rotate' % fkChain[0]
        src2 = '%s.rotate' % ikChain[0]
        tgt = '%s.rotate' % bindChain[0]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #Connect each node to the self.stateNode so it's all driven by 1 att
        mc.connectAttr('%s.FK_IK' % self.stateNode,
                       '%s.blender' % legTop_node1)

        #
        # knee1 blendColors nodes creation/connections
        # Connecting rotates and translates

        #knee1 blendColors creation/linking
        temp = mc.createNode('blendColors')
        knee1_node1 = '%s_knee1Rotate' % prefix
        mc.rename(temp, knee1_node1)

        temp = mc.createNode('blendColors')
        knee1_node2 = '%s_knee1Translate' % prefix
        mc.rename(temp, knee1_node2)

        #legTop_node1 attributes to connect
        nodeColor1 = (knee1_node1 + ".color1")
        nodeColor2 = (knee1_node1 + ".color2")
        nodeOutput = (knee1_node1 + ".output")

        src1 = '%s.rotate' % fkChain[1]
        src2 = '%s.rotate' % ikChain[1]
        tgt = '%s.rotate' % bindChain[1]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #legTop_node2 attributes to connect
        nodeColor1 = (knee1_node2 + ".color1")
        nodeColor2 = (knee1_node2 + ".color2")
        nodeOutput = (knee1_node2 + ".output")

        src1 = '%s.translate' % fkChain[1]
        src2 = '%s.translate' % ikChain[1]
        tgt = '%s.translate' % bindChain[1]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #Connect each node to the self.stateNode so it's all driven by 1 att
        mc.connectAttr('%s.FK_IK' % self.stateNode, '%s.blender' % knee1_node1)
        mc.connectAttr('%s.FK_IK' % self.stateNode, '%s.blender' % knee1_node2)

        if kneeNum == 2:
            #
            # knee2 blendColors nodes creation/connections
            # Connecting rotates and translates

            #knee2 blendColors creation/linking
            temp = mc.createNode('blendColors')
            knee2_node1 = '%s_knee2Rotate' % prefix
            mc.rename(temp, knee2_node1)

            temp = mc.createNode('blendColors')
            knee2_node2 = '%s_knee2Translate' % prefix
            mc.rename(temp, knee2_node2)

            #legTop_node1 attributes to connect
            nodeColor1 = (knee2_node1 + ".color1")
            nodeColor2 = (knee2_node1 + ".color2")
            nodeOutput = (knee2_node1 + ".output")

            src1 = '%s.rotate' % fkChain[2]
            src2 = '%s.rotate' % ikChain[2]
            tgt = '%s.rotate' % bindChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #legTop_node2 attributes to connect
            nodeColor1 = (knee2_node2 + ".color1")
            nodeColor2 = (knee2_node2 + ".color2")
            nodeOutput = (knee2_node2 + ".output")

            src1 = '%s.translate' % fkChain[2]
            src2 = '%s.translate' % ikChain[2]
            tgt = '%s.translate' % bindChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the self.stateNode so it's all driven by 1 att
            mc.connectAttr('%s.FK_IK' % self.stateNode,
                           '%s.blender' % knee2_node1)
            mc.connectAttr('%s.FK_IK' % self.stateNode,
                           '%s.blender' % knee2_node2)

        #
        # ankle blendColors nodes creation/connections
        #

        #ankle blendColors creation/linking
        temp = mc.createNode('blendColors')
        ankle_node1 = '%s_ankleRotate' % prefix
        mc.rename(temp, ankle_node1)

        temp = mc.createNode('blendColors')
        ankle_node2 = '%s_ankleTranslate' % prefix
        mc.rename(temp, ankle_node2)

        #legTop_node1 attributes to connect
        nodeColor1 = (ankle_node1 + ".color1")
        nodeColor2 = (ankle_node1 + ".color2")
        nodeOutput = (ankle_node1 + ".output")

        if kneeNum == 1:  #One knee
            src1 = '%s.rotate' % fkChain[2]
            src2 = '%s.rotate' % ikChain[2]
            tgt = '%s.rotate' % bindChain[2]

        if kneeNum == 2:  #Two knees
            src1 = '%s.rotate' % fkChain[3]
            src2 = '%s.rotate' % ikChain[3]
            tgt = '%s.rotate' % bindChain[3]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #legTop_node2 attributes to connect
        nodeColor1 = (ankle_node2 + ".color1")
        nodeColor2 = (ankle_node2 + ".color2")
        nodeOutput = (ankle_node2 + ".output")

        if kneeNum == 1:  #One knee
            src1 = '%s.translate' % fkChain[2]
            src2 = '%s.translate' % ikChain[2]
            tgt = '%s.translate' % bindChain[2]

        if kneeNum == 2:  #Two knees
            src1 = '%s.translate' % fkChain[3]
            src2 = '%s.translate' % ikChain[3]
            tgt = '%s.translate' % bindChain[3]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #Connect each node to the self.stateNode so it's all driven by 1 att
        mc.connectAttr('%s.FK_IK' % self.stateNode, '%s.blender' % ankle_node1)
        mc.connectAttr('%s.FK_IK' % self.stateNode, '%s.blender' % ankle_node2)

        #
        #--- Create FK controllers
        #

        #leg_top
        temp = mc.circle(nr=normal, r=radius)
        mc.parent(temp, fkChain[0])  #Parent transform under fk joint
        mc.move(0, 0, 0, temp)  #Zero it so it snaps to FK position/orientation
        shape = mc.pickWalk(
            temp, direction='down')  #Get shape node for the parent command
        mc.parent(shape, fkChain[0], s=True,
                  r=True)  #Parent shape to joints transform
        mc.delete(temp)  #Delete empty transform

        if kneeNum == 1:
            #knee1
            temp = mc.circle(nr=normal, r=radius)
            mc.parent(temp, fkChain[1])  #Parent transform under fk joint
            mc.move(0, 0, 0,
                    temp)  #Zero it so it snaps to FK position/orientation
            shape = mc.pickWalk(
                temp, direction='down')  #Get shape node for the parent command
            mc.parent(shape, fkChain[1], s=True,
                      r=True)  #Parent shape to joints transform
            mc.delete(temp)  #Delete empty transform

            #ankle
            temp = mc.circle(nr=normal, r=radius)
            mc.parent(temp, fkChain[2])  #Parent transform under fk joint
            mc.move(0, 0, 0,
                    temp)  #Zero it so it snaps to FK position/orientation
            shape = mc.pickWalk(
                temp, direction='down')  #Get shape node for the parent command
            mc.parent(shape, fkChain[2], s=True,
                      r=True)  #Parent shape to joints transform
            mc.delete(temp)  #Delete empty transform

        if kneeNum == 2:
            #knee1
            temp = mc.circle(nr=normal, r=radius)
            mc.parent(temp, fkChain[1])  #Parent transform under fk joint
            mc.move(0, 0, 0,
                    temp)  #Zero it so it snaps to FK position/orientation
            shape = mc.pickWalk(
                temp, direction='down')  #Get shape node for the parent command
            mc.parent(shape, fkChain[1], s=True,
                      r=True)  #Parent shape to joints transform
            mc.delete(temp)  #Delete empty transform

            #knee2: Connect second knee rotations to first knee. this way, we only need one control.
            mc.connectAttr('%s.rotate' % fkChain[2],
                           '%s.rotate' % fkChain[1],
                           f=True)

            #ankle
            temp = mc.circle(nr=normal, r=radius)
            mc.parent(temp, fkChain[3])  #Parent transform under fk joint
            mc.move(0, 0, 0,
                    temp)  #Zero it so it snaps to FK position/orientation
            shape = mc.pickWalk(
                temp, direction='down')  #Get shape node for the parent command
            mc.parent(shape, fkChain[3], s=True,
                      r=True)  #Parent shape to joints transform
            mc.delete(temp)  #Delete empty transform

        #
        # FK Length attributes setup/ Done using the translates of the child to avoid skewing that
        # occurs with scaling in a non-uniform manner, i.e. (1,2,1) vs. (1,1,1)
        #
        mc.addAttr(fkChain[0], ln='length', min=0, dv=1, max=5, k=True)
        mc.addAttr(fkChain[1], ln='length', min=0, dv=1, max=5, k=True)

        #Get current translate%s % aim value to set the max SDK as 5 times the default length
        val1 = mc.getAttr('%s.translate%s' % (fkChain[1], aim))
        if kneeNum == 2:
            val2 = mc.getAttr('%s.translate%s' % (fkChain[3], aim))
        else:
            val2 = mc.getAttr('%s.translate%s' % (fkChain[2], aim))

        #SDK to connect them
        mc.setDrivenKeyframe(fkChain[1],
                             cd='%s.length' % fkChain[0],
                             at='translate%s' % aim,
                             dv=1)  #Set default with current value in .tx
        mc.setDrivenKeyframe(fkChain[1],
                             cd='%s.length' % fkChain[0],
                             at='translate%s' % aim,
                             dv=0,
                             v=0)  #Set min
        mc.setDrivenKeyframe(fkChain[1],
                             cd='%s.length' % fkChain[0],
                             at='translate%s' % aim,
                             dv=5,
                             v=(val1 * 5))  #Set max

        if kneeNum == 1:
            mc.setDrivenKeyframe(fkChain[2],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=1)  #Set default with current value in .tx
            mc.setDrivenKeyframe(fkChain[2],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=0,
                                 v=0)  #Set min
            mc.setDrivenKeyframe(fkChain[2],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=5,
                                 v=(val2 * 5))  #Set max

        if kneeNum == 2:
            mc.setDrivenKeyframe(fkChain[3],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=1)  #Set default with current value in .tx
            mc.setDrivenKeyframe(fkChain[3],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=0,
                                 v=0)  #Set min
            mc.setDrivenKeyframe(fkChain[3],
                                 cd='%s.length' % fkChain[1],
                                 at='translate%s' % aim,
                                 dv=5,
                                 v=(val2 * 5))  #Set max

        #
        # Lock and hide fk attributes as needed
        #
        mc.setAttr('%s.translateX' % fkChain[0], lock=True, keyable=False)
        mc.setAttr('%s.translateY' % fkChain[0], lock=True, keyable=False)
        mc.setAttr('%s.translateZ' % fkChain[0], lock=True, keyable=False)

        mc.setAttr('%s.translateX' % fkChain[1],
                   keyable=False)  #This channel connected to length
        mc.setAttr('%s.translateY' % fkChain[1], lock=True, keyable=False)
        mc.setAttr('%s.translateZ' % fkChain[1], lock=True, keyable=False)

        if kneeNum == 1:
            mc.setAttr('%s.translateX' % fkChain[2],
                       keyable=False)  #This channel connected to length
            mc.setAttr('%s.translateY' % fkChain[2], lock=True, keyable=False)
            mc.setAttr('%s.translateZ' % fkChain[2], lock=True, keyable=False)

        if kneeNum == 2:
            mc.setAttr('%s.translateX' % fkChain[2], lock=True, keyable=False)
            mc.setAttr('%s.translateY' % fkChain[2], lock=True, keyable=False)
            mc.setAttr('%s.translateZ' % fkChain[2], lock=True, keyable=False)

            mc.setAttr('%s.translateX' % fkChain[3],
                       keyable=False)  #This channel connected to length
            mc.setAttr('%s.translateY' % fkChain[3], lock=True, keyable=False)
            mc.setAttr('%s.translateZ' % fkChain[3], lock=True, keyable=False)

        #
        #--- IK leg time!
        #

        #
        #--- Combining noFlip & pv via blendColors
        #
        # ik leg_top blendColors node creation/connections

        #
        #leg_top blendColors creation/linking
        #
        temp = mc.createNode('blendColors')
        iklegTop_node1 = '%s_iktopLegRotate' % prefix
        mc.rename(temp, iklegTop_node1)

        #legTop_node1 attributes to connect
        nodeColor1 = (iklegTop_node1 + ".color1")
        nodeColor2 = (iklegTop_node1 + ".color2")
        nodeOutput = (iklegTop_node1 + ".output")

        src1 = '%s.rotate' % pvChain[0]
        src2 = '%s.rotate' % noFlipChain[0]
        tgt = '%s.rotate' % ikChain[0]

        mc.connectAttr(src2, nodeColor1)
        mc.connectAttr(src1, nodeColor2)
        mc.connectAttr(nodeOutput, tgt)

        #Connect each node to the self.foot_cnt so it's all switched by 1 att
        mc.connectAttr('%s.Type' % foot_cnt, '%s.blender' %
                       iklegTop_node1)  #Defaults to: noFlip / 0 / node input 2

        #
        # ik leg_knee1, knee2, and ankle blendColors node creation/connections
        #
        if kneeNum == 1:
            #
            #iklegKnee1_node1 rotate blendColors creation/linking
            #
            temp = mc.createNode('blendColors')
            iklegKnee1_node1 = '%s_ikknee1Rotate' % prefix
            mc.rename(temp, iklegKnee1_node1)

            #iklegKnee1_node1 attributes to connect
            nodeColor1 = (iklegKnee1_node1 + ".color1")
            nodeColor2 = (iklegKnee1_node1 + ".color2")
            nodeOutput = (iklegKnee1_node1 + ".output")

            src1 = '%s.rotate' % pvChain[1]
            src2 = '%s.rotate' % noFlipChain[1]
            tgt = '%s.rotate' % ikChain[1]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee1_node1)

            #iklegKnee1_node2 translate blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegKnee1_node2 = '%s_ikKnee1Translate' % prefix
            mc.rename(temp, iklegKnee1_node2)

            #iklegKnee1_node2 attributes to connect
            nodeColor1 = (iklegKnee1_node2 + ".color1")
            nodeColor2 = (iklegKnee1_node2 + ".color2")
            nodeOutput = (iklegKnee1_node2 + ".output")

            src1 = '%s.translate' % pvChain[1]
            src2 = '%s.translate' % noFlipChain[1]
            tgt = '%s.translate' % ikChain[1]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee1_node2)

            #
            #ankle blendColors creation/linking
            #
            temp = mc.createNode('blendColors')
            iklegAnkle_node = '%s_ikAnkleRotate' % prefix
            mc.rename(temp, iklegAnkle_node)

            #iklegAnkle_node attributes to connect
            nodeColor1 = (iklegAnkle_node + ".color1")
            nodeColor2 = (iklegAnkle_node + ".color2")
            nodeOutput = (iklegAnkle_node + ".output")

            src1 = '%s.rotate' % pvChain[2]
            src2 = '%s.rotate' % noFlipChain[2]
            tgt = '%s.rotate' % ikChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegAnkle_node)

            #iklegAnkle_node2 translate blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegAnkle_node2 = '%s_ikankleTranslate' % prefix
            mc.rename(temp, iklegAnkle_node2)

            #iklegAnkle_node2 attributes to connect
            nodeColor1 = (iklegAnkle_node2 + ".color1")
            nodeColor2 = (iklegAnkle_node2 + ".color2")
            nodeOutput = (iklegAnkle_node2 + ".output")

            src1 = '%s.translate' % pvChain[2]
            src2 = '%s.translate' % noFlipChain[2]
            tgt = '%s.translate' % ikChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegAnkle_node2)

        if kneeNum == 2:
            #iklegKnee1_node1 blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegKnee1_node1 = '%s_ikKnee1Rotate' % prefix
            mc.rename(temp, iklegKnee1_node1)

            #iklegKnee1_node1 attributes to connect
            nodeColor1 = (iklegKnee1_node1 + ".color1")
            nodeColor2 = (iklegKnee1_node1 + ".color2")
            nodeOutput = (iklegKnee1_node1 + ".output")

            src1 = '%s.rotate' % pvChain[1]
            src2 = '%s.rotate' % noFlipChain[1]
            tgt = '%s.rotate' % ikChain[1]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee1_node1)

            #iklegKnee1_node2 translate blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegKnee1_node2 = '%s_ikknee1Translate' % prefix
            mc.rename(temp, iklegKnee1_node2)

            #iklegKnee1_node2 attributes to connect
            nodeColor1 = (iklegKnee1_node2 + ".color1")
            nodeColor2 = (iklegKnee1_node2 + ".color2")
            nodeOutput = (iklegKnee1_node2 + ".output")

            src1 = '%s.translate' % pvChain[1]
            src2 = '%s.translate' % noFlipChain[1]
            tgt = '%s.translate' % ikChain[1]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee1_node2)

            #iklegKnee2_node1 blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegKnee2_node1 = '%s_ikKnee2Rotate' % prefix
            mc.rename(temp, iklegKnee2_node1)

            #iklegKnee2_node1 attributes to connect
            nodeColor1 = (iklegKnee2_node1 + ".color1")
            nodeColor2 = (iklegKnee2_node1 + ".color2")
            nodeOutput = (iklegKnee2_node1 + ".output")

            src1 = '%s.rotate' % pvChain[2]
            src2 = '%s.rotate' % noFlipChain[2]
            tgt = '%s.rotate' % ikChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee2_node1)

            #iklegKnee2_node2 translate blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegKnee2_node2 = '%s_ikKnee2Translate' % prefix
            mc.rename(temp, iklegKnee2_node2)

            #iklegKnee2_node2 attributes to connect
            nodeColor1 = (iklegKnee2_node2 + ".color1")
            nodeColor2 = (iklegKnee2_node2 + ".color2")
            nodeOutput = (iklegKnee2_node2 + ".output")

            src1 = '%s.translate' % pvChain[2]
            src2 = '%s.translate' % noFlipChain[2]
            tgt = '%s.translate' % ikChain[2]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegKnee2_node2)

            #iklegAnkle_node blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegAnkle_node = '%s_ikAnkleRotate' % prefix
            mc.rename(temp, iklegAnkle_node)

            #iklegAnkle_node attributes to connect
            nodeColor1 = (iklegAnkle_node + ".color1")
            nodeColor2 = (iklegAnkle_node + ".color2")
            nodeOutput = (iklegAnkle_node + ".output")

            src1 = '%s.rotate' % pvChain[3]
            src2 = '%s.rotate' % noFlipChain[3]
            tgt = '%s.rotate' % ikChain[3]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegAnkle_node)

            #iklegAnkle_node2 translate blendColors creation/linking
            temp = mc.createNode('blendColors')
            iklegAnkle_node2 = '%s_ikankleTranslate' % prefix
            mc.rename(temp, iklegAnkle_node2)

            #iklegAnkle_node2 attributes to connect
            nodeColor1 = (iklegAnkle_node2 + ".color1")
            nodeColor2 = (iklegAnkle_node2 + ".color2")
            nodeOutput = (iklegAnkle_node2 + ".output")

            src1 = '%s.translate' % pvChain[3]
            src2 = '%s.translate' % noFlipChain[3]
            tgt = '%s.translate' % ikChain[3]

            mc.connectAttr(src2, nodeColor1)
            mc.connectAttr(src1, nodeColor2)
            mc.connectAttr(nodeOutput, tgt)

            #Connect each node to the foot_cnt so it's all driven by 1 att
            mc.connectAttr('%s.Type' % foot_cnt,
                           '%s.blender' % iklegAnkle_node2)

        #Create RP IK on pv and no-flip chains
        if kneeNum == 1:
            noFlip_ikHandle = mc.ikHandle(sj=noFlipChain[0],
                                          ee=noFlipChain[2],
                                          solver='ikRPsolver',
                                          name=(prefix + '_noFlipIkHandle'))
            pv_ikHandle = mc.ikHandle(sj=pvChain[0],
                                      ee=pvChain[2],
                                      solver='ikRPsolver',
                                      name=(prefix + '_pvIkHandle'))
        if kneeNum == 2:
            noFlip_ikHandle = mc.ikHandle(sj=noFlipChain[0],
                                          ee=noFlipChain[3],
                                          solver='ikRPsolver',
                                          name=(prefix + '_noFlipIkHandle'))
            pv_ikHandle = mc.ikHandle(sj=pvChain[0],
                                      ee=pvChain[3],
                                      solver='ikRPsolver',
                                      name=(prefix + '_pvIkHandle'))

        #Parent IK Handles to foot_cnt
        mc.parent(pv_ikHandle[0], noFlip_ikHandle[0], foot_cnt)

        #
        #---Set up no-Flip IK
        #
        noFlipPV_loc = mc.spaceLocator(n=('%s_noflipPV_loc' % prefix))
        #Move it forward and out to the side
        mc.move(5, noFlipPV_loc, moveX=True)
        #Make pv constraint
        mc.poleVectorConstraint(noFlipPV_loc, noFlip_ikHandle[0])
        #Set twist to re-align with offset.
        mc.setAttr('%s.twist' % noFlip_ikHandle[0], 90)
        #Group noFlipPV and connect the groups rotate Y to the 'noFlipKnee' attr on the foot_cnt
        mc.select(clear=True)
        noFlipKneeGrp = mc.group(n=('%s_noFlipKneeGrp' % prefix), em=True)
        mc.parent(noFlipPV_loc, noFlipKneeGrp)
        mc.parent(noFlipKneeGrp, self.stateNode)
        mc.pointConstraint(foot_cnt, noFlipKneeGrp, mo=True)
        #Set up attribute to twist the knee

        mc.addAttr(foot_cnt, ln='noFlipKnee', at='float', k=True)
        mc.connectAttr('%s.noFlipKnee' % foot_cnt,
                       '%s.rotateY' % noFlipKneeGrp,
                       f=True)
        mc.setAttr(noFlipPV_loc[0] + '.visibility', 0)

        #
        #---Set up pv IK
        #
        pv_loc = mc.spaceLocator(n=('%s_pv_loc' % prefix))
        #Snap it to the knee and move it forward (Z) 5 units
        temp = mc.pointConstraint(ikChain[1], pv_loc, mo=False)
        mc.delete(temp)
        if build == 'positive':
            mc.move(-5, pv_loc, moveZ=True)
        if build == 'negative':
            mc.move(5, pv_loc, moveZ=True)
        mc.makeIdentity(pv_loc, apply=True)
        #Create the constraint
        mc.poleVectorConstraint(pv_loc, pv_ikHandle[0])
        #Zero pv
        pv_grp = mc.group(em=True, name='%s_pvBuffer' % prefix)
        if kneeNum == 1:
            temp = mc.pointConstraint(bindChain[2], pv_grp, mo=False)
        if kneeNum == 2:
            temp = mc.pointConstraint(bindChain[3], pv_grp, mo=False)
        mc.delete(temp)
        mc.parent(pv_grp, self.stateNode)
        mc.pointConstraint(foot_cnt, pv_grp, mo=True)
        mc.parent(pv_loc, pv_grp)
        #PV knee twist
        mc.addAttr(foot_cnt, ln='pv_knee', k=True, at='float')
        mc.connectAttr('%s.pv_knee' % foot_cnt, '%s.rotateY' % pv_grp, f=True)

        if stretchy == 1:
            #
            #--- Call ms_makeStretchy for noFlip ik setup
            #
            ##Create dictionary to pass with apply()
            arguments = {
                'ikHandle': noFlip_ikHandle[0],
                'solverType': 1,
                'aimAxis': aim,
                'clusters': 2,
                'stretchVal': 1,
                'prefix': ('nf' + prefix),
                'jointChain': noFlipChain,
                'kneeNum': self.kneeNum,
                'build': build
            }
            pargs = (
                1, 2
            )  #No purpose besides satisfying the required list argument for the apply call.

            #Call script, passing dictionary as an argument using apply()
            apply(mks.ms_makeStretchy, pargs, arguments)

            #
            #--- Call ms_makeStretchy for PV ik setup
            #
            ##Create dictionary to pass with apply()
            arguments = {
                'ikHandle': pv_ikHandle[0],
                'solverType': 1,
                'aimAxis': aim,
                'clusters': 2,
                'stretchVal': 1,
                'prefix': ('pv' + prefix),
                'jointChain': pvChain,
                'kneeNum': self.kneeNum,
                'build': build
            }
            pargs = (
                1, 2
            )  #No purpose besides satisfying the required list argument for the apply call.

            #Call script, passing dictionary as an argument using apply()
            apply(mks.ms_makeStretchy, pargs, arguments)

        #
        #---Create vis switching stuff
        #
        mc.connectAttr('%s.FK_IK' % self.stateNode,
                       '%s.visibility' % foot_cnt,
                       f=True)
        mc.addAttr(foot_cnt,
                   ln='pv_vis',
                   at='float',
                   k=True,
                   min=0,
                   max=1,
                   dv=0)
        mc.connectAttr('%s.pv_vis' % foot_cnt,
                       '%s.visibility' % pv_grp,
                       f=True)
        #Reverse node for the FK
        rvNode = '%s_rvNode' % prefix
        mc.createNode('reverse', n=rvNode)
        mc.connectAttr(self.stateNode + '.FK_IK', rvNode + '.inputX', f=True)
        mc.connectAttr(rvNode + '.outputX', fkChain[0] + '.visibility', f=True)

        #Now, we group and hide stuff
        jointsGrp = '%s_jointsGrp' % prefix
        mc.group(em=True, n=jointsGrp)
        mc.parent(bindChain[0], pvChain[0], noFlipChain[0], fkChain[0],
                  ikChain[0], jointsGrp)
        mc.setAttr(ikChain[0] + '.visibility', 0)
        mc.setAttr(pvChain[0] + '.visibility', 0)
        mc.setAttr(noFlipChain[0] + '.visibility', 0)

        #foot_cnt
        mc.setAttr(foot_cnt + '.visibility',
                   lock=True,
                   channelBox=False,
                   keyable=False)
        mc.setAttr(foot_cnt + '.scaleX',
                   lock=True,
                   channelBox=False,
                   keyable=False)
        mc.setAttr(foot_cnt + '.scaleY',
                   lock=True,
                   channelBox=False,
                   keyable=False)
        mc.setAttr(foot_cnt + '.scaleZ',
                   lock=True,
                   channelBox=False,
                   keyable=False)

        #fk controls
        for jnt in fkChain:
            mc.setAttr(jnt + '.scaleX',
                       lock=True,
                       channelBox=False,
                       keyable=False)
            mc.setAttr(jnt + '.scaleY',
                       lock=True,
                       channelBox=False,
                       keyable=False)
            mc.setAttr(jnt + '.scaleZ',
                       lock=True,
                       channelBox=False,
                       keyable=False)
            mc.setAttr(jnt + '.visibility',
                       lock=True,
                       channelBox=False,
                       keyable=False)
            mc.setAttr(jnt + '.radius',
                       lock=True,
                       channelBox=False,
                       keyable=False)