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


Python core.ls函数代码示例

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


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

示例1: blend_search_and_create

def blend_search_and_create ( find_string, replace_string, blend_suffix = 'main_BS', double_namespace=False ):
	'''creates a blendshape between selected objects and targets based on find/replace strings and turns on
	:param find_string: string to find in the name of the transform.name()
	:type find_string: str or unicode
	:param replace_string: string to find in the name of the transform.name()
	:type find_string: str or unicode
	:param blend_suffix: suffix for blendshapes that are created
	:type double_namespace: str or unicode
	:param double_namespace: if we should search mpc style or not
	:type double_namespace: bool
	:rtype : list of pm.PyNode
	:usage :
		blend_search_and_create( 'INPUT', 'GEO', double_namespace=True )
	'''
	blends=[]
	for transform in pm.ls(sl=True):
		namespace = ''
		if double_namespace:
			namespace = '*:*:'
		target = pm.ls( '%s%s'%( namespace, transform.name().replace( find_string, replace_string ) ) )
		blend_name = transform.name().replace( find_string, blend_suffix )
		blend = pm.blendShape(transform, target, n=blend_name, frontOfChain=True)[0]
		blend_aliases = blend.listAliases()
		for blend_alias in blend_aliases:
			blend.attr(blend_alias[0]).set(1)
		blends.append( blend )
	return blends
开发者ID:AndresMWeber,项目名称:aw,代码行数:27,代码来源:lib_blends.py

示例2: setCamera

	def setCamera(self):
		pm.mel.eval('setNamedPanelLayout "Single Perspective View"; updateToolbox();')
		sceneReferences = pm.getReferences()
		print sceneReferences
		camera = ''
		for item in sceneReferences :
			if sceneReferences[item].isLoaded():
				if referenceCam.lower() in sceneReferences[item].path.lower():
					print 'cam loaded already'
					camera = pm.ls(item + ':*',type='camera')[0]
					break
		
		print referenceCam
		stageCam = pm.ls(referenceCam + '*',type='camera')[0]
		print stageCam
		
		if stageCam:
			camera = stageCam
		if camera == '':
			if os.path.isfile(referenceCam):
				pm.createReference(referenceCam,namespace="CAM")
				camera = pm.ls('CAM:*',type='camera')[0]
			else:
				print 'No cam file, creating a default one'
				cameraList = pm.camera(n='playblastCam')
				camera = cameraList[1]
				cameraList[0].setTranslation([0,10,60])
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:27,代码来源:animToolUI.py

示例3: check_if_leaf_mesh_nodes_have_no_transformation

def check_if_leaf_mesh_nodes_have_no_transformation():
    """checks if all the Mesh transforms have 0 transformation, but it is
    allowed to move the mesh nodes in space with a parent group node.
    """
    mesh_nodes_with_transform_children = []
    for node in pm.ls(dag=1, type='mesh'):
        parent = node.getParent()
        tra_under_shape = pm.ls(
            parent.listRelatives(),
            type='transform'
        )
        if len(tra_under_shape):
            mesh_nodes_with_transform_children.append(parent)

    if len(mesh_nodes_with_transform_children):
        pm.select(mesh_nodes_with_transform_children)
        raise PublishError(
            'The following meshes have other objects parented to them:'
            '\n\n%s'
            '\n\nPlease remove any object under them!' %
            '\n'.join(
                map(lambda x: x.name(),
                    mesh_nodes_with_transform_children[:MAX_NODE_DISPLAY])
            )
        )
开发者ID:theomission,项目名称:anima,代码行数:25,代码来源:publish.py

示例4: storeDeformerWeights

def storeDeformerWeights(selection=True, type='rig_vertSnap'):
	'''
	Usage:
		storeDeformerWeights(selection=False)
		storeDeformerWeights(selection=True, type=['rig_vertSnap'])
		storeDeformerWeights(selection=False, type=['rig_vertSnap', 'wire'])
	'''
	
	deformers = pm.ls(type=type)
	if selection:
		if len(pm.ls(sl=True))==0:
			pm.error('select something numbnuts!')
		deformers = pm.ls(sl=True)[0].listHistory(type='rig_vertSnap')
	vsFile = {}
	for deformer in deformers:
		vs = Deformer(deformer)
		vs.initializeWeights()
		if len(vs.weightsList) > 0:
			vsFile[deformer.name()] = vs.weightsList
	try:
		filename = os.path.join( pm.fileDialog2(cap='Select a folder to store the weights', fm=3, okc='Select')[0], 'deformerWeights.json' )
	except:
		pm.error('Why did you cancel? :(')
	with open(filename, 'wb') as fp:
		print 'Storing weights in file:\n\t%s'%(filename)
		print '\t\tDeformers Stored:\n\t\t\t%s'%('\n\t\t\t'.join([deformer.name() for deformer in deformers]))
		json.dump(vsFile, fp, indent=4)
开发者ID:creuter23,项目名称:tools,代码行数:27,代码来源:lib_deformer.py

示例5: ReverseShape

def ReverseShape(  objs=None, axis='x' ):
	
	scaleValue = ( -1, 1, 1 )
	if axis == 'y':
		scaleValue = ( 1, -1, 1 )
	elif axis == 'z':
		scaleValue = ( 1, 1, -1 )
	elif axis != 'x':
		pm.warning('Axis was not correct, used "x" axis instead.')
	
	if objs == None:
		objs = pm.ls( sl=True )
	else:
		objs = pm.ls( objs )
	
	for obj in objs:
		try:
			shape = obj.getShape()
			if shape.type() == 'mesh':
				pm.select( shape.vtx[:] )
				pm.scale( scaleValue )
				pm.select( objs )
			elif shape.type() == 'nurbsCurve':
				pm.select( shape.cv[:] )
				pm.scale( scaleValue )
				pm.select( objs )			
		except:
			pm.warning("Object doesn't have a shape. Skipped!")

		'''
开发者ID:satishgoda,项目名称:EHM_tools,代码行数:30,代码来源:reverseShape_backup.py

示例6: updateFileNamePrefix

    def updateFileNamePrefix(self, *args):
        if self.rendererTabUiDict.has_key("common"):
            uiDict = self.rendererTabUiDict["common"]
        prefix = uiDict["fileNamePrefixField"].getText()

        sceneName = ".".join(pm.sceneName().basename().split(".")[:-1])
        if len(prefix) == 0:
            prefix = sceneName
            uiDict["imgname"].setLabel("File Name: " + sceneName)

        settings = pm.api.MCommonRenderSettingsData()
        pm.api.MRenderUtil.getCommonRenderSettings(settings)

        cams = [cam for cam in pm.ls(type="camera") if cam.renderable.get()]
        if len(cams) < 1:
            log.error("No renderable camera. please make at least one camera renderable.")
            prefix = ""
            for c in pm.ls(type="camera"):
                if "perspShape" in c:
                    cams.append(c)
                    break
        prefix = prefix.replace("<Camera>", cams[0].name())

        prefix = prefix.replace("<Scene>", sceneName)

        ext = self.renderNode.imageFormat.getEnums().keys()[self.renderNode.imageFormat.get()].lower()
        numberFormat = ""
        paddedFrameString = "{0:0" + str(settings.framePadding) + "d}."
        if settings.isAnimated():
            numberFormat = paddedFrameString.format(int(pm.SCENE.defaultRenderGlobals.startFrame.get()))
        completeFileName = "{prefix}.{numbering}{ext}".format(prefix=prefix, numbering=numberFormat, ext=ext)
        uiDict["imgname"].setLabel("File Name: " + completeFileName)
        """
开发者ID:dictoon,项目名称:appleseed-maya,代码行数:33,代码来源:commonglobals.py

示例7: bdLocOnJnt

def bdLocOnJnt():
    try:
        rootJnt = pm.ls(sl=True)[0]
    except:
        pm.warning('Nothing selected')
        return
    try:
        crvPath  = pm.ls(sl=True)[1]
    except:
        pm.warning('No curve selected')
        return

    allJnt = rootJnt.listRelatives(f=True, ad=True,type='joint')
    allJnt = allJnt + [rootJnt]
    allJnt.reverse()

    locators = []
    for jnt in allJnt:
        print jnt
        loc = pm.spaceLocator(name = jnt.name().replace( '_jnt','_loc'))
        locGrp = pm.group(n = loc.name() + '_grp')

        tempCnstr = pm.pointConstraint(jnt,locGrp,mo=0);
        pm.delete(tempCnstr )
        locators.append(locGrp)

    bdMultiMotionPath(crvPath, locators)
    bdParentJntToLocs(allJnt)
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:28,代码来源:bdRigUtils.py

示例8: __init__

 def __init__(s, name):
     sel = pmc.ls(sl=True)
     pmc.select(clear=True)
     try:
         s.nodes = pmc.ls(name, r=True, type="objectSet") or [pmc.sets(n=name)]
     finally:
         pmc.select(sel, r=True)
开发者ID:internetimagery,项目名称:OutOfControlRig,代码行数:7,代码来源:collection.py

示例9: transferProxyTransforms

def transferProxyTransforms():
    nodes = pm.ls(sl=True)

    attrsDict = {}
    attrs = ('tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz')
    
    for n in nodes:
        d = {}
        for a in attrs:
            d[a] = n.attr(a).get()
        attrsDict[n.nodeName()] = d
        
    #--------
    
    # adapt changes
    attrsDict['spine_mid_2_loc'] = attrsDict['spine_mid_loc']
    attrsDict['spine_mid_1_loc'] = attrsDict['spine_low_loc']
    
    nodes = pm.ls(sl=True)
    
    for n in nodes:
        if n.nodeName() in attrsDict.keys():
            for a, val in attrsDict[n.nodeName()].items():
                try:
                    n.attr(a).set(val)
                except:
                    pass
        else:
            print n + ' not found'
开发者ID:sayehaye3d,项目名称:ls-rigging-tools,代码行数:29,代码来源:abAutoRigUtils.py

示例10: bdSwitchIKFK

 def bdSwitchIKFK(self):
     if 'arm' in self.limb:
         print self.side + ' arm IK -> FK switch'
         
         for loc in self.fkArmCons:
             shadowLoc = pm.ls(self.namespace + self.side +  loc + 'LOC')[0]
             tempLoc = pm.duplicate(shadowLoc)
             pm.parent(tempLoc,w=True)
             
             fkCon = pm.ls(self.namespace + self.side +  loc + 'CON',type='transform')[0]
             tempCnstr = pm.orientConstraint(tempLoc,fkCon)
             
             pm.delete([tempCnstr,tempLoc])
             
         
         self.armSwitchCon.attr('ikFkBlend').set(1)
         
     elif 'leg' in self.limb:
         print self.side + ' leg IK->FK switch ' 
         
         for loc in self.fkLegCons:
             shadowLoc = pm.ls(self.namespace + self.side +  loc + 'LOC')[0]
             tempLoc = pm.duplicate(shadowLoc)
             pm.parent(tempLoc,w=True)
             
             fkCon = pm.ls(self.namespace + self.side +  loc + 'CON',type='transform')[0]
             tempCnstr = pm.orientConstraint(tempLoc,fkCon)
             
             pm.delete([tempCnstr,tempLoc])
             
         
         self.legSwitchCon.attr('ikFkBlend').set(1)            
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:32,代码来源:bdFrogIKFK.py

示例11: bdSwitchFKIK

 def bdSwitchFKIK(self):
     if 'arm' in self.limb:
         print self.side + ' arm FK->IK switch ' 
         
         for loc in self.ikArmCons:
             shadowLoc = pm.ls(self.namespace + self.side +  loc + 'LOC')[0]
             tempLoc = pm.duplicate(shadowLoc)
             pm.parent(tempLoc,w=True)
             
             ikCon = pm.ls(self.namespace + self.side +  loc + 'CON',type='transform')[0]
             if ikCon.name().find('armIK') > 0:
                 tempCnstr = pm.parentConstraint(tempLoc,ikCon)
             else:
                 tempCnstr = pm.pointConstraint(tempLoc,ikCon)
             pm.delete([tempCnstr,tempLoc])
                    
         self.armSwitchCon.attr('ikFkBlend').set(0)
     
     elif 'leg' in self.limb:
         print self.side + ' leg FK->IK switch ' 
         
         for loc in self.ikLegCons:
             shadowLoc = pm.ls(self.namespace + self.side +  loc + 'LOC')[0]
             tempLoc = pm.duplicate(shadowLoc)
             pm.parent(tempLoc,w=True)
             
             ikCon = pm.ls(self.namespace + self.side +  loc + 'CON',type='transform')[0]
             if ikCon.name().find('legIK') > 0:
                 tempCnstr = pm.parentConstraint(tempLoc,ikCon)
             else:
                 tempCnstr = pm.pointConstraint(tempLoc,ikCon)
             pm.delete([tempCnstr,tempLoc])
                    
         self.legSwitchCon.attr('ikFkBlend').set(0)
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:34,代码来源:bdFrogIKFK.py

示例12: bdConnectArms

def bdConnectArms(namespace):
	print 'adasdasdasda'
	sides = {'Left':'L', 'Right':'R'}
	tsmArmChain = ['Arm_joint1','Arm_joint2','Arm_joint3','Arm_joint5','Arm_influence7_intermediate_constrain','Arm_joint6','Arm_joint7','Arm_joint8','Arm_joint7']
	capcomArmChain = ['Shoulder','ArmDir','Arm1','Arm2','Elbow','ARoll3','ARoll4','handRot','handXR'] 

	i=0

	for jnt in tsmArmChain:
		try:
			target = pm.ls(namespace + sides['Left'] + capcomArmChain[i])[0]
		except:
			print ' cant find', capcomArmChain[i]
			
		source = pm.ls(sides.keys()[1] + jnt )[0]
		i+=1

		pm.parentConstraint(source,target,mo=True)
		pm.scaleConstraint(source,target,mo=True)

	i=0

	for jnt in tsmArmChain:
		target = pm.ls(namespace + sides['Right'] + capcomArmChain[i])[0]
		source = pm.ls(sides.keys()[0] + jnt )[0]
		i+=1

		pm.parentConstraint(source,target,mo=True)        
		pm.scaleConstraint(source,target,mo=True)
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:29,代码来源:bdHookSFChar.py

示例13: bdRenameLipJoints

def bdRenameLipJoints(namespace):

	tsmCornerLipJoints = ['lip_corner_right_speak','lip_corner_left_speak']
	tsmLipJoints = ['upper_lip_right_speak','upper_lip_open_center_speak','upper_lip_center_speak','upper_lip_left_speak']

	capcomCornerLipJoints = ['Face_RMouthCorners','Face_LMouthCorners']
	capcomLipJoints = ['Face_RMouthTop2','Face_RMouthTop1','Face_LMouthTop1','Face_LMouthTop2']

	for jnt in capcomCornerLipJoints:
		toRename = pm.ls( namespace+ jnt)[0]
		try:
			toRename.rename(tsmCornerLipJoints[capcomCornerLipJoints.index(jnt)])
		except:
			print 'some shit happened'

	for jnt in capcomLipJoints:
		toRenameUpper = pm.ls(namespace + jnt,ap=True)[0]
		toRenameLower = pm.ls(namespace + jnt.replace('Top','Bottom'),ap=True)[0]
		try:
			toRenameUpper.rename(tsmLipJoints[capcomLipJoints.index(jnt)])    
		except:
			print 'some shit happened while renaming ', toRenameUpper.name()

		try:
			toRenameLower.rename(tsmLipJoints[capcomLipJoints.index(jnt)].replace('upper','lower'))    
		except:
			print 'some shit happened while renaming ', toRenameLower.name()   
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:27,代码来源:bdHookSFChar.py

示例14: populateList

def populateList():    
    # Get shader type
    shaderSel = pc.radioButtonGrp(uiWidgets['shaderType'], q=1, select=1)
    
    if shaderSel == 1:
        shaderType = 'lambert'
    elif shaderSel == 2:
        shaderType = 'blinn'
    elif shaderSel == 3:
        shaderType = 'phong'
        
    # Get shader prefix
    shaderPrefix = pc.textField(uiWidgets['shadersPrefix'], q=1, text=1)
    
    if len(shaderPrefix) == 0:
        listShaders = pc.ls(exactType=shaderType)
    else:
        listShaders = pc.ls(shaderPrefix+'*', exactType=shaderType)

    if len(listShaders) == 0:
        pc.confirmDialog(t="Error", message="No shaders fitting the given paramaters has been found.", icon='critical')
        exit(1)
    elif len(listShaders) > 0:
        pc.confirmDialog(t="Shaders found", message=str(len(listShaders))+" shader(s) found. Click confirm to continue.")
    else:
        exit("Unknown error.")
    
#    for info in infos.keys():
#        print "#######################"
#        print "### Shader: '%s'" % info
#        print " - Found %s shape(s)" % len(infos[info])
#        print "Shapes list: %s " % infos[info]
        
    return listShaders
开发者ID:ma55acre,项目名称:MayaDev,代码行数:34,代码来源:render_mayashdtoaistd.py

示例15: ExtraControlForJnt

def ExtraControlForJnt( jnts=None ) :

	if not jnts:
		jnts = pm.ls( sl=True )
	else:
		jnts = pm.ls( jnts )
	
	
	for jnt in jnts:
		
		# duplicate joint
		pm.select( clear=True )
		newJnt = pm.joint( p = [0,0,0], name= '%s_extra'%jnt.name() )
		pm.delete( pm.pointConstraint( jnt, newJnt ) )
		pm.delete( pm.orientConstraint( jnt, newJnt ) )
		pm.parent( newJnt, jnt )
		newJnt.jointOrient.set( jnt.jointOrient.get() )
		
		# create control curve for joint
		ctrl = CubeCrv( name = '%s_ctrl'%jnt.name() )
		pm.delete( pm.pointConstraint( jnt, ctrl ) )
		pm.delete( pm.orientConstraint( jnt, ctrl ) )
		zeroAndOfs = ZeroGrp( ctrl )
		ctrl.translate >> newJnt.translate
		ctrl.rotate >> newJnt.rotate
		ctrl.scale >> newJnt.scale
        
		# make controls to move with base joints
		pm.parentConstraint( jnt, zeroAndOfs[0] )
		pm.scaleConstraint( jnt, zeroAndOfs[0] )
开发者ID:satishgoda,项目名称:EHM_tools,代码行数:30,代码来源:extraControlForJnt.py


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