当前位置: 首页>>代码示例>>Python>>正文


Python cmds.xform函数代码示例

本文整理汇总了Python中maya.cmds.xform函数的典型用法代码示例。如果您正苦于以下问题:Python xform函数的具体用法?Python xform怎么用?Python xform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rotateToOrient

def rotateToOrient (joint):
    '''
    Transfer the euler rotate values to the joint orientation

    :param joint: Joint(s) you want to do the transfer for
    :type joint: *str* or *list*
    '''
    sArrJoints = [joint]#common.toList(joint)

    for j in sArrJoints:
        if cmds.objectType(j)=='joint':
            doit=True
            for attr in ['rx','ry','rz','jox','joy','joz','ro']:
                #don't exists, lock,or connected
                if cmds.getAttr(j+'.'+attr,l=True) or cmds.listConnections('%s.%s' % (j,attr), destination = False, plugs = True):
                    doit=False

            if doit:
                roo = cmds.xform(j,q=True,roo=True)#get rotation order
                cmds.xform(j, p=True, roo='xyz' )#set rotation order to default (joint orient only works with xyz rotation order)
                orientToRotate(j)#transfer current joint orient to rotate
                ori = cmds.getAttr(j+'.r')[0]
                cmds.setAttr(j+'.jo',ori[0],ori[1],ori[2])
                cmds.setAttr(j+'.r',0,0,0)
                cmds.xform(j, p=True, roo=roo )#set back the initial rotation order
            else:
                print ('//Warning: "' + j + '" is locked or connected, unable to set rotation')
开发者ID:jonntd,项目名称:japeto,代码行数:27,代码来源:joint.py

示例2: main

def main():
	mm.eval('selectCurveCV("all");')
	sel = mc.ls(sl=1, fl=1)
	grpname = (sel[0].split('.'))
	grpname = grpname[0]+"_grp"
	grp = mc.group(em=1, n=grpname)
	
	for i in sel:
		iname = i.replace('[', '')
		iname = iname.replace(']','')
		iname = iname.replace('.','_')
		
		locname = iname+"_loc"
		clusname = iname+"_clus"	
		
		mc.select(i, r=1)
		print "here"
		cluster = mc.cluster(n=clusname)
	
		location = mc.xform(cluster, q=1, ws=1, sp=1)
		print location
		locator = mc.spaceLocator(n=locname, p=(location[0], location[1], location[2]))
		mc.xform(locator, cp=1)
		set_vis = clusname+"Handle.visibility"
		mc.setAttr(set_vis, 0)
		mc.parent(cluster, locator)
		mc.parent(locator, grp)
		
		shape = mc.listRelatives(locator)
		mc.setAttr((shape[0]+".overrideEnabled"),1)
		mc.setAttr((shape[0]+".overrideColor"),17)
开发者ID:maitelels,项目名称:maya_scripts,代码行数:31,代码来源:tim_clusterCurveComponent.py

示例3: unparent

def unparent(shape):
	'''
	Unparent shape nodes from a source parent
	@param shape: Shape or transform to unparent shapes from
	@type shape: str
	'''
	# Checks
	if not mc.objExists(shape):
		raise Exception('Object "'+shape+'" does not exist!!')
	
	# Get shapes
	if mc.ls(shape,type='transform'):
		transform = shape
		shapes = mc.listRelatives(shape,s=True,pa=True)
	else:
		transform = mc.listRelatives(shape,p=True,pa=True)[0]
		shapes = [shape]
	
	# Create shape holder
	shapeHolder = transform+'Shapes'
	if not mc.objExists(shapeHolder): shapeHolder = mc.createNode('transform',n=shapeHolder)
	targetXform = mc.xform(transform,q=True,ws=True,m=True)
	mc.xform(shapeHolder,ws=True,m=targetXform)
	
	# Unparent shapes
	for shape in shapes:
		mc.parent(shape,shapeHolder,s=True,r=True)
	
	# Return Result
	return shapeHolder
开发者ID:auqeyjf,项目名称:glTools,代码行数:30,代码来源:shape.py

示例4: makeGem

def makeGem(size):
	#import gem
	if not cmds.objExists('gem'):
		cmds.file("gem.ma", i=True)

	cmds.select('gem')
	cmds.xform(s=(size,size,size))
开发者ID:ahamburger,项目名称:bedazzler,代码行数:7,代码来源:bedazzle.py

示例5: _mirror_setFollowValues

 def _mirror_setFollowValues(self):
     for target in self.__followTargets:
         if target.find( 'Collar' ) != -1:
             otherTarget = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
             mtxList = cmds.getAttr( otherTarget+'.wm' )
         elif target.find( 'Leg' ) != -1:
             poleVTarget = target.replace( 'Switch_CTL', 'PoleV_CTL' )
             poleVMtxList = cmds.getAttr( poleVTarget+'.wm' )
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' )+'.wm' )
         else:
             mtxList = cmds.getAttr( target.replace( 'Switch', 'IK' )+'.wm' )
         
         index = self.__followTargets.index( target )
         udAttrs = cmds.listAttr( target, ud=1 )
         
         for attr in udAttrs:
             if attr.find( 'Follow' ) != -1:
                 cmds.setAttr( target+'.'+attr, self.__followValues[index].pop(0) )
                 
         if target.find( 'Switch' ) != -1: target = target.replace( 'Switch', 'IK' )
         elif target.find( 'Collar' ) != -1:
             target = target.replace( 'Collar_L', 'Arm_L_PoleV' ).replace( 'Collar_R', 'Arm_R_PoleV' )
         
         cmds.xform( target, ws=1, matrix = mtxList )
         if cmds.nodeType( target ) == 'joint':
             rigbase.setRotate_keepJointOrient( mtxList, target )
             
         if target.find( 'Leg' ) != -1:
             cmds.xform( poleVTarget, ws=1, matrix = poleVMtxList )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:29,代码来源:allCtlsCmd.py

示例6: surfaceFromNodes

def surfaceFromNodes(nodes, name='jntsSrf', upAxis=0, doubleEndPoints=False):
    """
    Create a 2-degree nurbs surface from the position of a list of
    node (generally, the IK controls)
    @param nodes: controls that will dictate the CV positions
    @type nodes: list of strings
    @param name: the name of the surface
    @type name: str
    @param upAxis: the direction of the width of the surface
    @type upAxis: int representing x(0), y(1) or z(2)
    """
    inPos = [0,0,0]
    outPos = [0,0,0]
    inPos[upAxis] = -1
    outPos[upAxis] = 1

    crv1 = curveFromNodes(nodes, doubleEndPoints=doubleEndPoints)
    crv2 = curveFromNodes(nodes, doubleEndPoints=doubleEndPoints)

    MC.xform(crv1, t=outPos)
    MC.xform(crv2, t=inPos)

    srf = MC.loft(crv1, crv2, u=1, c=0, ch=0, ar=1, d=1, ss=1, rn=0, po=0, rsn=True)[0]
    srf = MC.rename(srf, name)
    MC.delete(crv1, crv2)

    return srf
开发者ID:jspatrick,项目名称:beings,代码行数:27,代码来源:spine2.py

示例7: _createAimLocator

    def _createAimLocator(self, position = [0,0,0], color = None):
        #create aim locator and move into position
        aimLocator = \
            cmds.spaceLocator(n = '%s_aim_%s' % (self.name(), common.LOCATOR))[0]

        aimZero = \
            cmds.createNode('transform',
                    n = aimLocator.replace(common.LOCATOR, common.ZERO))

        cmds.parent(aimLocator, aimZero)
        cmds.xform(aimZero, ws = True, t = position)
        
        #create display line between aim locator and start joint
        displayLine = control.displayLine(self.startJoint, aimLocator)
        cmds.parent(displayLine, self.guidesGrp)
        
        
        #set color on aim control
        common.setColor(aimLocator, color)
        
        #parent locator to zero group
        cmds.parent(aimZero, self.masterGuide)
        
        
        return aimLocator
        
        
开发者ID:jonntd,项目名称:japeto,代码行数:25,代码来源:chain.py

示例8: setRestCurve

def setRestCurve( startCurves ):
    
    restCurves = []
    index = 0
    for startCurve in startCurves:
        
        follicle = cmds.listConnections( startCurve+'.wm', type='follicle', shapes=1 )[0]
        
        if cmds.listConnections( follicle+'.restPosition', s=1, d=0 ): continue
        
        startShape = cmds.listConnections( follicle+'.startPosition', s=1, d=0, shapes=1 )[0]
        
        rebuildCurve= cmds.listConnections( startShape+'.create', type='rebuildCurve' )[0]
        
        crvShape = cmds.createNode( 'nurbsCurve' )
        cmds.connectAttr( rebuildCurve+'.outputCurve', crvShape+'.create' )
        cmds.connectAttr( crvShape+'.worldSpace', follicle+'.restPosition' )
        cmds.setAttr( crvShape+'.io', 1 )
        
        crv = cmds.listRelatives( crvShape, p=1 )[0]
        crv = cmds.rename( crv, 'restCurve_%03d' % index )
        
        startMtx = cmds.getAttr( crv+'.wm' )
        cmds.xform( crv, ws=1, matrix=  startMtx )
        
        restCurves.append( crv )
        index += 1
    
    cmds.group( restCurves, n='restCurveGrps' )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:29,代码来源:p2014_06_jinro.py

示例9: buildGuideSpline

	def buildGuideSpline(self):
		cPoints = []
		for marker in self.totalMarkerList:
			markerPos = cmds.xform(marker.getName(), t=True, q=True, ws=True)
			cPoints.append(markerPos)
		nameStart = nameBase(self.totalMarkerList[0].getName(), self.searchString, "loc", "cv")
		guideSplineName = nameStart + "ribbonGuideSpline"
		self.guideSpline = cmds.curve(editPoint = cPoints, degree=3, name=guideSplineName)       #Need to add Naming Convention here
		self.tempGuideParts.append(self.guideSpline)

		for i, marker in enumerate(self.totalMarkerList):
			locPos = cmds.xform(marker.getName(), t=True, q=True, ws=True)
			newPara = cmds.closestPointOnCurve(self.guideSpline, ip=locPos, paramU=True)
			newParaVal = cmds.getAttr(newPara + ".paramU")
			cmds.delete(newPara)
			# print "new ParaVal : ", newParaVal
			##Now Create a new Locator and add it to the precise parameter position
			nameStart = nameRebuild(marker.getName(), self.searchString, "loc", "loc",nameAddition = "tempRibbonGuide")
			newAlignedLoc = cmds.spaceLocator(name = nameStart) 
			# guideSplineName = nameStart + "ribbonGuideSpline"                                         #Need naming convention
			self.tempGuideParts.append(newAlignedLoc[0])
			mPath = cmds.pathAnimation(newAlignedLoc, follow=True, c=self.guideSpline)
			uAnimNode = cmds.listConnections(mPath + ".uValue", source=True) 
			cmds.delete(uAnimNode)
			cmds.setAttr(mPath + ".uValue", newParaVal)
			self.totalMarkerList[i].setAlignedMarker(newAlignedLoc[0])
			self.totalMarkerList[i].setUParameter(newParaVal)
开发者ID:Everzen,项目名称:3DFr_FilmRigs_scripts,代码行数:27,代码来源:3DFR_RibbonSplineSetup.py

示例10: apply

	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 )
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:27,代码来源:animClip.py

示例11: bakeManualRotateDelta

def bakeManualRotateDelta( src, ctrl, presetStr ):
	'''
	When you need to apply motion from a skeleton that is completely different from a skeleton driven
	by the rig you're working with (transferring motion from old assets to newer assets for example)
	you can manually align the control to the joint and then use this function to generate offset
	rotations and bake a post trace cmd.
	'''
	srcInvMat = Matrix( getAttr( '%s.worldInverseMatrix' % src ) )
	ctrlMat = Matrix( getAttr( '%s.worldMatrix' % ctrl ) )

	#generate the offset matrix as
	mat_o = ctrlMat * srcInvMat

	#now figure out the euler rotations for the offset
	ro = getAttr( '%s.ro' % ctrl )
	rotDelta = constants.MATRIX_ROTATION_ORDER_CONVERSIONS_TO[ ro ]( mat_o, True )

	#now get the positional delta
	posDelta = Vector( xform( src, q=True, ws=True, rp=True ) ) - Vector( xform( ctrl, q=True, ws=True, rp=True ) )
	posDelta *= -1
	ctrlParentInvMat = Matrix( getAttr( '%s.parentInverseMatrix' % ctrl ) )
	posDelta = posDelta * ctrlParentInvMat

	#construct a list to use for the format str
	formatArgs = tuple( rotDelta ) + tuple( posDelta )

	#build the post trace cmd str
	PostTraceNode( ctrl ).setCmd( presetStr % formatArgs )

	return rotDelta
开发者ID:zethwillie,项目名称:zbw_python_tools,代码行数:30,代码来源:animClip.py

示例12: mmInsertJoint

def mmInsertJoint( *args ):
    
    def normalize(vector_value):
        length = math.sqrt(vector_value[0]**2 + vector_value[1]**2 + vector_value[2]**2)
        x = vector_value[0]/length
        y = vector_value[1]/length
        z = vector_value[2]/length
        result = [x, y, z]
        return result
    
    num_joints =input(10)
    num_joints = num_joints+1
    joint_list = cmds.ls(sl=True)
    
    for r in joint_list:
    
        first_joint_trans = cmds.xform(r, q=True, ws=True, t=True)
        first_joint_ori = cmds.xform(r, q=True, ws=True, ro=True)
        end_joint = cmds.listRelatives(r, f=True, c=True)
        end_joint_rename=cmds.rename(end_joint[0], "end_to_delete______yeah")
        end_joint_trans = cmds.xform(end_joint_rename, q=True, ws=True, t=True)
        end_joint_ori = cmds.xform(end_joint_rename, q=True, ws=True, ro=True)
        
        between_vector = [-(first_joint_trans[0]-end_joint_trans[0]),-(first_joint_trans[1]-end_joint_trans[1]),-(first_joint_trans[2]-end_joint_trans[2])]
        vector_length = mel.eval(("mag(<<"+str(between_vector[0])+","+str(between_vector[1])+","+str(between_vector[2])+">>)"))
        vector_normalize = normalize(between_vector)
        
        for i in range(num_joints):
                vector_to_add = [(vector_normalize[0]*((vector_length/num_joints)*((num_joints-float(i))))),(vector_normalize[1]*((vector_length/num_joints)*((num_joints-float(i))))),(vector_normalize[2]*((vector_length/num_joints)*((num_joints-float(i)))))]
                inset_joint = cmds.insertJoint(r)
                cmds.joint(inset_joint, e=True, co=True, o=(0,0,0), p=((first_joint_trans[0]+vector_to_add[0]), (first_joint_trans[1]+vector_to_add[1]), (first_joint_trans[2]+vector_to_add[2])))
        cmds.delete(end_joint_rename)
开发者ID:jonntd,项目名称:mayadev-1,代码行数:32,代码来源:cmdModel.py

示例13: mmMirrorJoint

def mmMirrorJoint( *args ):
    
    sels= cmds.ls( sl=1 )
    
    for sel in sels:
        
        srcStr = ''
        trgStr = ''
        if sel.find( '_L_' ) != -1:
            other = sel.replace( '_L_', '_R_' )
            srcStr = '_L_'
            trgStr = '_R_'
        elif sel.find( '_R_' ) != -1:
            other = sel.replace( '_R_', '_L_' )
            srcStr = '_R_'
            trgStr = '_L_'
        else:
            continue
        
        if not cmds.objExists( other ):
            cmds.mirrorJoint( sel, mirrorYZ=1, mirrorBehavior=1, searchReplace=["_L_", "_R_"] )
        else:
            mtxTop = cmds.getAttr( sel+'.wm' )
            mtxTop[1] *= -1; mtxTop[ 2] *= -1
            mtxTop[5] *= -1; mtxTop[ 6] *= -1
            mtxTop[9] *= -1; mtxTop[10] *= -1
            mtxTop[12] *= -1
            cmds.xform( other, ws=1, matrix=mtxTop )
            
            children = cmds.listRelatives( sel, c=1, ad=1 )
            for child in children:
                mtx = cmds.getAttr( child+'.m' )
                mtx[12] *= -1; mtx[13] *= -1; mtx[14] *= -1
                otherChild = child.replace( srcStr, trgStr )
                cmds.xform( otherChild, matrix=mtx )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:35,代码来源:cmdModel.py

示例14: ui_on_BTN_create_clicked

    def ui_on_BTN_create_clicked(self, *args):
        cube = m.polyCube(ch=False)[0]

        xPosUI = self.ui_FLTFLDGRP_xPos.getValue()[0]
        xNegUI = self.ui_FLTFLDGRP_xNeg.getValue()[0]
        yPosUI = self.ui_FLTFLDGRP_yPos.getValue()[0]
        yNegUI = self.ui_FLTFLDGRP_yNeg.getValue()[0]
        zPosUI = self.ui_FLTFLDGRP_zPos.getValue()[0]
        zNegUI = self.ui_FLTFLDGRP_zNeg.getValue()[0]

        xPos = max(xPosUI, xNegUI)
        xNeg = min(xPosUI, xNegUI)
        yPos = max(yPosUI, yNegUI)
        yNeg = min(yPosUI, yNegUI)
        zPos = max(zPosUI, zNegUI)
        zNeg = min(zPosUI, zNegUI)

        m.move(xPos, cube + faceMapping['xPos'], worldSpaceDistance=True, x=True)
        m.move(xNeg, cube + faceMapping['xNeg'], worldSpaceDistance=True, x=True)
        m.move(yPos, cube + faceMapping['yPos'], worldSpaceDistance=True, y=True)
        m.move(yNeg, cube + faceMapping['yNeg'], worldSpaceDistance=True, y=True)
        m.move(zPos, cube + faceMapping['zPos'], worldSpaceDistance=True, z=True)
        m.move(zNeg, cube + faceMapping['zNeg'], worldSpaceDistance=True, z=True)

        m.xform(cube, cp=True)
        m.rename(cube, BBOX_NAME)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:26,代码来源:fx_create_aabb.py

示例15: _createParentMaster

def _createParentMaster(obj, translation=True, rotation=True):
    '''Crea i gruppi necessari per utilizzare il parent master.'''

    # creo il parent handle e lo snap group dell'oggetto (aventi stesso pivot)
    # un file referenziato genera eccezione
    if cmds.referenceQuery(obj, inr=True) and (not ALLOW_REFERENCE_ROOT or cmds.listRelatives(obj, p=True)):
        sys.stdout.write('Read-only hierarchy detected\n')
        msg = 'Are you working with referenced files?\n\nZVPM can\'t group "%s" because it\'s in a read-only hierarchy.\n\n\nDo the following:\n\n- Open the referenced file.\n- Select this object, right-click on "Attach objects" button and "Create parent groups".\n- Save the file.' % obj
        cmds.confirmDialog(title='Referenced file - ZV Parent Master', message=msg)
        return False

    piv = cmds.xform(obj, q=True, rp=True, ws=True)
    cmds.group(obj, n=_getSnapGroup(obj))
    cmds.xform(_getSnapGroup(obj), piv=piv, ws=True)
    ph = cmds.group(_getSnapGroup(obj), n=_getParentHandle(obj))
    cmds.xform(_getParentHandle(obj), piv=piv, ws=True)

    # locca gli attributi non diponibili e quelli non richiesti
    ts = set(['tx', 'ty', 'tz'])
    rs = set(['rx', 'ry', 'rz'])

    availAttrs = set(cmds.listAttr(obj, k=True, u=True, sn=True) or [])
    attrsToLock = (ts | rs) - availAttrs
    if not translation:
        attrsToLock |= ts
    if not rotation:
        attrsToLock |= rs

    for attr in attrsToLock:
        cmds.setAttr('%s.%s' % (ph, attr), lock=True)

    return True
开发者ID:jasperges,项目名称:ZvParentMaster,代码行数:32,代码来源:ZvParentMaster.py


注:本文中的maya.cmds.xform函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。