當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.cluster方法代碼示例

本文整理匯總了Python中maya.cmds.cluster方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.cluster方法的具體用法?Python cmds.cluster怎麽用?Python cmds.cluster使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.cluster方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: shapeSizeSetup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:20,代碼來源:dpControls.py

示例2: ui

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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.') 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:18,代碼來源:ml_softWeights.py

示例3: sqCreateClusters

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:7,代碼來源:sqStickyLipsSetup.py

示例4: dpCheckLinearUnit

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:29,代碼來源:dpControls.py

示例5: getClusterPosition

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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]


# ---------------------------------------------------------------------------- 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:16,代碼來源:cluster.py

示例6: copy

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:36,代碼來源:modeling.py

示例7: paste

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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
        
#ポリゴンメッシュをウェイト付きで複製する関數 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:16,代碼來源:modeling.py

示例8: softSelectionClusterWeights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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]) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:33,代碼來源:ml_softWeights.py

示例9: clusterCurve

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import cluster [as 別名]
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 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:44,代碼來源:cluster.py


注:本文中的maya.cmds.cluster方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。