本文整理汇总了Python中maya.cmds.select函数的典型用法代码示例。如果您正苦于以下问题:Python select函数的具体用法?Python select怎么用?Python select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: m
def m(p, _t=None):
if not _t:
_t = mc.ls(sl=1)
for i in range (0,len(_t)):
mc.select(_t[i])
mc.move(p[0],p[1],p[2])
示例2: edgeLoopWeights
def edgeLoopWeights(edgeList):
"""
"""
# Check Edge List
if not edgeList: raise Exception('Invalid or empty edge list!')
edgeList = cmds.filterExpand(edgeList, ex=True, sm=32) or []
if not edgeList: raise Exception('Invalid edge list! List of polygon edges required...')
# Get Mesh from Edges
mesh = list(set(cmds.ls(edgeList, o=True) or []))
if len(mesh) > 1:
raise Exception('Edges from multiple mesh shapes were supplied! ' + str(mesh))
mesh = mesh[0]
for edge in edgeList:
# Get Edge ID
edgeID = glTools.utils.component.index(edge)
# Get Vertices from Edge
edgeVerts = cmds.polyListComponentConversion(edge, fe=True, tv=True)
# Get Average Vertex Weights
cmds.select(edgeVerts)
glTools.tools.copyPasteWeights.averageWeights()
# Select Edge Loop Vertices
cmds.polySelect(mesh, edgeLoop=edgeID)
loopEdges = cmds.ls(sl=1, fl=1)
loopVerts = cmds.polyListComponentConversion(loopEdges, fe=True, tv=True)
cmds.select(loopVerts)
glTools.tools.copyPasteWeights.pasteWeights()
# Return Result
return mesh
示例3: orderNextTo
def orderNextTo(objects, target):
'''
places 'objects'/[objects] next to 'target' in hierarchy and ordering
I found most of the time I use the get/setOrder stuff to relocate objs to another
with parenting and if in world and hierarchy Nr and all that shit.. this does it inline
'''
if not isinstance(objects, list):
objects = [objects]
handledObjs = []
targetParent = m.listRelatives(target, parent=True, fullPath=True)
targetNr = getOrder(target)
# handle each object on its own no matter how its parented
for o in objects:
oParent = m.listRelatives(o, parent=1, fullPath=1)
if oParent != targetParent:
if targetParent:
o = m.parent(o, targetParent)[0]
else:
o = m.parent(o, world=1)[0]
# else if in same hierarchy already decrease count if obj is before target
elif getOrder(o) <= targetNr:
targetNr -= 1
handledObjs.append(o)
setOrder(handledObjs, targetNr + 1)
m.select(handledObjs)
return handledObjs
示例4: checkSelObj
def checkSelObj(self):
"""检查选中的物体是否为mesh节点
Description:
选有物体且所选的是mesh节点,返回True
没选物体或所选物体类型不符合,则返回False
Arguments:
无
Returns:
result = True:通过检查
result = False:没通过检查,释放所有选择
"""
selObj = cmds.ls(sl =True)
lenOfSel = len(selObj)
result = True
if lenOfSel < 1:
cmds.confirmDialog(title = "Warning", message = "Please Select Objects!", button = "OK", defaultButton = "OK")
result = False
else:
for eachObj in selObj:
if cmds.nodeType(eachObj) != "transform":
cmds.confirmDialog(title = "Warning", message = "There Has An Object With Incorrect Type!", button = "OK", defaultButton = "OK")
cmds.select(deselect = True) #去除所有选择
result = False
break
return result
示例5: crear
def crear(self):
#Tipo 1
if(self.edififio_seleccionado == 0):
cmds.polyCube(w = self.anchura, d = self.Largo, h = self.Anchura_random, n = str(self.EdificioName))
#Tipo 2
elif(self.edififio_seleccionado == 1):
cmds.polyCube(w = self.anchura, d = self.Largo, h = self.Anchura_random, n = str(self.EdificioName))
#Modificamos las caras aleatoriamente
for i in range(0, random.randrange(0,3)):
cmds.polyExtrudeFacet(str(self.EdificioName) + ".f[1]", kft = False, ls = (0.8, 0.8, 0))
cmds.polyExtrudeFacet(str(self.EdificioName) + ".f[1]", kft = False, ltz = 30)
#Tipo 3
else:
cmds.polyCube(w = self.anchura, d = self.Largo, h = self.Anchura_random, sx = self.xDiv, sy = self.yDiv, sz = self.zDiv, n = str(self.EdificioName))
sides = []
#Seleccionamos el edificio
for i in range(0, 8):
if(i != 1 and i != 3):
sides.append(str(self.EdificioName) + ".f[" + str(self.xDiv * self.yDiv * i) + ":" + str((self.xDiv * self.yDiv * (i+1)) - 1) + "]")
#Modificamos las caras para generar ventanas
cmds.polyExtrudeFacet(sides[0], sides[1], sides[2], sides[3], sides[4], sides[5], kft = False, ls = (0.8, 0.8, 0))
windows = cmds.ls(sl = True)
cmds.polyExtrudeFacet(windows[1], windows[2], windows[3], kft = False, ltz = -0.2)
cmds.select( self.EdificioName)
示例6: filterSelection
def filterSelection(self):
"""
from a raw list of items, returns 1 dict containing:
{[meshes], [cameras], [locators], [lights]}
"""
# get current selection
cmds.select(hi = True)
selection = [str(item) for item in cmds.ls(sl = True)]
# fill the items dict from the raw selection
items = {}
# meshes
items['meshes'] = [cmds.listRelatives(node, p=True, fullPath=True)[0] \
for node in selection if cmds.nodeType(node) == "mesh"]
# cameras
items['cameras'] = [cmds.listRelatives(node, p=True, fullPath=True)[0] \
for node in selection if cmds.nodeType(node) == "camera"]
# locators
items['locators'] = [cmds.listRelatives(node, p=True, fullPath=True)[0] \
for node in selection if cmds.nodeType(node) == "locator"]
# lights
items['lights'] = [cmds.listRelatives(node, p=True, fullPath=True)[0] \
for node in selection if 'Light' in cmds.nodeType(node)]
return items
示例7: mirrorJoints
def mirrorJoints(self, topJoint = '', prefix = ['l_', 'r_']):
"""
mirroring joint, top node needs to contain 'l_' as prefix
"""
lPrefix = prefix[0]
rPrefix = prefix[1]
cmds.select(cl = True)
cmds.joint(n = 'temp_jnt')
cmds.select(topJoint, r = True)
cmds.select('temp_jnt', tgl = True)
self.toggleSelect(topJoint, 'temp_jnt')
cmds.parent()
cmds.select(topJoint, r = True)
cmds.mirrorJoint(mirrorYZ = True, mirrorBehavior = True, myz = True, searchReplace = prefix)
rJoint = rPrefix + topJoint.split(lPrefix)[-1]
cmds.select(topJoint, rJoint)
cmds.parent(w = True)
cmds.delete('temp_jnt')
return rJoint
示例8: __init__
def __init__(self, start_face):
self.start_face = start_face
cmds.select(self.start_face)
self.start_face_sel = cmds.ls(sl=True)
self.slice_point = self.start_face_sel[0].find('.')
self.geom_name = self.start_face_sel[0][:int(self.slice_point)]
self.ordered_list = [self.start_face]
示例9: orientJoints
def orientJoints(s):
"""
Face joints in the correct direction.
"""
sel = cmds.ls(sl=True)
err = cmds.undoInfo(openChunk=True)
try:
markers = s.markers
joints = markers.keys()
with ReSeat(joints):
for j in joints:
m = markers[j]
if cmds.objExists(m.marker) and cmds.objExists(j):
with Isolate(j):
m.setJoint()
try:
cmds.makeIdentity(
j,
apply=True,
r=True) # Freeze Rotations
except RuntimeError:
pass
else: # User deleted marker / joint. Stop tracking.
m.removeMarker()
del markers[j]
cmds.select(sel, r=True)
except Exception as err:
raise
finally:
cmds.undoInfo(closeChunk=True)
if err: cmds.undo()
示例10: mirror_chain
def mirror_chain(self, side = None):
#create one temporary joint at the origin
tmp_jnt = cmds.joint(position = [0, 0, 0])
#parent the chain to that joint
cmds.parent(self.fk_joint_names[0], tmp_jnt)
#mirror the chain and rename the mirrored side
if side == 'L':
self.mirrored_fk_joint_names = cmds.mirrorJoint(self.fk_joint_names[0], mirrorYZ = 1, mirrorBehavior = 1, searchReplace = (side, 'R'))
elif side == 'l':
self.mirrored_fk_joint_names = cmds.mirrorJoint(self.fk_joint_names[0], mirrorYZ = 1, mirrorBehavior = 1, searchReplace = (side, 'r'))
elif side == 'R':
self.mirrored_fk_joint_names = cmds.mirrorJoint(self.fk_joint_names[0], mirrorYZ = 1, mirrorBehavior = 1, searchReplace = (side, 'L'))
elif side == 'r':
self.mirrored_fk_joint_names = cmds.mirrorJoint(self.fk_joint_names[0], mirrorYZ = 1, mirrorBehavior = 1, searchReplace = (side, 'l'))
else:
self.mirrored_fk_joint_names = cmds.mirrorJoint(self.fk_joint_names[0], mirrorYZ = 1, mirrorBehavior = 1)
#unparent the chain and delete the temporary joint
cmds.parent(self.fk_joint_names[0], self.mirrored_fk_joint_names[0], world = 1)
cmds.delete(tmp_jnt)
cmds.select(clear = 1)
return self.mirrored_fk_joint_names
示例11: cutSkin
def cutSkin(mesh, weightThreshold=0.25, reducePercent=None, parentShape=False):
"""
Extract a per influence proxy mesh from a skinned mesh based on influence weights.
@param mesh: Mesh to extract faces from
@type mesh: str
@param weightThreshold: Influence to use to extract faces
@type weightThreshold: float
@param reducePercent: Influence to use to extract faces
@type reducePercent: int or None
"""
# Initialize
startTime = cmds.timerX()
cmds.undoInfo(state=False)
# Get Skin Info
skin = glTools.utils.skinCluster.findRelatedSkinCluster(mesh)
if not skin:
print('Cut Skin: Mesh "" has no skinCluster! Skipping...')
return None
# Prune Weights
glTools.utils.skinCluster.lockSkinClusterWeights(skin, lock=False, lockAttr=False)
pruneWts = glTools.utils.mathUtils.distributeValue(10, rangeStart=0.001, rangeEnd=weightThreshold)
cmds.select(mesh)
for wt in pruneWts:
try:
mel.eval('doPruneSkinClusterWeightsArgList 1 {"' + str(wt) + '"}')
except Exception, e:
print('Prune weight FAILED (' + mesh + ')! ' + str(e))
break
示例12: csvWrite
def csvWrite():
""" This is the path where the csv will be written. Change this to a path on your local machine. """
path = "R:/System/CSV_files/armCsv.csv"
""" Open the csv in maya for writing """
writer = csv.writer(open(path, 'wb'), delimiter=',')
""" Create a new list based off your selection """
selectionList = cmds.ls(sl=True)
""" Clear the selection """
cmds.select(clear=True)
for selection in selectionList:
""" An empty list to hold both the joint names and the positions """
jointInfo = []
pos = cmds.xform(selection, q=True, t=True, ws=True)
""" Append the name of the locator and it's position to a new list"""
""" I am splitting the positions into seperate variables to make things easier when I try read them later """
jointInfo.append(selection)
jointInfo.append(pos[0])
jointInfo.append(pos[1])
jointInfo.append(pos[2])
""" At this point you could use the joint info to build joints """
""" Write the data to csv """
writer.writerow(jointInfo)
""" Print the joint info so you can see what is happening """
print jointInfo
示例13: export_static_ogre
def export_static_ogre(*args):
export_dir = get_export_dir()
objects = get_objects()
ogre_mesh_files = []
if (cmds.file(q=True, sceneName=True)==''):
print 'Not a valid scene. Try saving it.'
return False
if not export_dir:
print ("Empty Scene? unable to export.")
else:
print ('Export Directory:\n %s\nOgre files\n' % export_dir)
for ob in objects:
name = ob
if cmds.nodeType(ob) == 'transform':
name = cmds.listRelatives(ob)[0]
cmds.select(ob, r=True)
_path = os.path.abspath( export_dir + ('/%s.mesh' % name) )
ogre_path = _path.replace(os.sep, '/')
# print ('select %s' % ob)
print (' %s' % ogre_path)
ogre_mesh_files.append(ogre_path)
# 'ogreExport -sel -obj -lu mm -scale 1 -mesh \"aaa.mesh\" -shared -v -n -c -t -tangents TANGENT -tangentsplitmirrored;''
command = 'ogreExport -sel -obj -lu mm -scale 0.1 -mesh \"%s\" -shared -n -c -t -tangents TANGENT -tangentsplitmirrored;' % ogre_path
mm.eval(command)
cmds.select(objects)
print 'fixing materials'
fix_xml_material_names(ogre_mesh_files)
示例14: select_samename_node
def select_samename_node(name):
sel = cmds.ls(sl=True)
cmds.select(cl=True)
sel_hr = cmds.listRelatives(sel, ad=True) + sel
for node in sel_hr:
if node.count(name):
cmds.select(node, add=True)
示例15: _finger_hydraulics
def _finger_hydraulics(self):
"""Connects the finger hydraulics."""
for side in ['L', 'R']:
for finger in ['pointer', 'middle', 'ring']:
start_jnt = '%s_%sBase_result_%s' % (side, finger, self.nc.joint)
end_jnt = '%s_%s1_result_%s' % (side, finger, self.nc.joint)
if finger == 'ring':
finger = 'pinky'
# END if
start_hydraulic = '%s_%sHydraulicsStart_%s_%s' % (side, finger, self.nc.joint, self.nc.group)
mid_hydraulic = '%s_%sHydraulicsMid_%s_%s' % (side, finger, self.nc.joint, self.nc.group)
end_hydraulic = '%s_%sHydraulicsEnd_%s_%s' % (side, finger, self.nc.joint, self.nc.group)
cmds.select(cl=True)
start_offset = cmds.group(n='%s_%sBaseOffset_%s' % (side, finger, self.nc.group), empty=True)
cmds.select(cl=True)
end_offset = cmds.group(n='%s_%s2Offset_%s' % (side, finger, self.nc.group), empty=True)
self.c.snap_a_to_b(start_offset, start_hydraulic)
self.c.snap_a_to_b(end_offset, end_hydraulic)
cmds.parent(start_offset, start_jnt)
cmds.parent(end_offset, end_jnt)
cmds.parent(start_hydraulic, start_offset)
cmds.parent(end_hydraulic, end_offset)
try:
cmds.parent(mid_hydraulic, '%s_hand_%s' % (side, self.nc.group))
except Exception as err:
print err