当前位置: 首页>>代码示例>>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;未经允许,请勿转载。