本文整理汇总了Python中maya.cmds.filterExpand函数的典型用法代码示例。如果您正苦于以下问题:Python filterExpand函数的具体用法?Python filterExpand怎么用?Python filterExpand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filterExpand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: use_weight_set
def use_weight_set():
cmds.select(cmds.cluster(cmds.textScrollList('UI_cluster_list', q=True, si=True)[0], q=True, g=True)[0])
mel.eval("ConvertSelectionToVertices;")
weights = cmds.percent (cmds.textScrollList('UI_cluster_list', q=True, si=True)[0], q=True, v=True)
cmds.filterExpand( ex=True, sm=31 )
elements = cmds.ls(sl=True, fl=True)
return elements, weights
示例2: expandSelection
def expandSelection():
'''Expands current component selection to its max bounds'''
oldSize = len(cmds.filterExpand(sm=[28,29,31,32,33,34,35]))
while(1):
cmds.polySelectConstraint(pp=1,t=0x00100)
newSize = len(cmds.filterExpand(sm=[28,29,31,32,33,34,35]))
if oldSize == newSize: break
oldSize = newSize
示例3: getObjectVertices
def getObjectVertices(ob, verts):
ov = cmds.polyListComponentConversion(ob, tv=1)
ov = cmds.filterExpand(ov, ex=1, fp=1, sm=31)
verts = cmds.filterExpand(verts, ex=1, fp=1, sm=31)
# print ov
# print verts
com = []
for v in verts:
if v in ov:
com.append(v)
return com
示例4: meshFaceConstraintList
def meshFaceConstraintList(faceList=[], transformList=[], orient=True, prefix=''):
"""
"""
# ==========
# - Checks -
# ==========
# Face List
if not faceList:
faceList = cmds.filterExpand(sm=34)
if not faceList: raise Exception('No mesh face list specified for constraint!')
# Transform List
if not transformList:
transformList = ['' for vtx in vtxList]
# Vertex / Face list length
if not len(faceList) == len(transformList):
raise Exception('Face and Transform list length mis-match!')
# ======================
# - Create Constraints -
# ======================
constraintList = []
for i in range(len(faceList)):
cmds.select(cl=True)
itPrefix = prefix + '_' + str(i)
constraintList.append(meshFaceConstraint(faceList[i], transformList[i], orient=orient, prefix=itPrefix))
# =================
# - Return Result -
# =================
return constraintList
示例5: GrpEdgstoVertx
def GrpEdgstoVertx():
sel=mc.ls(sl=True)
if sel:
if (mc.filterExpand(sel[0], sm = 32)):
if not len(sel)==1:
seled = flatten(sel)
seled1 = seled[:]
edgGrps = []
comEdges = []
for i in range(len(seled1)):
if len(seled) > 1:
if seled1[i] in comEdges:
continue
mc.select(seled1[i], r = 1)
mel.eval('polySelectEdges edgeLoopOrBorder')
loopEdges = flatten(mc.ls(sl=1))
comEdges = list(set(seled).intersection(set(loopEdges)))
#edgGrps.append(comEdges)
print comEdges
if comEdges not in edgGrps :
edgGrps.append(comEdges)
mc.select(cl=1)
for each in comEdges:
mc.select(each,add=True)
mel.eval('polyToCurve -form 2 -degree 3')
else:
mel.eval('polyToCurve -form 2 -degree 3')
mc.select(cl=1)
else:
mc.confirmDialog (title='Error' ,message= 'Please Select Edges', button=['OK'] ,defaultButton='Yes')
else:
mc.confirmDialog (title='Error' ,message= 'Nothing Selected..Please Select any Edges', button=['OK'] ,defaultButton='Yes')
示例6: buildEdgeCurves
def buildEdgeCurves(edges,name,color=None):
'''
Build poly edge curves.
Group, name and color resulting curves.
@param edges: List of poly edges to extract as curves.
@type edges: str
@param name: Curve and group name prefix.
@type name: str
@param color: Color to apply to the edge curve (group).
@type color: int or str or None
'''
# Get Edges
edges = mc.filterExpand(ex=True,sm=32) # Poly Edges
if not edges: raise Exception('Invalid or empty edge list!')
# Get Master Group
masterGrp = buildMasterCurveGroup('edgeCurveGroup')
# Get Curve Group
curveGrp = buildCurveGroup(name,color)
try: mc.parent(curveGrp,masterGrp)
except: pass
# Build Edge Curves
crvList = []
for edge in edges:
crv = mc.polyToCurve(edge,form=2,degree=1)[0]
for at in 'trs': mc.setAttr(crv+'.'+at,l=True,cb=False)
mc.parent(crv,curveGrp)
# Return Result
return curveGrp
示例7: storeSelection
def storeSelection(self):
#Handle Object Selection
for item in cmds.ls(sl=1,tr=1,l=1):
obj = ObjSelData(item)
self.__setitem__(item, obj)
#Handle Component Selection
for item in cmds.ls(hl=1,l=1):
obj = ObjSelData(item, hilite=True)
obj.populateSubSelection()
self.__setitem__(item, obj)
#Handle Components whose mesh is hilited
sel_comps = []
clean_set = set()
for compType in ObjSelData._filterExpandMap.values():
sel_comps += cmds.filterExpand(ex=0,fp=1,sm=compType) or []
for item in sel_comps:
shape = item.split('.')[0]
parent = shape.rsplit('|',1)[0]
clean_set.add(parent)
for item in list(clean_set) :
obj = ObjSelData(item, hilite=True)
obj.populateSubSelection()
self.__setitem__(item, obj)
示例8: MakeJntAndIKs
def MakeJntAndIKs(side):
"""
选择两圈眼球上的线,生成骨骼和ik,side的值例如:R_In or R_Out
ps: 选择骨骼链的子物体,打组,centerPivot,在原点生成一个骨点,用组约束骨点,正确命名,然后将IK组分别放到对应骨点下边。
"""
lx_start=mc.xform('loc_eyeCenter01',q=1,ws=1,t=1)
lx_mouthPnt= mc.filterExpand(sm=31)
mc.select (cl=1)
lx_Jnts=[]
lx_IKs = []
for i in lx_mouthPnt :
lx_end=mc.xform(i,q=1,ws=1,t=1)
lx_stJnt=mc.joint (n=("Jnt_"+side+"_st"),p=(lx_start[0],lx_start[1],lx_start[2]),radius=0.1)
lx_edJnt=mc.joint (n=("Jnt_"+side+"_ed"),p=(lx_end[0],lx_end[1],lx_end[2]),radius=0.1)
lx_scik =mc.ikHandle (n=("scik_"+side+str(01)),sj=lx_stJnt,ee=lx_edJnt,sol="ikSCsolver")
#mc.setAttr((str(lx_scik[0]) +".visibility") ,0)
mc.select(cl=1)
lx_Jnts.append(lx_stJnt)
lx_IKs .append(lx_scik[0])
mc.select(lx_Jnts,r=1)
mc.group(n=("grp_Jnts"+side))
mc.select(lx_IKs,r=1)
mc.group(n=("grp_iks"+side))
mc.setAttr((str("grp_iks"+side) +".visibility") ,0)
#3.选择眼皮曲线,执行脚本,生成
def MakeEyeLidJnts(cuvs):
示例9: setObjectToShatterCmd
def setObjectToShatterCmd(self, *args):
'''
'''
if not (cmds.draggerContext(self._IScontextTool._mContext, exists = True)):
iMinTime = cmds.playbackOptions(query = True, minTime = True)
cmds.currentTime(iMinTime, edit = True)
polySelection = cmds.filterExpand(selectionMask = 12)
if polySelection:
if len(polySelection) > 0:
mBreakNode = cmds.listConnections(polySelection[0], sh = True, type = 'fxBreakGeometry')
if not mBreakNode:
cmds.button(self._ISaddBtn, edit = True, label = 'Please wait... checking mesh toplogy')
self._IScontextTool.checkForNonManifoldMeshes(polySelection[0])
cmds.delete(polySelection[0], ch = True)
self.resetIShatterGUI()
self._IScontextTool._mVoroObject = polySelection[0]
cmds.button(self._ISaddBtn, edit = True, label = polySelection[0])
cmds.button(self._ISdelBtn, edit = True, enable = True)
cmds.button(self._ISprocessBtn, edit = True, enable = True)
cmds.checkBox(self._ISborderEdgesCbx, edit = True, enable = True)
cmds.checkBox(self._IShideObjectsCbx, edit = True, enable = True)
else:
cmds.confirmDialog(title = 'Oups... IShatter Error', message = 'You must select one mesh object first !', button = 'OK', defaultButton = 'Yes', cancelButton = 'No', dismissString = 'No')
示例10: alignUVs
def alignUVs(doU, minU, doV, inV):
"""
align selected uvs based on the one most on top, bottom, left, right
"""
# get the selected UVs from current selection
selectedItems = cmds.filterExpand(ex=False, sm=35) # 35 means UVs
uvMin = []
uvMax = []
# get the 3d bounding box of selection
uvInfo = cmds.polyEvaluate(bc2=True)
uvMin[0] = uvInfo[0]
uvMin[1] = uvInfo[2]
uvMax[0] = uvInfo[1]
uvMax[1] = uvInfo[3]
if doU:
if minU:
cmds.polyEditUV(r=False, u=uvMin[0])
else:
cmds.polyEditUV(r=False, u=uvMax[0])
if doV:
if minV:
cmds.polyEditUV(r=False, v=uvMin[1])
else:
cmds.polyEditUV(r=False, v=uvMax[1])
示例11: alignVertices
def alignVertices(minX, maxX, minY, maxY, minZ, maxZ):
"""
align vertices in 3d
"""
# get the selected vertices from current selection
selectedItems = cmds.filterExpand(ex=False, sm=31) # 31 means vertices
# get the 3d bounding box of selection
bInfo = cmds.polyEvaluate(bc=True)
xmin = bInfo[0][0]
xmax = bInfo[0][1]
ymin = bInfo[1][0]
ymax = bInfo[1][1]
zmin = bInfo[2][0]
zmax = bInfo[2][1]
if minX:
cmds.move(xmin, moveX=True)
if maxX:
cmds.move(xmax, moveX=True)
if minY:
cmds.move(ymin, moveY=True)
if maxY:
cmds.move(ymax, moveY=True)
if minZ:
cmds.move(zmin, moveZ=True)
if maxZ:
cmds.move(zmax, moveZ=True)
示例12: getMeshVertexData
def getMeshVertexData( mesh ):
returnData = []
exportObject = 'bwExportObject'
cmds.duplicate( mesh, n=exportObject )
cmds.polyTriangulate(exportObject)
numOfFaces = cmds.polyEvaluate(exportObject, f=True )
for i in xrange(0, numOfFaces):
faceSelect = exportObject + '.f[' + str(i) + ']'
fVertices = []
fVertices = cmds.polyListComponentConversion(faceSelect, ff = True, tvf = True)
fVertices = cmds.filterExpand(fVertices, sm = 70, ex = True)
print fVertices
for vertex in fVertices:
faceDict = {}
vName = cmds.polyListComponentConversion(vertex, fvf = True, tv = True)
xyz = []
xyz = cmds.xform(vName, q = True, os = True, t = True)
faceDict['x'] = round(xyz[0], 2)
faceDict['y'] = round(xyz[1], 2)
faceDict['z'] = round(xyz[2], 2)
normal = []
normal = cmds.polyNormalPerVertex(vertex, q = True, xyz = True)
faceDict['xN'] = round(normal[0], 2)
faceDict['yN'] = round(normal[1], 2)
faceDict['zN'] = round(normal[2], 2)
# vuv = []
# vuv = cmds.polyListComponentConversion(vertex, fvf = True, tuv = True)
# uvCoords = []
# uvCoords = cmds.polyEditUV(vuv[0], q = True, u = True, v = True)
# faceDict['u'] = round(uvCoords[0], 2)
# faceDict['v'] = round(uvCoords[0], 2)
returnData.append(faceDict)
cmds.delete(exportObject)
return json.dumps(returnData)
示例13: doIt
def doIt(self,argList):
polygons = cmds.filterExpand(sm=12)
if not polygons:
print 'Please select a polygon.'
return
paths = cmds.fileDialog2(dialogStyle=2, fileMode = 3, okCaption = "Save", cancelCaption = "Cancel")
if not paths:
return
for p in range(0, len(polygons)):
polygon = polygons[p]
related_cluster = mel.eval('findRelatedSkinCluster '+polygon)
if related_cluster == '':
print 'Please bind skin for this polygon.' + polygon
continue
path = paths[0]
joints = cmds.skinPercent(related_cluster, polygon+'.vtx[0]', q = True, t = None);
f = open(path+'/'+polygon+'.weights', 'w')
vertices = cmds.getAttr(polygon+'.vrts', multiIndices = True);
for i in range(0, len(vertices)):
infs = cmds.skinPercent(related_cluster, polygon+'.vtx['+str(vertices[i])+']', q = True, v = True)
pos = cmds.xform(polygon+'.vtx['+str(vertices[i])+']', q=1, ws=1, t=1)
f.write('vp ' + str(pos[0])+' '+str(pos[1])+' '+str(pos[2]) + '\n')
f.write('vinf');
for j in range(0, len(infs)):
f.write(' ' + joints[j] + ' ' + str(infs[j]))
f.write('\n')
f.close()
print 'Export Complete.'
开发者ID:teststaybaka,项目名称:Maya_Plugin_SkinMapExporterImporter,代码行数:33,代码来源:skinExporter_Importer_Space.py
示例14: cache
def cache(s, meshes=None):
"""
Store joints influence on objects for quick checking later
"""
if meshes:
# Cache Joints and Meshes
for mesh in meshes:
skin = mel.eval("findRelatedSkinCluster %s" % mesh)
if skin:
joints = cmds.skinPercent(skin, "%s.vtx[0]" % mesh, q=True, t=None)
for vert in range(cmds.getAttr("%s.weightList" % skin, size=True)):
for i, v in enumerate(cmds.skinPercent(skin, "%s.vtx[%s]" % (mesh, vert), q=True, v=True)):
joint = joints[i]
if 0.2 < v:
# Sort by joints
s.joints[joint] = s.joints.get(joint, [])
s.joints[joint].append("%s.vtx[%s]" % (mesh, vert))
# Sort by meshes
s.meshes[mesh] = s.meshes.get(mesh, {})
s.meshes[mesh][joint] = s.meshes[mesh].get(joint, {})
s.meshes[mesh][joint][vert] = v
# Speed up Cache
if s.joints:
s.select.ignore = True
for j in s.joints:
cmds.select(s.joints[j], r=True)
s.joints[j] = cmds.filterExpand(ex=False, sm=31)
cmds.select(clear=True)
else:
s.meshes = {}
s.joints = {}
pass
示例15: edgeLoopsToCurve
def edgeLoopsToCurve(edgeList,form=2,degree=1):
'''
Generate edge loop curves from the specified list of edges.
@param edgeList: The list of mesh edges to generate edge loop curves from.
@type edgeList: list
@param form: NURBS curve form. 0 = Periodic, 1 = Open, 2 = Best Guess.
@type form: str
@param degree: NURBS curve degree.
@type degree: str
'''
# Filter/Check Edge List
edgeList = mc.filterExpand(edgeList,ex=True,sm=32)
if not edgeList: raise Exception('Invalid edge list!')
# For Each Edge
edgeCurveList = []
for edge in edgeList:
# Get Mesh
edgeId = glTools.utils.component.index(edge)
meshShape = mc.ls(edge,o=True)[0]
mesh = mc.listRelatives(meshShape,p=True)[0]
prefix = mesh.split(':')[-1]
# To Edge Loop
mc.polySelect(mesh,edgeLoop=edgeId)
# Edge Loop to Curve
edgeCurve = mc.polyToCurve(ch=False,form=form,degree=degree)[0]
# Append List
edgeCurveList.append(edgeCurve)
# Return Result
return edgeCurveList