本文整理汇总了Python中pymel.core.selected函数的典型用法代码示例。如果您正苦于以下问题:Python selected函数的具体用法?Python selected怎么用?Python selected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了selected函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export
def export(self, dirpath, all=False, center=True, child=True):
if os.path.isfile(self.opts['presetFile']):
pm.mel.FBXLoadExportPresetFile(f=self.opts['presetFile'])
ext = '.fbx'
if all:
pm.select(self.meshList.getAllItems())
sel = pm.selected()
else:
sel = pm.selected()
if len(sel) == 0:
pm.warning('Nothing is selected!')
else:
for obj in sel:
pm.select(obj)
if center:
oldLoc = obj.getRotatePivot()
self.centerPiv(obj)
exportPath = self._get_filename(dirpath, obj.name(), ext)
if child:
children = obj.getChildren()
for i in children:
if isinstance(i, pm.nt.Transform):
pm.select(i, add=True)
pm.mel.FBXExport(f=exportPath, s=True)
if center:
obj.setTranslation([oldLoc[0], oldLoc[1], oldLoc[2]])
示例2: createLocToCenter
def createLocToCenter():
old_selection = pymel.selected()
p3Pos = get_center(pymel.selected(flatten=True))
pPoint = pymel.general.spaceLocator()
pPoint.setTranslation(p3Pos, space='world')
if old_selection:
pymel.select(old_selection)
示例3: create_new_pose_prompt
def create_new_pose_prompt(self):
if not pm.selected():
pm.warning ("Please Select an Object")
return
namespace = pm.selected()[0].split(":")[0]
targetObj = "%s:geo"%(namespace)
result = pm.promptDialog(
title='Create New Pose',
message='Enter Pose Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if result == 'OK':
name = pm.promptDialog(query=True, text=True)
directory = self.get_active_directory()
path = os.path.join(directory, "%s.pose" %name)
pose_obj = Pose(path)
pose_obj.create()
pose_obj.save_pose()
pose_obj.update_thumbnail(targetObj)
self.populate_library_layout()
示例4: save_set
def save_set(self):
if not pm.selected():
pm.warning ("Please Select an Object")
return
selected = [obj.name().split(":")[-1] for obj in pm.selected()]
with open(self.set_path, 'w') as outfile:
json.dump(selected, outfile, separators=(',',':'))
示例5: one_cam_to_shots
def one_cam_to_shots():
if not pm.ls(type='shot'):
raise RuntimeError('There are no Shots in this scene.')
if len(pm.selected()) != 1 or pm.selected()[0].getShape().type() != 'camera':
raise RuntimeError('Select just 1 camera.')
the_cam = pm.selected()[0]
for shot in pm.ls(type='shot'):
shot.set_camera(the_cam)
示例6: snapPivot
def snapPivot(self):
haircap = self.capName.getText()
oldSel = pm.selected()
self.transform()
if pm.objExists(haircap):
geo = pm.ls(haircap)[0]
for sel in pm.selected():
point = geo.getClosestPoint(sel.getTranslation())
pm.move( point[0][0], point[0][1], point[0][2], sel)
pm.select(oldSel)
else: pm.error('hair cap doesnt exist in scene')
示例7: selectSkinnedJoints
def selectSkinnedJoints(node=None):
'''
selects all joints bound to the specified node
'''
if node==None:
if len(pmc.selected())==1:
node=pmc.selected()[0]
else:
return 'Please select or specify a skinCluster node'
influences = pmc.skinCluster(node, q=1, influence=1)
pmc.select(influences)
示例8: library_button_save_pose
def library_button_save_pose(self, obj):
if not pm.selected():
pm.warning ("Please Select an Object")
return
namespace = pm.selected()[0].split(":")[0]
targetObj = "%s:geo"%(namespace)
obj.save_pose()
obj.update_thumbnail(targetObj)
self.populate_library_layout()
示例9: create_ribbon_callback
def create_ribbon_callback(self, *args):
startObj = None
endObj = None
if len(pm.selected()) == 2:
startObj = pm.selected()[0]
endObj = pm.selected()[-1]
prefix = self.widgets["prefix_textField"].getText()
numJoints = self.widgets["numJoint_intField"].getValue()[0]
numSpans = self.widgets["spans_intField"].getValue()[0]
utils.create_ribbon(numJoints=numJoints, prefix=prefix, numSpans=numSpans, startObj=startObj, endObj=endObj)
示例10: create_BTN_pressed
def create_BTN_pressed(self):
ctrl_suffix = self.widgets['suffix_TFG'].getText()
create_offsetNode = self.widgets['offsetNode_CB'].getValue()
offsetNode_suffix = self.widgets['offsetNode_TF'].getText()
create_cluster = self.widgets['cluster_CB'].getValue()
cluster_group = self.widgets['clusterGroup_RBG'].getSelect()
create_shape = self.widgets['shape_CB'].getValue()
shape_type = self.widgets['shape_TSL'].getSelectItem()[0]
shape_axis = self.widgets['shapeAxis_OM'].getValue()
hierarchy = self.widgets['hierarchry_RB'].getSelect()
tConst = self.widgets['tConst_CB'].getValue()
rConst = self.widgets['rConst_CB'].getValue()
pConst = self.widgets['pConst_CB'].getValue()
sConst = self.widgets['sConst_CB'].getValue()
clusterHandles = []
if create_cluster:
if cluster_group == 1: #each
for obj in pm.selected():
c, hdl = pm.cluster(obj, name='%s_cluster'%obj.name())
clusterHandles.append(hdl)
elif cluster_group == 2: #all
c, hdl = pm.cluster(pm.selected())
clusterHandles.append(hdl)
ctrls = []
objects = clusterHandles or pm.selected()
for i, obj in enumerate(objects):
ctrlName = "%s_%s" %(obj.name(), ctrl_suffix)
ctrl = obj.add_ctrl(name=ctrlName, point=tConst, orient=rConst, scale=sConst, parent=pConst)
ctrls.append(ctrl)
if hierarchy == 2 and i != 0: #selectionOrder
pm.parent(ctrl, ctrls[ i-1 ])
if create_offsetNode:
ctrl.add_parent_group(suffix=offsetNode_suffix)
if create_shape:
ctrl.add_shape(shape=shape_type, axis=shape_axis)
示例11: getSkinBones
def getSkinBones():
aInfluences = []
for oCurObj in pymel.selected():
oSkinCluster = getSkinCluster(oCurObj)
if oSkinCluster is not None:
aInfluences += libSkinning.get_skin_cluster_influence_objects(oSkinCluster)
pymel.select(aInfluences)
示例12: zero_out_bend
def zero_out_bend(**kwargs):
"""
Zero out all the bend joint
Here we assume it already has a optimised rotate order
- joint_list: (list) List of joint to zero out te bend
- axis: (str) Which axis is the joint bending
- rotate_order: (str) What is the current rotate order
@return the rotate order
"""
joint_list = libUtilities.pyList(kwargs.get("joint_list") or get_joint_children(pm.selected()[0]))
libUtilities.freeze_rotation(joint_list)
libUtilities.freeze_scale(joint_list)
rotate_order = kwargs.get("rotate_order") or joint_list[0].rotateOrder.get(asString=True)
target_axis = kwargs.get("axis", rotate_order[0])
new_rotate_order = None
if target_axis != rotate_order[0]:
new_rotate_order = "{}{}{}".format(target_axis, rotate_order[0], rotate_order[2])
pm.undoInfo(openChunk=True)
for joint in joint_list:
for rotate_axis in rotate_order:
if rotate_axis != target_axis:
joint.attr("jointOrient{}".format(rotate_axis.upper())).set(0)
if new_rotate_order:
joint.rotateOrder.set(new_rotate_order)
pm.undoInfo(closeChunk=True)
return new_rotate_order
示例13: printSelection
def printSelection(longNames=True):
"""Print the selection in an organized, numbered list"""
selList = pm.selected()
print '\n//{0} Nodes Selected'.format(len(selList))
nameMethod = None
if longNames:
nameMethod = 'longName'
else:
nameMethod = 'name'
maxLen = 0
for obj in selList:
if hasattr(obj, nameMethod):
name = getattr(obj, nameMethod)()
else:
name = obj.name()
if len(name) > maxLen:
maxLen = len(name)
for i in range(len(selList)):
obj = selList[i]
typ = pm.nodeType(obj)
if hasattr(obj, nameMethod):
name = getattr(obj, nameMethod)()
else:
name = obj.name()
print '{index:03}. {name:<{maxLen}} - {type}'.format(index=i, name=name, type=typ, maxLen=maxLen)
示例14: init
def init(discard=False):
selection = pm.selected()
if len(selection) != 1:
print 'Must select one object'
else:
selection = selection[0]
uuid = cmds.ls(selection.name(), uuid=True)[0]
#bn = BridgedNode(uuid)
#bn = BRIDGE_NODE
if BRIDGE_NODE.uuid == None:
BRIDGE_NODE.uuid = uuid
BRIDGE_NODE.ingest()
if discard:
BRIDGE_NODE.erase_history()
if BRIDGE_NODE.is_valid():
if BRIDGE_NODE.has_history():
print '> file has history. opening source.'
else:
BRIDGE_NODE.dump_geo()
BRIDGE_NODE.dump_metadata()
else:
BRIDGE_NODE.dump_geo()
BRIDGE_NODE.dump_metadata()
open_port(PORT)
BRIDGE_NODE.edit_in_app()
示例15: fixedSeed
def fixedSeed():
sel = pm.selected()
animStartTime = pm.playbackOptions(animationStartTime=1, q=1)
animEndTime = pm.playbackOptions(animationEndTime=1, q=1)
for attr in sel:
animStartTime = pm.playbackOptions(animationStartTime=1, q=1)
animEndTime = pm.playbackOptions(animationEndTime=1, q=1)
xVal = attr.rotateX.get()
yVal = attr.rotateY.get()
zVal = attr.rotateZ.get()
print animStartTime
print animEndTime
print xVal
print yVal
print zVal
while animStartTime<=animEndTime:
attr.rotateX.set(xVal+random.uniform(-.1,.1))
attr.rotateY.set(yVal+random.uniform(-.1,.1))
attr.rotateZ.set(zVal+random.uniform(-.1,.1))
pm.setKeyframe(attribute="rotate", time=animStartTime)
animStartTime+=1