Python maya.cmds.cluster() Examples
The following are 11
code examples of maya.cmds.cluster().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: dpControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def shapeSizeSetup(self, transformNode, *args): """ Find shapes, create a cluster deformer to all and set the pivot to transform pivot. Returns the created cluster. """ clusterHandle = None childShapeList = cmds.listRelatives(transformNode, shapes=True, children=True) # print "Child length {0}".format(len(childShapeList)) if childShapeList: thisNamespace = childShapeList[0].split(":")[0] cmds.namespace(set=thisNamespace, force=True) clusterName = transformNode.split(":")[1]+"_ShapeSizeCH" clusterHandle = cmds.cluster(childShapeList, name=clusterName)[1] cmds.setAttr(clusterHandle+".visibility", 0) cmds.xform(clusterHandle, scalePivot=(0, 0, 0), worldSpace=True) cmds.namespace(set=":") else: print "There are not children shape to create shapeSize setup of:", transformNode return clusterHandle
Example #2
Source File: ml_softWeights.py From ml_tools with MIT License | 6 votes |
def ui(): ''' User interface for ml_softWeights ''' with utl.MlUi('ml_softWeights', 'Soft Weights', width=400, height=180, info='''Set deformer weights based on current soft-selection. Follow the instructions below for either cluster or skin. ''') as win: mc.text(label='Select vertices with soft selection.') win.buttonWithPopup(label='Create Cluster', command=softSelectionClusterWeights, annotation='Select a vertex with soft selection to create a cluster.') mc.separator(height=20) mc.text(label='Select vertices with soft selection, followed by a joint.') win.buttonWithPopup(label='Set Joint Weights', command=softSelectionSkinWeights, annotation='Select vertices with soft selection, followed by a joint.')
Example #3
Source File: sqStickyLipsSetup.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def sqCreateClusters(self, curveA, curveB, *args): self.clusterList = [] for i in range(1, self.curveLenght-1): self.clusterList.append(cmds.cluster([curveA+".cv["+str(i)+"]", curveB+".cv["+str(i)+"]"], name="StickyLips_"+str(`i-1`)+"_Cls")[1]) return self.clusterList
Example #4
Source File: dpControls.py From dpAutoRigSystem with GNU General Public License v2.0 | 5 votes |
def dpCheckLinearUnit(self, origRadius, defaultUnit="centimeter", *args): """ Verify if the Maya linear unit is in Centimeter. Return the radius to the new unit size. WIP! Changing to shapeSize cluster setup """ newRadius = origRadius # newRadius = 1 # linearUnit = cmds.currentUnit(query=True, linear=True, fullName=True) # # centimeter # if linearUnit == defaultUnit: # newRadius = origRadius # elif linearUnit == "meter": # newRadius = origRadius*0.01 # elif linearUnit == "millimeter": # newRadius = origRadius*10 # elif linearUnit == "inch": # newRadius = origRadius*0.393701 # elif linearUnit == "foot": # newRadius = origRadius*0.032808 # elif linearUnit == "yard": # newRadius = origRadius*0.010936 return newRadius #@utils.profiler
Example #5
Source File: cluster.py From maya-spline-ik with GNU General Public License v3.0 | 5 votes |
def getClusterPosition(cluster): """ Get the origin position of a cluster, positions are rounded to 6 decimals to be able to match positions. :param str cluster: :return: origin position of cluster :rtype: list """ pos = cmds.getAttr("{0}.origin".format(cluster))[0] return [round(p, 6) for p in pos] # ----------------------------------------------------------------------------
Example #6
Source File: modeling.py From SISideBar with MIT License | 5 votes |
def copy(self, mesh): self.cluster_list = [] self.point_dict = {} self.cls_weight_dict = {} dummy = common.TemporaryReparent().main(mode='create') common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='cut') cluster = cmds.ls(cmds.listHistory(mesh), type='cluster', l=True) for cls in cluster: set_node = cmds.ls(cmds.listHistory(cls, f=True), type='objectSet', l=True)[0] cmds.select(set_node) vertices = cmds.ls(sl=True) vertices = cmds.filterExpand(vertices, sm=31) cmds.select(vertices, r=True) try: weights = cmds.percent(cls, q=True, v=True) print weights #値が取れないときアンドゥするとなぜか直ることがある except Exception as e: print e.message cmds.delete(cls) cmds.undo() set_node = cmds.ls(cmds.listHistory(cls, f=True), type='objectSet', l=True)[0] vertices = cmds.ls(sl=True) vertices = cmds.filterExpand(vertices, sm=31) cmds.select(vertices, r=True) weights = cmds.percent(cls, q=True, v=True) self.cluster_list.append(cls) self.cls_weight_dict[cls] = weights self.point_dict[cls] = vertices common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='parent')#コピーのおわったメッシュの子供を元に戻す common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除 return self.point_dict, self.cls_weight_dict
Example #7
Source File: modeling.py From SISideBar with MIT License | 5 votes |
def paste(self, mesh): if not self.cluster_list: return for cls in self.cluster_list: weights = self.cls_weight_dict[cls] print 'paste cls :',cls cmds.select(cl=True) points = self.point_dict[cls] newcls = cmds.cluster(points, n=cls) for i, v in enumerate(points): cmds.percent(newcls[0], v, v=(weights[i])) return newcls #ポリゴンメッシュをウェイト付きで複製する関数
Example #8
Source File: ml_softWeights.py From ml_tools with MIT License | 5 votes |
def softSelectionClusterWeights(*args): sel = mc.ls(sl=True, o=True) if not sel: raise RuntimeError('Please select some vertices.') weights = getSoftSelectionWeights() if not weights: raise RuntimeError('Please select some vertices.') #get manipulator position for pivot mc.setToolTo('Move') moveMode = mc.manipMoveContext('Move', query=True, mode=True) mc.manipMoveContext('Move', edit=True, mode=0) position = mc.manipMoveContext('Move', query=True, position=True) mc.manipMoveContext('Move', edit=True, mode=moveMode) clusterNode, clusterHandle = mc.cluster(sel[0]) for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True): weight = 0.0 if vert in weights.keys(): weight = weights[vert] mc.percent(clusterNode, vert, v=weight) #set cluster pivot mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2])) clusterShape = mc.listRelatives(clusterHandle, c=True, s=True) mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2])
Example #9
Source File: modeling.py From SIWeightEditor with MIT License | 5 votes |
def copy(self, mesh): self.cluster_list = [] self.point_dict = {} self.cls_weight_dict = {} dummy = common.TemporaryReparent().main(mode='create') common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='cut') cluster = cmds.ls(cmds.listHistory(mesh), type='cluster', l=True) for cls in cluster: set_node = cmds.ls(cmds.listHistory(cls, f=True), type='objectSet', l=True)[0] cmds.select(set_node) vertices = cmds.ls(sl=True) vertices = cmds.filterExpand(vertices, sm=31) cmds.select(vertices, r=True) try: weights = cmds.percent(cls, q=True, v=True) print weights #値が取れないときアンドゥするとなぜか直ることがある except Exception as e: print e.message cmds.delete(cls) cmds.undo() set_node = cmds.ls(cmds.listHistory(cls, f=True), type='objectSet', l=True)[0] vertices = cmds.ls(sl=True) vertices = cmds.filterExpand(vertices, sm=31) cmds.select(vertices, r=True) weights = cmds.percent(cls, q=True, v=True) self.cluster_list.append(cls) self.cls_weight_dict[cls] = weights self.point_dict[cls] = vertices common.TemporaryReparent().main(mesh, dummyParent=dummy, mode='parent')#コピーのおわったメッシュの子供を元に戻す common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除 return self.point_dict, self.cls_weight_dict
Example #10
Source File: modeling.py From SIWeightEditor with MIT License | 5 votes |
def paste(self, mesh): if not self.cluster_list: return for cls in self.cluster_list: weights = self.cls_weight_dict[cls] print 'paste cls :',cls cmds.select(cl=True) points = self.point_dict[cls] newcls = cmds.cluster(points, n=cls) for i, v in enumerate(points): cmds.percent(newcls[0], v, v=(weights[i])) return newcls #ポリゴンメッシュをウェイト付きで複製する関数
Example #11
Source File: cluster.py From maya-spline-ik with GNU General Public License v3.0 | 4 votes |
def clusterCurve(curve, name): """ Create a cluster on each cv of a curve. :param str curve: :param str name: :return: List of created clusters :rtype: list of strings """ clusters = [] # get num cvs on curve num = numCVs(curve) # create clusters for i in range(num): # create cluster clusterShape, clusterTransform = cmds.cluster( "{0}.cv[{1}]".format( curve, i ) ) # rename shape and transform clusterShape = cmds.rename( clusterShape, "{0}_clusterShape_{1:03d}".format(name, i+1) ) clusterTransform = cmds.rename( clusterTransform, "{0}_cluster_{1:03d}".format(name, i+1) ) # set and lock visibility cmds.setAttr("{0}.visibility".format(clusterTransform), 0) cmds.setAttr("{0}.visibility".format(clusterTransform), lock=True) # store transform clusters.append(clusterTransform) return clusters