• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python all.ls函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: applyVertexColorAttributeToSelection

    def applyVertexColorAttributeToSelection(self=None):

        sel = pm.ls(selection=True)

        shapesToAdd = []

        for obj in sel:
            try:
                shape = obj.getShape()
                shapesToAdd.append( shape )
            except:
                pass

        print( shapesToAdd )
        print( sel )

        selWithShapes = sel + shapesToAdd
        print(selWithShapes)

        shapes = pm.ls(selWithShapes, shapes=True )

        print( shapes )

        for obj in shapes:
            try:
                obj.mmmmExportVertexColorsForMr.get()
                try:
                    obj.mmmmExportVertexColorsForMr.set(True)
                except:
                    pass
            except:
                obj.addAttr( 'mmmmExportVertexColorsForMr', attributeType=bool, defaultValue=True )
开发者ID:joetainment,项目名称:mmmmtools,代码行数:32,代码来源:RendererVertexColorTools.py


示例2: volumeSelect

    def volumeSelect(cls, faces=False ):
      sel = pm.ls(sl=1)
    
      if len(sel) < 2:
          print( "You must have at least two objects selected" )
          return []
    
      checkInsideObj = sel.pop()
      #checkInsideObj = sel[1]
      
      allIn = []
           
      for container in sel:

            
          allVtx = pm.ls(str(checkInsideObj)+'.vtx[*]',fl=1)

          start = pm.timerX()
        
          for eachVtx in allVtx:
              location = pm.pointPosition(eachVtx,w=1)
              test = cls.pyRayIntersect(container,location,(0,1,0))
        
              if(test):
                  allIn.append(eachVtx)
                  
      elapsedTime = pm.timerX(startTime = start)
      print "time :",elapsedTime
      pm.select(allIn,replace=1)
      if faces==True:
          pm.mel.eval( 'ConvertSelectionToContainedFaces;' )
      return pm.ls(selection=True)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:32,代码来源:SelectorVolumeSelect.py


示例3: snapVertsToGrid

 def snapVertsToGrid(cls, log=False):
     originalSelection = pm.ls( selection=True, flatten=True )
     pm.mel.eval('ConvertSelectionToVertices;')
     selVerts = pm.ls( selection=True, flatten=True )
     #objectSelection = pm.ls(selection=True, shapes=True )
     
     #selObjs = originalSelection[:]  ## copy the list
     #selVerts = pm.polyListComponentConversion(
     #    fromFace=True, fromVertex=True, fromEdge=True,
     #    fromVertexFace=True,
     #    toVertex=True )
     #    
     #selVerts = 
         
         
         
     spacing = cls.getSpacing()
     
     for v in selVerts:
         if isinstance( v, pm.MeshVertex ):
             pW = v.getPosition(space='world')
             p = pW.homogenize()  ## Turn it into simply coords
             #print( type(p.x)  )                
             def onGrid(n, s):
                 return (  spacing * float(   round( n/float(s) )  )   )
             p.x = onGrid( p.x, spacing )
             p.y = onGrid( p.y, spacing )
             p.z = onGrid( p.z, spacing )
             #print( p.x, p.y, p.z )                               
             v.setPosition( p.homogenize(), space='world' )
             #print p.x,p.y,p.z
             #print( help(p)  )
             #break
     pm.select( originalSelection )
开发者ID:joetainment,项目名称:mmmmtools,代码行数:34,代码来源:old-ModelerGridManager.py


示例4: print

         try:
             self.node.addAttr( self.attrName, dt='string' )
             print( 'An attribute named "' + self.attrName + '" was added to ' + self.node.name()  )                
         except:
             print( "Couldn't add attribute. Continuing anyway...")            
         
 def getScriptFromSelection(self):
     try:
         sel = pm.ls(selection=True)
         attr = None
         foundObj = None
         for obj in sel:
             try:
                 attr = getattr( obj, self.attrName ) 
                     ## this will fail if the attribute doesn't
                     ## exist, and the next line won't run
                 foundObj = obj
             except:
                 continue
         if foundObj is None:
             try:
                 foundObj= pm.ls(selection=True)[0]
             except:
                 print( "An object must be selected in order to get the script." )
                 raise
         else:
             self.node = foundObj
             n = foundObj.name()
             self.updateScriptNames()
             pre = self.scriptPrefix
             if n.startswith( pre ) and len(n) > len( pre ):
                 n = n[ len(self.scriptPrefix) : ]
                 self.scriptNameTextField.setText( n )
             else:
                 self.scriptPrefixTextField.setText('')
开发者ID:joetainment,项目名称:mmmmtools,代码行数:35,代码来源:ScripterEditor.py


示例5: applyUvToWorldRatioToSelection

    def applyUvToWorldRatioToSelection(self, targetRatio=None):
        oSel = pm.ls(sl=True)

        pm.mel.eval("ConvertSelectionToFaces;")

        sel = pm.ls(sl=True)

        if targetRatio == None:
            targetRatio = input()
        currentRatio = self.calcUvToWorldAreaRatio()
        amountToScaleBeforeSqrt = targetRatio / currentRatio
        amountToScale = math.sqrt(amountToScaleBeforeSqrt)

        ## Calc a bounding box in uv space, and it's center, for a scale pivot
        bb = pm.polyEvaluate(sel, boundingBoxComponent2d=True)
        bbUMin = bb[0][0]
        bbUMax = bb[0][1]
        bbVMin = bb[1][0]
        bbVMax = bb[1][1]
        bbUCenter = (bbUMax + bbUMin) * 0.5
        bbVCenter = (bbVMax + bbVMin) * 0.5

        pm.polyEditUV(sel, pu=bbUCenter, pv=bbVCenter, su=amountToScale, sv=amountToScale)

        pm.select(oSel)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:25,代码来源:Texturer.py


示例6: projectSelection

    def projectSelection(self):

        hiliteOrig = pm.ls(hilite=True)

        selOrig = pm.ls(selection=True)
        selPre = pm.polyListComponentConversion(selOrig, tv=True)

        try:
            pm.select(self.referenceXformNode, replace=True)
            pm.select(selPre, add=True)
            selForTransfer = pm.ls(selection=True)
            pm.transferAttributes(
                transferPositions=1, transferNormals=0, transferUVs=0, transferColors=0, sampleSpace=0, searchMethod=0
            )
            objsToAddToSelection = []
            for o in selForTransfer:
                # s = str( type(o) )
                # print "y" + s + "y"
                if str(type(o)) == "<class 'pymel.core.general.MeshVertex'>":
                    n = o.name().split(".")[0]
                    objsToAddToSelection.append(n)
            for obj in objsToAddToSelection:
                pm.select(obj, add=True)
            pm.delete(ch=True)  ##was #pm.mel.eval( "DeleteHistory;" )
            print(selForTransfer)
            pm.select(selOrig, replace=True)
            pm.hilite(hiliteOrig)
        except:
            pm.select(selOrig)
            pm.hilite(hiliteOrig)

            print(
                "Please ensure that you have a valid reference mesh selected, and that you have verticies or objects select to project."
            )
开发者ID:joetainment,项目名称:mmmmtools,代码行数:34,代码来源:ModelerRetoper.py


示例7: arsenal_proxyShaderAutoConnect

def arsenal_proxyShaderAutoConnect(ignoreNamespace = False):
    if ignoreNamespace:
        print '[Arsenal ToolBox] Namespace ignored'
    else:
        print '[Arsenal ToolBox] Namespace not ignored'
    proxyMaterialNodes = pm.ls(type='VRayMeshMaterial')
    allMaterials = pm.ls(materials=True)
    materialClean = list(set(allMaterials) - set(proxyMaterialNodes))
    if len(proxyMaterialNodes) == 0:
        OpenMaya.MGlobal.displayWarning('No VRayMeshMaterial in the scene !')
    for proxyMaterialNode in proxyMaterialNodes:
        numberOfSlot = proxyMaterialNode.shaderNames.get(size=True)
        for i in range(numberOfSlot):
            nameSlot = pm.getAttr(proxyMaterialNode + '.shaderNames[' + str(i) + ']')
            if pm.connectionInfo(proxyMaterialNode + '.shaders[' + str(i) + ']', isDestination=True):
                connected = pm.connectionInfo(proxyMaterialNode + '.shaders[' + str(i) + ']', sourceFromDestination=True)
                pm.disconnectAttr(connected, proxyMaterialNode + '.shaders[' + str(i) + ']')
                print '[Arsenal ToolBox] Disconnect ' + proxyMaterialNode + '.shaders[' + str(i) + ']'
            for myMat in materialClean:
                okConnect = False
                if ignoreNamespace:
                    if myMat.split(':')[-1] == nameSlot.split(':')[-1]:
                        okConnect = True
                elif myMat == nameSlot:
                    okConnect = True
                if okConnect:
                    pm.connectAttr(myMat + '.outColor', proxyMaterialNode + '.shaders[' + str(i) + ']', f=True)
                    print '[Arsenal ToolBox] ' + proxyMaterialNode + '.shaders[' + str(i) + '] connected.'
开发者ID:davidpower,项目名称:MS_Research,代码行数:28,代码来源:arsenalToolBox.py


示例8: applyMultiplier

 def applyMultiplier(self, selection=False, multiplier = 1.0 ):
     originalSelection = pm.ls(selection=True)
     pm.select( hierarchy=True )
     lights = pm.ls(selection=selection, lights=True)
     for light in lights:
         try:
             v = light.intensity.get() * multiplier
             light.intensity.set( v )
         except:
             print( "Coundn't set intensity on light: " + light.name()  )
     pm.select(originalSelection)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:11,代码来源:RendererLightsMultiplier.py


示例9: __get_object_list

def __get_object_list( selected_only ) :
	objects = []
	if( not selected_only ) :
		objects = pm.ls( assemblies=True, visible=True )
	else :
		objects = pm.ls( sl=True )
		for obj in objects :
			if(  obj.getShape() ) :
				pm.error( 'Please group your meshes when using selective export' )
	remove_list = [ 'top', 'front', 'side', 'perp' ]
	objects[:] = [ obj for obj in objects if obj.name() not in remove_list ]
	return objects
开发者ID:kotchin,项目名称:mayaSettings,代码行数:12,代码来源:export.py


示例10: setCreaseValueOnSelection

 def setCreaseValueOnSelection( v ):
     objs = pm.ls(selection=True, flatten=True)
     for obj in objs:
         try:
             creaseValue = pm.polyCrease( obj, value = v )
         except:
             pass  ## we don't care if this fails, no big deal
开发者ID:joetainment,项目名称:mmmmtools,代码行数:7,代码来源:Utils-backup-when-flatten-was-true-for-creases.py


示例11: getVerticesInOrder

    def getVerticesInOrder(self):
        """ Get vertices in continous order """

        sel = pm.ls(sl=True, fl=True)
        left = list(sel)

        finished = [sel[0]]
        left.remove(sel[0])

        while True:
            currentVertex = finished[-1]
            distance = 999999.0
            closestVertex = None
            for v in left:
                a = v.getPosition(space='world')
                b = currentVertex.getPosition(space='world')
                length = (a - b).length()
                if length < distance:
                    distance = length
                    closestVertex = v
            finished.append(closestVertex)
            left.remove(closestVertex)
            if left == []:
                break

        return finished
开发者ID:jonntd,项目名称:miMayaPlugins,代码行数:26,代码来源:circulateVertices.py


示例12: export_models

def export_models(
	res_path,
	model_rel_path,
	selected_only
	) :
	
	print 'Exporting models'

	res_path = os.path.abspath( res_path )
	model_rel_path = os.path.normpath( model_rel_path )

	sel = pm.ls( sl=True )

	try : os.makedirs( os.path.join( res_path, model_rel_path ) )
	except : pass
	
	objects = __get_object_list( selected_only )
	errors=[]
	for obj in objects :
		clean_obj = __create_clean_object( obj )
		errors.extend( __recursive_export_ffm( 
			clean_obj,			
			res_path,			
			model_rel_path			
		) )
		# pm.delete( clean_obj )

	pm.select( sel )

	if( len(errors) ) :
		for error in errors : print error

	print 'Exporting models finished'
	return True
开发者ID:kotchin,项目名称:mayaSettings,代码行数:34,代码来源:export.py


示例13: unfold3dMultipleObjects

 def unfold3dMultipleObjects(self):
     origSel = pm.ls(selection=True)
     for obj in origSel:
         pm.select(obj)
         pm.mel.eval("ConvertSelectionToUVs;")
         pm.mel.eval("Unfold3D -unfold -iterations 1 -p 1 -borderintersection 1 -triangleflip 1;")
     pm.select(origSel)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:7,代码来源:Texturer.py


示例14: addAttributeGroup

 def addAttributeGroup( self, user_given_vray_attr_group ):
 
     ## Get selection
     sel = pm.ls(selection=True)
     ## Copy selection in case we modify the list
     objs = sel[:]
     
     for obj in objs:
         try:
             shp = obj
             try:
                 shp = obj.getShape()
             except:
                 shp = obj
             ##if hasattr( obj, "getShape" ):
             ##    shp = obj.getShape()
             pm.mel.eval(
                 'vray addAttributesFromGroup "'
                 + shp.name()
                 + '" "' + user_given_vray_attr_group + '" 1;'
             )
         except:
             print "not working"
     
     ##restore original selection
     pm.select(sel)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:26,代码来源:vray_attributes_manager.py


示例15: connectAttributes

    def connectAttributes(self, sourceAttrName, targetAttrName, multiplier=0.0):

        sourceAttrName = sourceAttrName
        targetAttrName = targetAttrName

        multValue = multiplier
        ##print( help( multValue )   )

        ## Get a list of all selected objects
        objs = pm.ls(selection=True)

        sourceObj = objs.pop(0)
        sourceAttr = getattr(sourceObj, sourceAttrName)

        doMult = False
        if multiplier != 0.0:
            doMult = True

        if doMult:
            m = pm.createNode("multiplyDivide")
            m.input2X.set(multValue)

        ## Loop through all the selected objects, except the first one
        for obj in objs:
            ## This stuff might fail, so put it in a try block
            try:
                targetAttr = getattr(obj, targetAttrName)
                if doMult:
                    sourceAttr >> m.input1X
                    m.outputX >> targetAttr
                else:
                    sourceAttr >> targetAttr

            except:
                print("An error occured on object: " + obj.name() + "\n" + traceback.format_exc() + "\n")
开发者ID:joetainment,项目名称:mmmmtools,代码行数:35,代码来源:RiggerAttributeConnector.py


示例16: setCreaseValueOnSelection

def setCreaseValueOnSelection( v ):
    objs = pm.ls(selection=True) ## removed flatten=True because it makes it crazy slow
    for obj in objs:
        try:
            creaseValue = pm.polyCrease( obj, value = v )
        except:
            pass  ## we don't care if this fails, no big deal
开发者ID:joetainment,项目名称:mmmmtools,代码行数:7,代码来源:Mesh.py


示例17: fixXforms

    def fixXforms(self):
        ## Get the first selected object
        objs = pm.ls(selection=True)
        
        for obj in objs:
            pm.parent( obj, world=True )

        for obj in objs:        
            ## Unparent the object
            
            ## Move the pivot to the origin
            pm.move ( obj.scalePivot , [0,0,0] )
            pm.move ( obj.rotatePivot , [0,0,0] )
            ## Freeze transforms
            pm.makeIdentity(
                obj,
                apply = True,
                normal = 0,
                preserveNormals = True
            )
            ## Note that the options for makeIdentity were simply
            ## from the Mel script history or freeze transform
            
            ## Delete the history
            pm.delete (ch = True )        
开发者ID:joetainment,项目名称:mmmmtools,代码行数:25,代码来源:QuickMenus.py


示例18: setAttributeOnSelected

def setAttributeOnSelected( attrName, v ):
    objs = pm.ls(selection=True, flatten=True)
    for obj in objs:
        try:
            obj.setAttr( attrName, v )
        except:
            print("Could not affect " + obj )
开发者ID:joetainment,项目名称:mmmmtools,代码行数:7,代码来源:Mesh.py


示例19: putObjOnSnappableSpacing

def putObjOnSnappableSpacing(obj, snappableSpacing):
    oSel = pm.ls(selection=True)
    destinationObj = obj
    usedObj = obj

    pm.select(destinationObj)
    t = pm.xform(query=True, rotatePivot=True, worldSpace=True)
    vt = pm.core.datatypes.Vector(t[0], t[1], t[2])
    vt = onSnappableSpacingVec(vt, snappableSpacing)

    pm.select(usedObj)
    pm.move(vt, worldSpace=True, absolute=True, worldSpaceDistance=True)

    ## We compensate by getting the *object being moved*'s
    ## pivot
    t2 = pm.xform(query=True, rotatePivot=True, worldSpace=True)
    vt2 = pm.core.datatypes.Vector(t2[0], t2[1], t2[2])

    ## vExtra is the additional amount compensated
    vExtra = vt - vt2

    vDest = vt + vExtra

    vFinal = vDest

    pm.move(vFinal, worldSpace=True, absolute=True, worldSpaceDistance=True)

    pm.select(oSel)
开发者ID:joetainment,项目名称:mmmmtools,代码行数:28,代码来源:Grid.py


示例20: print

             obj.addAttr( "mmmmExportFile", dataType="string")
         except:
             print( "Attribute not added, it might already exist on the selected object.")
             print traceback.format_exc()
 def addAttributeForExportPath(self):
     for obj in pm.ls(selection=True, transforms=True):
         try:
开发者ID:joetainment,项目名称:mmmmtools,代码行数:7,代码来源:GamerFbxExporter.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python all.select函数代码示例发布时间:2022-05-27
下一篇:
Python MeiElement.MeiElement类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap