本文整理汇总了Python中pymel.core.ls函数的典型用法代码示例。如果您正苦于以下问题:Python ls函数的具体用法?Python ls怎么用?Python ls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ls函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: determineHanded
def determineHanded(self, thumb, wrist): #thumb, wrist
handed = ""
objectJoint = pc.ls(thumb, type="joint")[0]
objWorldMat = objectJoint.attr("worldMatrix").get()
objTransformationMat = dt.TransformationMatrix(objWorldMat)
objectTrans = objTransformationMat.getTranslation('world')
tarJoint = pc.ls(wrist, type="joint")[0]
tarWorldMat = tarJoint.attr("worldMatrix").get()
targetTransformationMat = dt.TransformationMatrix(tarWorldMat)
targetTrans = targetTransformationMat.getTranslation('world')
worldVector = dt.Vector(0,0,0)
targetVector = (objectTrans - targetTrans)
targetVector.normalize()
targetUp = tarWorldMat[1][:3]
targetUp.normalize()
# find dot product between target and object
dotProduct = dt.dot(targetUp, targetVector)
if dotProduct > 0:
handed = "R"
if dotProduct <= 0:
handed = "L"
return handed
开发者ID:RiggingDojo,项目名称:AnomaliaRigging,代码行数:32,代码来源:hand_rigger.py
示例17: addItems
def addItems(self, parent):
column = 0
self.renderLayers = self.getRenderLayers() # Get render layers
self.renderLayerDict = {} # Dictionary to store layer name and the assosiated AOVS
for layer in self.renderLayers:
if str(layer.name()) not in self.renderLayerDict:
self.renderLayerDict[str(layer.name())] = [] # Add elements to Dictionary as Key with empty list as value
# vrayRenderElements = pm.listConnections(layer, s=1, type='VRayRenderElement') # Find all the AOVS connected to each render layers and Append to the Dictionary self.renderLayerDict[Key] = Value
vrayRenderElements = pm.ls(type='VRayRenderElement')
for element in vrayRenderElements:
if element.name() not in self.renderLayerDict[str(layer.name())]:
self.renderLayerDict[str(layer.name())].append(str(element.name()))
# vrayRenderElementSets = pm.listConnections(layer, s=1, type='VRayRenderElementSet')
vrayRenderElementSets = pm.ls(type='VRayRenderElementSet')
for set in vrayRenderElementSets:
if set.name() not in self.renderLayerDict[str(layer.name())]:
self.renderLayerDict[str(layer.name())].append(str(set.name()))
panels = pm.getPanel( type='modelPanel' ) # Get all the Model panels and Set show to None
for panel in panels:
if '|' in panel:
panel = panel.split('|')[-1]
pm.modelEditor(panel, e=1, allObjects=0)
for key, values in self.renderLayerDict.iteritems(): # Update tree widget with top parent node as render layer name and childs as Aovs
pm.editRenderLayerGlobals(currentRenderLayer=key) # select current render layer and find the Aovs state (Enabled or Disabled)
layer_item = self.addParent(parent, column, key, 'data Layers')
for value in sorted(values):
self.addChild(layer_item, column, value, 'data Aovs')
开发者ID:vipul-rathod,项目名称:AppleTree,代码行数:28,代码来源:setAovs.py
示例18: bdAddSpreadMeta
def bdAddSpreadMeta(side,finger,attr):
fingerAnim = pm.ls(side + 'Fingers_CON',type='transform')[0]
if finger != 'Thumb':
startFingerJnt = pm.ls(side + finger + '_00_JNT')[0]
pm.setDrivenKeyframe(startFingerJnt, at='rotateY', cd = fingerAnim.name() + '.' + attr , dv= 0 , v = 0)
pm.setDrivenKeyframe(startFingerJnt, at='rotateY', cd = fingerAnim.name() + '.' + attr , dv= 10 , v = -10)
pm.setDrivenKeyframe(startFingerJnt, at='rotateY', cd = fingerAnim.name() + '.' + attr , dv= -10 , v = 10)
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:7,代码来源:bdRigFingersRD.py
示例19: bdMirrorCtrl
def bdMirrorCtrl():
selection = pm.ls(sl=True)
if selection:
try:
source,target = pm.ls(sl=True)
except:
pm.warning('Select source and target controller')
return
sourceShape = source.getShape()
if sourceShape.type() != 'nurbsCurve':
pm.error('Selected source is not nurbs curve')
return
targetCvsPos = [ (dt.Point(-x.x, x.y, x.z) ) for x in sourceShape.getCVs(space='world')]
targetShape = target.getShape()
if targetShape.type() != 'nurbsCurve':
pm.error('Selected target is not nurbs curve')
return
targetShape.setCVs(targetCvsPos,space='world')
targetShape.updateCurve()
else:
print 'Select source and target controller'
'''
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:29,代码来源:bdMirrorCtrl.py
示例20: RigFK
def RigFK( jnts=None, side='L', ctrlSize=1.0, stretch=True, color='r' ):
if not jnts:
jnts = pm.ls( sl=True )
else:
jnts = pm.ls( jnts )
# find color of the ctrls
color = 'y'
if side == 'L':
color = 'r'
elif side == 'R':
color = 'b'
shapes = []
for jnt in jnts:
if not jnt or not jnt.type()=='joint':
pm.warning('ehm_tools...RigFK: %s was not a joint, skipped!'%jnt)
shapes.append( (JntToCrv ( jnts = jnt , size = ctrlSize )).newShapes )
LockHideAttr( objs=jnt, attrs='t' )
LockHideAttr( objs=jnt, attrs='radius' )
if stretch == True:
# add length attribute and connect it to scale
pm.addAttr ( jnt , ln = "length" , at = "double" , min = 0 , dv = 1 , k = True )
jnt.length >> jnt.scaleX
LockHideAttr( objs=jnt, attrs='s' )
Colorize( shapes=shapes, color=color )
return shapes
开发者ID:satishgoda,项目名称:EHM_tools,代码行数:35,代码来源:rigFK.py
注:本文中的pymel.core.ls函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论