本文整理汇总了Python中maya.cmds.cluster函数的典型用法代码示例。如果您正苦于以下问题:Python cluster函数的具体用法?Python cluster怎么用?Python cluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cluster函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RMCreateLineBetwenPoints
def RMCreateLineBetwenPoints (self, Point1, Point2):
Curve = cmds.curve (degree=1, p=[[0,0,0],[1,0,0]], name = "curveLineBetweenPnts")
Curve = self.NameConv.RMRenameBasedOnBaseName(Point1, Curve, NewName = Curve)
NumCVs = cmds.getAttr (Curve + ".controlPoints" , size = True)
Cluster1, Cluster1Handle = cmds.cluster (Curve+".cv[0]", relative=True, name = "clusterLineBetweenPnts")
Cluster1 = self.NameConv.RMRenameBasedOnBaseName(Point1 , Cluster1, NewName = Cluster1)
Cluster1Handle = self.NameConv.RMRenameBasedOnBaseName(Point1 , Cluster1Handle, NewName = Cluster1Handle)
Cluster2, Cluster2Handle = cmds.cluster (Curve+".cv[1]", relative=True, name = "clusterLineBetweenPnts")
Cluster2 = self.NameConv.RMRenameBasedOnBaseName(Point2 , Cluster2, NewName = Cluster2)
Cluster2Handle = self.NameConv.RMRenameBasedOnBaseName(Point2 , Cluster2Handle, NewName = Cluster2Handle)
cmds.setAttr(Curve+".overrideEnabled",1)
cmds.setAttr(Curve+".overrideDisplayType",1)
RMAlign (Point1, Cluster1Handle, 1)
RMAlign (Point2, Cluster1Handle, 1)
PointConstraint1 = cmds.pointConstraint (Point1, Cluster1Handle, name = "PointConstraintLineBetweenPnts")[0]
PointConstraint1 = self.NameConv.RMRenameBasedOnBaseName(Point1 , PointConstraint1, NewName = PointConstraint1)
PointConstraint2 = cmds.pointConstraint (Point2, Cluster2Handle, name = "PointConstraintLineBetweenPnts")[0]
PointConstraint2 = self.NameConv.RMRenameBasedOnBaseName(Point2 , PointConstraint2, NewName = PointConstraint2)
DataGroup = cmds.group (em = True,name = "DataLineBetweenPnts")
DataGroup = self.NameConv.RMRenameBasedOnBaseName(Point1 , DataGroup, NewName = DataGroup)
cmds.parent (Cluster1Handle, DataGroup)
cmds.parent (Cluster2Handle, DataGroup)
cmds.parent (Curve, DataGroup)
return DataGroup , Curve
示例2: __init__
def __init__(self, objs = [], vertices = []):
self.objs = objs
self.vertices = vertices
#lattice -divisions 2 3 2 -objectCentered true -ol 1;
#mc.select( self.objs, self.vertices )
#CREATION
grp = mn.Node( mc.group( n = "head_toon_GRP", em = True ) )
deGrp = mn.Node( mc.group( n = "head_toon_deformer_GRP", em = True ) )
deGrp.parent = grp
deGrp.a.v.v = False
deGrp.a.v.locked = True
latNods = mc.lattice( self.objs, self.vertices, divisions = [ 2,3,2], objectCentered = True, ol = 1, n = 'head_toon_LAT' )
latBase = mn.Node( latNods[2] )
latBase.parent = deGrp
lat = mn.Node( latNods[1] )
lat.parent = deGrp
#mc.select( lat + ".pt[0:1][2][0]", lat + ".pt[0:1][2][1]" )
topClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][2][0]", lat.shape.name + ".pt[0:1][2][1]", n = 'top_face_toon_CLU' )[1] )
topClus.a.v.v = False
topClus.a.v.locked = True
#mc.select( lat + ".pt[0:1][1][0]", lat + ".pt[0:1][1][1]" )
midClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][1][0]", lat.shape.name + ".pt[0:1][1][1]", n = 'mid_face_toon_CLU' )[1] )
#mc.select( lat + ".pt[0:1][0][0]", lat + ".pt[0:1][0][1]" )
lowClus = mn.Node( mc.cluster( lat.shape.name + ".pt[0:1][0][0]", lat.shape.name + ".pt[0:1][0][1]", n = 'low_face_toon_CLU' )[1] )
ctl = crv.Curve( "head_toon_CTL" )
ctl = ctl.create( "sphere" )
ctl.a.t.v = topClus.worldPosition
mc.makeIdentity( ctl.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
topClus.parent = ctl
midClus.parent = deGrp
lowClus.parent = deGrp
ctl.parent = grp
#CONSTRAINS
midClus.a.r >> topClus.a.r
mc.pointConstraint( topClus.name, lowClus.name, midClus.name, mo = True )
#SCALE FOR MID CLUSTER
dist = mn.createNode( 'distanceBetween', n = 'head_toon_DIS' )
ctl.a.worldMatrix >> dist.a.inMatrix1
ctl.a.rp >> dist.a.point1
lowClus.a.worldMatrix >> dist.a.inMatrix2
lowClus.a.rp >> dist.a.point2
mul = mn.createNode( 'multiplyDivide', n = 'head_toon_scale_MUL' )
mul.a.input1.v = [dist.a.distance.v]*3
mul.a.operation.v = 2
dist.a.distance >> mul.a.input2X
dist.a.distance >> mul.a.input2Y
dist.a.distance >> mul.a.input2Z
mul.a.output >> midClus.a.s
#AIM CONSTRAINT
upLocGrp = mn.Node( mc.group( n = "head_upVector_GRP", em = True ) )
upLocGrp.a.t.v = midClus.worldPosition
mc.makeIdentity( upLocGrp.name, apply = True, t = 1, r = 1, s = 1, n = 2 )
upLocGrp.parent = deGrp
mc.orientConstraint( ctl.name, lowClus.name, upLocGrp.name, mo = True )
upLoc = mn.Node( mc.spaceLocator( n = 'head_upVector_LOC' )[0] )
upLoc.a.t.v = midClus.worldPosition
upLoc.a.tz.v = upLoc.a.tz.v + 5
mc.aimConstraint( topClus.name, midClus.name, mo = True, weight = 1, aimVector = [1, 0, 0], upVector = [0, 1, 0], worldUpType = "object", worldUpObject = upLoc.name )
upLoc.parent = upLocGrp
mc.pointConstraint( topClus.name, lowClus.name, upLoc.name, mo = True )
示例3: autoEyebrowGuidePosition
def autoEyebrowGuidePosition(side = None, guideName = None):
objectName = side + "_" + guideName
sel = cmds.ls(os = 1, flatten = 1)
pos = []
cluster = []
# check which type of component is selected and store the position
for t in sel:
i = t
selType = t.split(".")[1][0]
if selType == "e":
vtx = cmds.polyListComponentConversion(i, fe = 1, tv = 1)
cmds.select(vtx)
cls = cmds.cluster()
clsPos = cmds.xform(cls, query = 1, rotatePivot = 1, worldSpace = 1)
pos.append(clsPos)
cluster.append(cls)
elif selType == "f":
vtx = cmds.polyListComponentConversion(i, ff = 1, tv = 1)
cmds.select(vtx)
cls = cmds.cluster()
clsPos = cmds.xform(cls, query = 1, rotatePivot = 1, worldSpace = 1)
pos.append(clsPos)
cluster.append(cls)
elif selType == "v":
cmds.warning("Select in another component mode! We are out of verts dude!!!")
else:
cmds.warning("No components selected dude!!!")
# check if guide group exists
if cluster:
if cmds.objExists(objectName + "_TRN"):
cmds.delete(objectName + "_TRN")
# create the guides
guides = defGuideCmds.defGuideCrv()
guides.__init__(nSpans = len(cluster)-1, curveDegree = 1, offset =.2, offsetVector = [1,0,0], side = side, name = guideName, startPosition = [0,0,0], ctlSize = 10)
cmds.delete("C_curve_TRN")
# delete the cluster
for c in cluster:
cmds.delete(c)
# list all the guides inside the guideName group except the curve
loc = cmds.listRelatives(objectName + "_TRN", allDescendents = 1, type = "transform")[:-1]
# reposition the guides at the vertices place
for i, p in zip(loc, pos):
cmds.xform(i, translation = p, worldSpace = 1)
# mirror the guides
cmds.select(loc)
guides.createMirror()
示例4: RMCreateClustersOnCurve
def RMCreateClustersOnCurve(self , curve = None):
if curve.__class__ in [str,unicode]:
masterCurve = curve
mode = "single"
#print ("degree:%s",degree)
#print ("spans:%s",spans)
#print ("form:%s",form)
elif curve.__class__ == list:
masterCurve = curve[0]
mode = "multi"
degree = cmds.getAttr (masterCurve + ".degree")
spans = cmds.getAttr (masterCurve + ".spans")
form = cmds.getAttr (masterCurve + ".form")
# Form (open = 0, closed = 1, periodic = 2)
clusterList=[]
if form == 0 or form ==1:
#print "Open Line"
for i in range(0 , (degree + spans)):
cluster = cmds.cluster(masterCurve + ".cv["+str(i)+"]",name=self.NameConv.RMUniqueName ("Character_MD_ClusterOnCurve_cls_rig"))
if mode == "multi":
self.RMAddToCluster(i , curve[1:],cluster)
clusterList.append(cluster[1])
cmds.setAttr(cluster[1]+".visibility",0)
##cmds.cluster(cluster,edit=True,geometry = curve + ".["+str(i)+"]")
if form == 2:
#print "periodic Line"
for i in range(0,spans):
cluster = cmds.cluster(masterCurve+".cv["+str(i)+"]" ,name = self.NameConv.RMUniqueName ("Character_MD_ClusterOnCurve_cls_rig"))
if mode == "multi":
self.RMAddToCluster(i , curve[1:], cluster)
clusterList.append(cluster[1])
cmds.setAttr(cluster[1]+".visibility",0)
#cmds.cluster(cluster,edit=True,geometry = curve + ".["+str(i)+"]")
return clusterList
示例5: rebuild
def rebuild(self):
'''
Rebuild the cluster deformer from the recorded deformerData
'''
# Check target geometry
for obj in self.deformerData.iterkeys():
if not mc.objExists(obj): raise UserInputError('Object '+obj+' does not exist!')
# Check deformer
if mc.objExists(self.deformerName):
raise UserInputError('Cluster '+self.deformerName+' already exists!')
# Rebuild deformer
cluster = None
if mc.objExists(self.handle):
cluster = mc.cluster(self.getMemberList(),n=self.deformerName,wn=(self.handle,self.handle))
else:
cluster = mc.cluster(self.getMemberList(),n=self.deformerName)
if cluster[1] != self.handle: mc.rename(cluster[1],self.handle)
deformer = cluster[0]
# Connect bindPreMatrix
if self.bindPreMatrix:
if mc.objExists(self.bindPreMatrix[0]):
mc.connectAttr(self.bindPreMatrix[0],cluster+'.bindPreMatrix')
# Connect geomMatrix
for conn in self.geomMatrix.iterkeys():
if mc.objExists(conn):
mc.connectAttr(conn+'.'+self.geomMatrix[conn][0],cluster+'.geomMatrix['+str(self.geomMatrix[conn][1])+']')
# Set cluster weights
self.loadWeights()
# Return result
return deformer
示例6: cameraFrustum_build
def cameraFrustum_build(cam_shape):
#make sure a camera is loaded
if cam_shape==0:
cmds.error('no camera loaded...select a camera and load')
else:
#create frustum only if one doesnt already exist
selCamXform = cmds.listRelatives(cam_shape[0], p=1)
prefix = 'frust_'
frustumGrpName = prefix + 'camera_frustum_all_grp'
if cmds.objExists(frustumGrpName)==0:
#create main grp
frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)
#create frustum geo
frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
cmds.delete(frustumGeo[0], constructionHistory=True)
cmds.parent(frustumGeo[0], frustumMainGrp)
#load plugin "nearestPointOnMesh.mll" if needed and connect
plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
if plugin==0:
cmds.loadPlugin('nearestPointOnMesh.mll')
nearNodeName = prefix + 'npomNode'
npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')
#create clusters
cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')
#create near/far/camera locs
cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
cmds.parent(cameraLoc[0], frustumMainGrp)
nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
cmds.move(0, 0, -1)
farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
cmds.move(0, 0, 1)
#parent clusters under loc -- parent locs under camera loc
cmds.parent(nearCluster[1], nearLoc[0])
cmds.parent(farCluster[1], farLoc[0])
cmds.parent(nearLoc[0], cameraLoc[0])
cmds.parent(farLoc[0], cameraLoc[0])
#constrain camera loc to camera
cmds.parentConstraint(selCamXform, cameraLoc, weight=1)
return frustumGeo[0]
示例7: create_ik
def create_ik(self):
"""Ik spline"""
# Create curve
tmp_curve = curve.create_from_nodes(self.joints, name=name.set_suffix(self.name, 'ikCrv'), degree=3)
self.curve = curve.rebuild_curve(tmp_curve, 3)[0]
start_joint, end_joint = self.ik_joints[0], self.ik_joints[-1]
logger.info("Creating Ik using nodes: %s" % self.joints)
self.ik, self.effector = cmds.ikHandle(name=name.set_suffix(self.name, 'ikh'), sj=start_joint, ee=end_joint, curve=self.curve, createCurve=False, sol="ikSplineSolver", ns=3)
# Add to setups
self.setups.extend([self.ik, self.curve])
# Set attrs
cmds.setAttr("%s.dTwistControlEnable" % self.ik, 1)
cmds.setAttr("%s.dWorldUpAxis" % self.ik, 1)
cmds.setAttr("%s.dWorldUpType" % self.ik, 4)
cmds.setAttr("%s.dWorldUpVector" % self.ik, 1.0, 0.0, 0.0, type="float3")
cmds.setAttr("%s.dWorldUpVectorEnd" % self.ik, 1.0, 0.0, 0.0, type="float3")
# Turn on cvs
cmds.select(self.curve, r=True)
cmds.toggle(cv=True)
# Create clusters
clusters = OrderedDict()
clusters['bot'] = cmds.cluster(["%s.cv[0]" % self.curve, "%s.cv[1]" % self.curve])[1]
clusters['mid'] = cmds.cluster(["%s.cv[2]" % self.curve, "%s.cv[3]" % self.curve])[1]
clusters['top'] = cmds.cluster(["%s.cv[4]" % self.curve, "%s.cv[5]" % self.curve])[1]
xform.match_pivot(start_joint, clusters['bot'])
xform.match_pivot(end_joint, clusters['top'])
self.clusters = clusters
示例8: parent_cluster
def parent_cluster(cluster_name):
cluster_parent = cmds.textField('UI_cluster_clusterName', q=True, tx=True)
cluster_parent = cluster_parent.replace (" ", "_")
cluster_parent = cmds.createNode( 'transform', n= 'trn_' + cluster_parent, ss=True)
centre = cmds.objectCenter("loc_guide_deformer", gl=True)
cmds.move(centre[0], centre[1], centre[2], cluster_parent)
cmds.cluster (name = cluster_name, bs = True, wn = (cluster_parent, cluster_parent))
cmds.delete("loc_guide_deformer")
示例9: crvGuide
def crvGuide( ctrl = '' , target = '' ) :
# Create NURBs curve between control and target
# Returns : curve and two clusters
crv = pc.Dag( mc.curve( d = 1 , p = [ ( 0 , 0 , 0 ) , ( 0 , 0 , 0 ) ] ) )
clstr1 = pc.Dag( mc.cluster( '%s.cv[0]' % crv , wn = ( ctrl , ctrl ) )[ 0 ] )
clstr2 = pc.Dag( mc.cluster( '%s.cv[1]' % crv , wn = ( target , target ) )[ 0 ] )
mc.select( cl = True )
return crv , clstr1 , clstr2
示例10: rebuild
def rebuild(self, overrides={}):
"""
Rebuild the cluster deformer from the recorded deformerData
@param overrides: Dictionary of data overrides to apply
@type overrides: dict
"""
# Apply Overrides
self._data.update(overrides)
# ==========
# - Checks -
# ==========
# Check target geometry
for obj in self._data["affectedGeometry"]:
if not mc.objExists(obj):
raise Exception('Deformer affected object "' + obj + '" does not exist!')
# ====================
# - Rebuild Deformer -
# ====================
# Build Cluster Deformer and Handle
if not mc.objExists(self._data["name"]):
# Create New Cluster
cluster = mc.cluster(self.getMemberList(), n=self._data["name"])
self._data["name"] = cluster[0]
else:
# Check Cluster
if mc.objectType(self._data["name"]) != "cluster":
raise Exception('Object "' + self._data["name"] + '" is not a valid cluster deformer!')
# Rebuild Deformer
result = super(ClusterData, self).rebuild(overrides)
# Restore ClusterHandle Data
if self._data["clusterHandle"]:
if not mc.objExists(self._data["clusterHandle"]):
raise Exception('Weighted Node "' + self._data["clusterHandle"] + '" does not exist!')
try:
mc.cluster(
self._data["name"],
edit=True,
bindState=True,
wn=(self._data["clusterHandle"], self._data["clusterHandle"]),
)
except:
pass
# =================
# - Return Result -
# =================
return result
示例11: pvLine
def pvLine(name, icon, joint):
j=mel.eval('curve -d 1 -p 0 0 0 -p 1 0 0 -k 0 -k 1 ;')
k=cmds.rename(name)
c1=cmds.cluster('%s.cv[0]' % k, n='%s_cluster' % k)
c2=cmds.cluster('%s.cv[1]' % k, n='%s_cluster' % k)
cmds.parentConstraint(icon, c1, mo=0)
cmds.parentConstraint(joint, c2, mo=0)
i=cmds.group(k,c1,c2, n='%s_pad' % name)
cmds.setAttr('%sHandle.visibility' % c1[0], 0)
cmds.setAttr('%sHandle.visibility' % c2[0], 0)
cmds.setAttr('%sShape.overrideDisplayType' % k, 2)
cmds.setAttr('%sShape.overrideEnabled' % k, 1)
return i
示例12: createIKCtrlsOnJnts
def createIKCtrlsOnJnts(ikCrv, parentCtrl, size=1):
ikCVNum = ll.getCurveCVCount(ikCrv)
prev=parentCtrl
for i in range(1, ikCVNum):
clus = mc.cluster('%s.cv[%d]'%(ikCrv, i), n=parentCtrl.replace('masterctrl','ikClus%d')%i)
cvPos = mc.xform('%s.cv[%d]'%(ikCrv, i), q=1, ws=1, t=1)
mc.select(parentCtrl)
meval('wireShape("plus")')
ikCtrl = mc.rename(masterCtrl.replace('masterctrl','ikCtrl%d'%i))
mc.xform(ikCtrl, t=cvPos, ws=1)
mc.scale(size, size, size, ikCtrl, ocp=1)
mc.makeIdentity(ikCtrl, a=1, s=1)
mc.parent(ikCtrl, parentCtrl)
lsZeroOut(ikCtrl)
ctrlPR = lsZeroOut(ikCtrl, 'PR')
mc.addAttr(ikCtrl, ln='SPACE', at='bool', k=1)
mc.setAttr(ikCtrl+'.SPACE', l=1)
mc.addAttr(ikCtrl, ln='parent', at='float', dv=0, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='master', at='float', dv=1, min=0, max=1, k=1)
mc.addAttr(ikCtrl, ln='world', at='float', dv=0, min=0, max=1, k=1)
mc.parentConstraint(ikCtrl, clus)
cons = mc.parentConstraint(prev, parentCtrl, ctrlPR, mo=1)[0]
wal = mc.parentConstraint(cons, q=1, wal=1)
if len(wal) > 1:
mc.connectAttr(ikCtrl+'.parent', '%s.%s'%(cons, wal[0]), f=1)
mc.connectAttr(ikCtrl+'.master', '%s.%s'%(cons, wal[1]), f=1)
prev=ikCtrl
示例13: alignJawCtrl
def alignJawCtrl() :
# Align jaw control to jaw joint.
# Select jaw control curve then jaw joint.
sels = mc.ls( sl = True )
ctrl = sels[0]
jnt = sels[1]
shp = mc.listRelatives( ctrl , shapes=True )[0]
mc.select( shp , r=True )
fstCv = 14
scdCv = 2
fstPos = mc.xform( '%s.cv[%s]' % (shp,fstCv) , q=True , ws=True , t=True )
scdPos = mc.xform( '%s.cv[%s]' % (shp,scdCv) , q=True , ws=True , t=True )
midPos = [ (fstPos[0]+scdPos[0])/2 , (fstPos[1]+scdPos[1])/2 , (fstPos[2]+scdPos[2])/2 ]
clstr = mc.cluster()[1]
mc.select( clstr , r=True )
mc.move( midPos[0] , midPos[1] , midPos[2] , '%s.rotatePivot' % clstr )
mc.move( midPos[0] , midPos[1] , midPos[2] , '%s.scalePivot' % clstr )
mc.delete( mc.pointConstraint( jnt , clstr ) )
tipJnt = mc.listRelatives( jnt , type = 'joint' )[0]
if tipJnt :
mc.delete( mc.aimConstraint(tipJnt,clstr,aim=(0,0,1),u=(1,0,0),wut='vector',wu=(1,0,0)))
示例14: on_btn_Start_clicked
def on_btn_Start_clicked(self, clicked=None):
if clicked == None:return
geometry = str(self.LET_Geometry.text())
joints = [jnt.strip() for jnt in str(self.LET_Skeleton.text()).split(',')]
joints = [jnt for jnt in joints if mc.objExists(jnt)]
self.progressBar_A.setMaximum(len(joints))
self.progressLabel_A.setText('0/%d'%len(joints))
for i, jnt in enumerate(joints):
#- create cluster
cluster = mc.cluster(geometry, rel=True)
#- copy weights
res = transSkinWeightsToCluster(geometry, geometry, jnt, cluster[0], self.progressBar_B, self.progressLabel_B)
#if res:
##- weight Node
#mc.cluster(cluster[0], e=True, wn=(jnt, jnt))
##- delete handle
#mc.delete(cluster[1])
#- progerss
self.progressBar_A.setValue(i+1)
self.progressLabel_A.setText('%d/%d'%(i+1, len(joints)))
self.progressBar_A.setValue(0)
self.progressBar_A.setMaximum(1)
self.progressLabel_A.setText('0/0')
示例15: softSelectionClusterWeights
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])