本文整理匯總了Python中pymel.core.ls方法的典型用法代碼示例。如果您正苦於以下問題:Python core.ls方法的具體用法?Python core.ls怎麽用?Python core.ls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymel.core
的用法示例。
在下文中一共展示了core.ls方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: freeze
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def freeze():
cmds.selectMode(o=True)
selection = cmds.ls(sl=True, type = 'transform')
dummy = common.TemporaryReparent().main(mode='create')#モジュールでダミーの親作成
clusterCopy = modeling.ClusterCopy()
for sel in selection:
allChildren = [sel] + cmds.listRelatives(sel, ad=True)#子供を取得して1つのリストにする
polyMesh = common.search_polygon_mesh(allChildren)
if polyMesh:
for mesh in polyMesh:
common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='cut')
defCls = clusterCopy.copy(mesh)
cmds.bakePartialHistory(mesh,pc=True)
if defCls:
clusterCopy.paste(mesh)
common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='parent')#コピーのおわったメッシュの子供を元に戻す
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除
cmds.select(selection, r=True)
示例2: select_all_child_controls
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def select_all_child_controls(control, *args): # @unusedVariable
""" Selects all child controls from the given control
This function uses Maya's controller nodes and commands to find relevant
dependencies between controls
Args:
control (str): parent animation control (transform node)
*args: State of the menu item (if existing) send by mgear's dagmenu
"""
# gets controller node from the given control. Returns if none is found
tag = cmds.ls(cmds.listConnections(control), type="controller")
if not tag:
return
# query child controls
children = get_all_tag_children(tag)
# adds to current selection the children elements
cmds.select(children, add=True)
示例3: process
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def process(self, context, plugin):
import pymel.core as pm
# Get the errored instances
failed = []
for result in context.data["results"]:
if (result["error"] is not None and result["instance"] is not None
and result["instance"] not in failed):
failed.append(result["instance"])
# Apply pyblish.logic to get the instances for the plug-in
instances = api.instances_by_plugin(failed, plugin)
for instance in instances:
for node in instance[0].members():
io = pm.ls(node.getShapes(), intermediateObjects=True)
pm.delete(io)
示例4: all_shots
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def all_shots(self):
"""return all the shots connected to this sequencer
"""
return pm.ls(self.shots.get(), typ='shot')
# @extends(pm.nodetypes.Sequencer)
# @all_shots.setter
# def all_shots(self, shots):
# """setter for the all_shots property
# """
# # remove the current shots first
# # then append the new ones
# for s in self.all_shots:
# t = s // self.shots
#
# for s in shots:
# t = s.message >> self.shots.next_available
示例5: rivet_per_face
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def rivet_per_face():
"""creates hair follicles per selected face
"""
sel_list = pm.ls(sl=1, fl=1)
follicles = []
locators = []
for face in sel_list:
# use the center of the face as the follicle position
p = reduce(lambda x, y: x + y, face.getPoints()) / face.numVertices()
obj = pm.spaceLocator(p=p)
locators.append(obj)
shape = face.node()
uv = face.getUVAtPoint(p, space='world')
follicle_transform, follicle = create_follicle(shape, uv)
pm.parent(obj, follicle_transform)
follicles.append(follicle)
return follicles, locators
示例6: check_sequence_name
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def check_sequence_name(self):
"""checks sequence name and asks the user to set one if maya is in UI
mode and there is no sequence name set
"""
sequencer = pm.ls(type='sequencer')[0]
sequence_name = sequencer.getAttr('sequence_name')
if sequence_name == '' and not pm.general.about(batch=1) \
and not self.batch_mode:
result = pm.promptDialog(
title='Please enter a Sequence Name',
message='Sequence Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel'
)
if result == 'OK':
sequencer.setAttr(
'sequence_name',
pm.promptDialog(query=True, text=True)
)
示例7: setup_stretchy_spline_ik_curve
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def setup_stretchy_spline_ik_curve(cls):
"""
"""
selection = pm.ls(sl=1)
curve = selection[0]
curve_info = pm.createNode("curveInfo")
mult_div = pm.createNode("multiplyDivide")
curve_shape = pm.listRelatives(curve, s=1)
curve_shape[0].worldSpace >> curve_info.ic
curve_info.arcLength >> mult_div.input1X
curve_length = curve_info.arcLength.get()
mult_div.input2X.set(curve_length)
mult_div.operation.set(2)
pm.select(mult_div, curve_info, curve_shape[0], add=True)
示例8: reset_tweaks
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def reset_tweaks(cls):
"""Resets the tweaks on the selected deformed objects
"""
for obj in pm.ls(sl=1):
for tweak_node in pm.ls(obj.listHistory(), type=pm.nt.Tweak):
try:
for i in tweak_node.pl[0].cp.get(mi=1):
tweak_node.pl[0].cv[i].vx.set(0)
tweak_node.pl[0].cv[i].vy.set(0)
tweak_node.pl[0].cv[i].vz.set(0)
except TypeError:
try:
for i in tweak_node.vl[0].vt.get(mi=1):
tweak_node.vl[0].vt[i].vx.set(0)
tweak_node.vl[0].vt[i].vy.set(0)
tweak_node.vl[0].vt[i].vz.set(0)
except TypeError:
pass
示例9: get_pin_shader
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def get_pin_shader(self):
"""this creates or returns the existing pin shader
"""
shaders = pm.ls("%s*" % self.pin_shader_prefix)
if shaders:
# try to find the shader with the same color
for shader in shaders:
if list(shader.color.get()) == self.color:
return shader
# so we couldn't find a shader
# lets create one
shader = pm.shadingNode("lambert", asShader=1)
shader.rename("%s#" % self.pin_shader_prefix)
shader.color.set(self.color)
# also create the related shadingEngine
shading_engine = pm.nt.ShadingEngine()
shading_engine.rename("%sSG#" % self.pin_shader_prefix)
shader.outColor >> shading_engine.surfaceShader
return shader
示例10: set_finalGatherHide
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def set_finalGatherHide(cls, value):
"""sets the finalGatherHide to on or off for the given list of objects
"""
attr_name = "miFinalGatherHide"
objects = pm.ls(sl=1)
for obj in objects:
shape = obj
if isinstance(obj, pm.nt.Transform):
shape = obj.getShape()
if not isinstance(shape, (pm.nt.Mesh, pm.nt.NurbsSurface)):
continue
# add the attribute if it doesn't already exists
if not shape.hasAttr(attr_name):
pm.addAttr(shape, ln=attr_name, at="long", min=0, max=1, k=1)
obj.setAttr(attr_name, value)
示例11: populateJoints
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def populateJoints(self, *args):
""" This function is responsable to list all joints or only dpAR joints in the interface in order to use in skinning.
"""
# get current jointType (all or just dpAutoRig joints):
jntSelectedRadioButton = cmds.radioCollection(self.allUIs["jntCollection"], query=True, select=True)
chooseJnt = cmds.radioButton(jntSelectedRadioButton, query=True, annotation=True)
# list joints to be populated:
jointList, sortedJointList = [], []
allJointList = cmds.ls(selection=False, type="joint")
if chooseJnt == "allJoints":
jointList = allJointList
cmds.checkBox(self.allUIs["_JntCB"], edit=True, enable=False)
cmds.checkBox(self.allUIs["_JisCB"], edit=True, enable=False)
elif chooseJnt == "dpARJoints":
cmds.checkBox(self.allUIs["_JntCB"], edit=True, enable=True)
cmds.checkBox(self.allUIs["_JisCB"], edit=True, enable=True)
displayJnt = cmds.checkBox(self.allUIs["_JntCB"], query=True, value=True)
displayJis = cmds.checkBox(self.allUIs["_JisCB"], query=True, value=True)
for jointNode in allJointList:
if cmds.objExists(jointNode+'.'+BASE_NAME+'joint'):
if displayJnt:
if "_Jnt" in jointNode:
jointList.append(jointNode)
if displayJis:
if "_Jis" in jointNode:
jointList.append(jointNode)
# sort joints by name filter:
jointName = cmds.textField(self.allUIs["jointNameTF"], query=True, text=True)
if jointList:
if jointName:
sortedJointList = utils.filterName(jointName, jointList, " ")
else:
sortedJointList = jointList
# populate the list:
cmds.textScrollList( self.allUIs["jntTextScrollLayout"], edit=True, removeAll=True)
cmds.textScrollList( self.allUIs["jntTextScrollLayout"], edit=True, append=sortedJointList)
# atualize of footerB text:
self.atualizeSkinFooter()
示例12: __init__
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def __init__(self):
self.aDrivers = [] # List of parent in the system
self.nDriven = None # Base constrained objet (The constraint will no be set on this object
self.nSwConst = None # SpaceSwitch constraint for the system
self.nSwConstRecept = None # Constrained node
self.aFreeIndex = [] # List of free index (Can only happen when a item is removed) in the parent constraint
self.sSysName = "SpaceSwitcher_" # Name of the system
tempWorld = pymel.ls(self.WORLD_NODE_NAME)
if tempWorld:
self.worldNode = tempWorld[0]
else:
self.worldNode = None
示例13: get_all_ctrls
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def get_all_ctrls():
ctrls = pymel.ls('*_Ctrl')
ctrls = filter(_is_ctrl, ctrls)
return ctrls
示例14: get_all_ctrlsnapshots
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def get_all_ctrlsnapshots():
snapshots = pymel.ls('*_CtrlSnapshot')
snapshots = filter(_is_ctrl, snapshots)
return snapshots
示例15: ls_ex
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import ls [as 別名]
def ls_ex(*args, **kwargs):
return PyNodeChain(pymel.ls(*args, **kwargs))
# Wrapper for pymel.ls that return only objects without parents.