当前位置: 首页>>代码示例>>Python>>正文


Python cmds.duplicate方法代码示例

本文整理汇总了Python中maya.cmds.duplicate方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.duplicate方法的具体用法?Python cmds.duplicate怎么用?Python cmds.duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.duplicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: convert_edge_lock

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def convert_edge_lock():
    sel = cmds.ls(sl=True, l=True)
    meshes = common.search_polygon_mesh(sel, serchChildeNode=False)
    if not meshes:
        return
    for mesh in meshes:
        d_mesh = cmds.duplicate(mesh, rr=True)[0]
        modeling.setSoftEdge(mesh, angle=120)
        cmds.transferAttributes(d_mesh, mesh,
                                flipUVs=0, 
                                transferPositions=0, 
                                transferUVs=0, 
                                sourceUvSpace="map1", 
                                searchMethod=3, 
                                transferNormals=1, 
                                transferColors=0, 
                                targetUvSpace="map1", 
                                colorBorders=1, 
                                sampleSpace=5)
        freeze.main(mesh)
        cmds.polyNormalPerVertex(mesh, ufn=True)
        cmds.delete(d_mesh)
    cmds.select(meshes) 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:25,代码来源:normal.py

示例2: cloneMeshs

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def cloneMeshs(meshPaths):
    cloneMeshPaths = []
    cloneGroup = cmds.group(empty = True, world = True, name = 'ssdsResult')
    cloneGroupSL = om.MGlobal.getSelectionListByName(cloneGroup)
    cloneGroupFn = om.MFnTransform(cloneGroupSL.getDagPath(0))
    for path in meshPaths:
        mesh = om.MFnMesh(path)
        meshName = om.MFnDagNode(mesh.parent(0)).name()
        cloneMeshName = 'ssds:' + meshName
        sl = om.MSelectionList();
        sl.clear()
        sl.add(path)
        om.MGlobal.setActiveSelectionList(sl)
        cmds.duplicate(returnRootsOnly = True, name = cloneMeshName, renameChildren = True)
        cmds.parent(cloneMeshName, cloneGroup)
        cmds.setAttr(cloneMeshName + '.inheritsTransform', False)
        cloneMeshSL = om.MGlobal.getSelectionListByName(cloneMeshName)
        cloneMeshPath = cloneMeshSL.getDagPath(0)
        cloneMeshPath.extendToShape()
        cloneMeshPaths.append(cloneMeshPath)
    return cloneMeshPaths, cloneGroup 
开发者ID:TomohikoMukai,项目名称:ssds,代码行数:23,代码来源:main.py

示例3: snap

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def snap(node, snapTo):

    #duplicate the node we want snap
    dup = mc.duplicate(node, parentOnly=True)[0]
    #unlock translates and rotates
    for a in ('.t','.r'):
        for b in 'xyz':
            mc.setAttr(dup+a+b, lock=False)

    mc.parentConstraint(snapTo, dup)

    for a in ('.t','.r'):
        for b in ('x','y','z'):
            try:
                mc.setAttr(node+a+b, mc.getAttr(dup+a+b))
            except StandardError:
                pass

    mc.delete(dup) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:21,代码来源:ml_puppet.py

示例4: dup_polygon_mesh

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def dup_polygon_mesh(self):
        dup_objs = []
        for node in self.copy_mesh:
            #子供のノード退避用ダミーペアレントを用意
            dummy = common.TemporaryReparent().main(mode='create')
            common.TemporaryReparent().main(node,dummyParent=dummy, mode='cut')
            #複製
            dup = cmds.duplicate(node, rc=True)[0]
            cmds.bakePartialHistory(dup, pc=True)
            dup_objs.append(dup)
            #ウェイト転送
            weight.WeightCopyPaste().main(node, mode='copy', saveName=__name__, weightFile=node)
            weight.WeightCopyPaste().main(dup, mode='paste', saveName=__name__, weightFile=node)
            cmds.bakePartialHistory(dup, ppt=True)
            #親子付けを戻す
            common.TemporaryReparent().main(node,dummyParent=dummy, mode='parent')
            #ダミーペアレントを削除
            common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
        #cmds.select(dup_objs)
        return dup_objs 
开发者ID:ShikouYamaue,项目名称:SIWeightEditor,代码行数:22,代码来源:weight_transfer_multiple.py

示例5: sqCreateStikyLipsDeformers

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def sqCreateStikyLipsDeformers(self, *args):
        baseMesh = None
        mainCurveList = [self.mainCurveA, self.mainCurveB]
        for mainCurve in mainCurveList:
            if baseMesh == None:
                baseMesh = cmds.duplicate(self.receptList[0], name=self.receptList[0]+"Base")[0]
                cmds.setAttr(baseMesh+".visibility", 0)
            
            wrapNode = cmds.deformer(mainCurve, name="StickyLips_Wrap", type="wrap")[0]
            try:
                cmds.connectAttr(self.receptList[0]+".dropoff", wrapNode+".dropoff[0]", force=True)
                cmds.connectAttr(self.receptList[0]+".inflType", wrapNode+".inflType[0]", force=True)
                cmds.connectAttr(self.receptList[0]+".smoothness", wrapNode+".smoothness[0]", force=True)
                cmds.connectAttr(self.receptList[0]+"Shape.worldMesh[0]", wrapNode+".driverPoints[0]", force=True)
            except:
                pass
            
            cmds.connectAttr(baseMesh+"Shape.worldMesh[0]", wrapNode+".basePoints[0]", force=True)
            cmds.connectAttr(mainCurve+"Shape.worldMatrix[0]", wrapNode+".geomMatrix", force=True)
            cmds.setAttr(wrapNode+".maxDistance", 1)
            cmds.setAttr(wrapNode+".autoWeightThreshold", 1)
            cmds.setAttr(wrapNode+".exclusiveBind", 1)
            
        baseCurveList = [self.baseCurveA, self.baseCurveB]
        for c, baseCurve in enumerate(baseCurveList):
            wireNode = cmds.wire(self.receptList[1], name=baseCurve+"_Wire", groupWithBase=False, crossingEffect=0, localInfluence=0)[0]
            cmds.connectAttr(mainCurveList[c]+"Shape.worldSpace[0]", wireNode+".baseWire[0]", force=True)
            cmds.connectAttr(baseCurve+"Shape.worldSpace[0]", wireNode+".deformedWire[0]", force=True)
            self.wireNodeList.append(wireNode)
            
            wireLocList = []
            for i in range(0, self.maxIter):
                wireLocList.append(baseCurve+".u["+str(i)+"]")
            cmds.dropoffLocator(1, 1, wireNode, wireLocList) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:36,代码来源:sqStickyLipsSetup.py

示例6: duplicateModule

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def duplicateModule(self, *args):
        """ This module will just do a simple duplicate from Maya because we have a scriptJob to do the creating a new instance setup.
        """
        cmds.duplicate(self.moduleGrp) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:6,代码来源:dpBaseClass.py

示例7: zeroOut

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def zeroOut(transformList=[], offset=False):
    """ Create a group over the transform, parent the transform in it and set zero all transformations of the transform node.
        If don't have a transformList given, try to get the current selection.
        If want to create with offset, it'll be a, offset group between zeroGrp and transform.
        Return a list of names of the zeroOut groups.
    """
    zeroList = []
    if not transformList:
        transformList = cmds.ls(selection=True)
    if transformList:
        for transform in transformList:
            zeroGrp = cmds.duplicate(transform, name=transform+'_Zero_Grp')[0]
            zeroUserAttrList = cmds.listAttr(zeroGrp, userDefined=True)
            if zeroUserAttrList:
                for zUserAttr in zeroUserAttrList:
                    try:
                        cmds.deleteAttr(zeroGrp+"."+zUserAttr)
                    except:
                        pass
            allChildrenList = cmds.listRelatives(zeroGrp, allDescendents=True, children=True, fullPath=True)
            if allChildrenList:
                cmds.delete(allChildrenList)
            if offset:
                offsetGrp = cmds.duplicate(zeroGrp, name=transform+'_Offset_Grp')[0]
                cmds.parent(transform, offsetGrp, absolute=True)
                cmds.parent(offsetGrp, zeroGrp, absolute=True)
            else:
                cmds.parent(transform, zeroGrp, absolute=True)
            zeroList.append(zeroGrp)
    return zeroList 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:32,代码来源:dpUtils.py

示例8: duplicate_with_skin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def duplicate_with_skin(nodes, parentNode=None):
    #親子付けがあってもエラーはかないように修正
    print nodes
    # リストタイプじゃなかったらリストに変換する
    if not isinstance(nodes, list):
        nodes = [nodes]
    dupObjs = []
    for node in nodes:
        #子供のノード退避用ダミーペアレントを用意
        dummy = common.TemporaryReparent().main(mode='create')
        common.TemporaryReparent().main(node,dummyParent=dummy, mode='cut')
        #複製
        dup = cmds.duplicate(node)[0]
        #ウェイト転送メソッドをSimpleWeightコピペに変更
        weight.SimpleWeightCopyPaste().main(node, mode='copy', saveName=__name__, weightFile=node)
        weight.SimpleWeightCopyPaste().main(dup, mode='paste', saveName=__name__, weightFile=node)
        #親子付けを戻す
        common.TemporaryReparent().main(node,dummyParent=dummy, mode='parent')
        #ダミーペアレントを削除
        common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
        if parentNode is not None:
            cmds.parent(dup, parentNode)
        dupObjs.append(dup)
    return dupObjs
    
#シーン内、もしくは入力メッシュ内にゼロポリゴンオブジェクトがあるかどうか調べる関数 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:28,代码来源:modeling.py

示例9: createMush

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def createMush(self):
        mesh = self.sourceField.text()
        if not mesh:
            return
        if cmds.objExists(mesh + '_Mush'):
            print(mesh + '_Mush already exists!')
            return
        cmds.currentTime(cmds.playbackOptions(q=True, min=True))
        dup = cmds.duplicate(mesh, inputConnections=True, n=mesh + '_Mush')
        cmds.deltaMush(dup, smoothingIterations=20, smoothingStep=0.5, pinBorderVertices=True, envelope=1) 
开发者ID:duncanskertchly,项目名称:dm2skin,代码行数:12,代码来源:dm2skin.py

示例10: setUp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def setUp(self):
        self.start_joint = cmds.joint(p=(-0.3, -0.5, 0), name="start_joint")
        self.end_joint = cmds.joint(p=(0.5, 2.0, 0), name="end_joint")
        cmds.joint(
            self.start_joint, e=True, oj="xyz", secondaryAxisOrient="yup", zso=True
        )
        cmds.setAttr("{}.jo".format(self.end_joint), 0, 0, 0)
        self.twist_joint = cmds.duplicate(self.end_joint, name="twist_joint")[0]
        cmds.delete(
            cmds.pointConstraint(self.start_joint, self.end_joint, self.twist_joint)
        )
        self.world_plug = "{}.worldMatrix[0]".format(self.twist_joint)
        self.rest_m = self.local_matrix()
        self.tx = cmds.getAttr("{}.tx".format(self.twist_joint)) 
开发者ID:chadmv,项目名称:cmt,代码行数:16,代码来源:test_cmt_twist_decomposition.py

示例11: duplicate_chain

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def duplicate_chain(start, end, prefix="", suffix="", search_for="", replace_with=""):
    """Duplicates the transform chain starting at start and ending at end.

    :param start: The start transform.
    :param end: The end transform.
    :param prefix: Prefix to add to the new chain.
    :param suffix: Suffix to add to the new chain.
    :param search_for: Search for token
    :param replace_with: Replace token
    :return: A list of the duplicated joints, a list of the original joints that were
    duplicated.
    """
    joint = end
    joints = []
    original_joints = []
    while joint:
        name = "{0}{1}{2}".format(prefix, joint, suffix)
        if search_for or replace_with:
            name = name.replace(search_for, replace_with)
        original_joints.append(joint)
        duplicate_joint = cmds.duplicate(joint, name=name, parentOnly=True)[0]
        if joints:
            cmds.parent(joints[-1], duplicate_joint)
        joints.append(duplicate_joint)
        if joint == start:
            break
        joint = cmds.listRelatives(joint, parent=True, path=True)
        if joint:
            joint = joint[0]
        else:
            raise RuntimeError("{0} is not a descendant of {1}".format(end, start))
    joints.reverse()
    original_joints.reverse()
    return joints, original_joints 
开发者ID:chadmv,项目名称:cmt,代码行数:36,代码来源:common.py

示例12: retarget

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def retarget(source, target, shapes, rbf=None, radius=0.5, stride=1):
    """Run the mesh retarget.

    :param source: Source mesh
    :param target: Modified source mesh
    :param shapes: List of meshes to retarget
    :param rbf: One of the RBF functions. See class RBF
    :param radius: Smoothing parameter for the rbf
    :param stride: Vertex stride to sample on the source mesh.  Increase to speed up
    the calculation but less accurate.
    """
    start_time = time.time()
    source_points = points_to_np_array(source, stride)
    target_points = points_to_np_array(target, stride)

    if rbf is None:
        rbf = RBF.linear
    weights = get_weight_matrix(source_points, target_points, rbf, radius)

    for shape in shapes:
        points = points_to_np_array(shape)
        n_points = points.shape[0]
        dist = get_distance_matrix(points, source_points, rbf, radius)
        identity = np.ones((n_points, 1))
        h = np.bmat([[dist, identity, points]])
        deformed = np.asarray(np.dot(h, weights))
        points = [OpenMaya.MPoint(*p) for p in deformed]
        dupe = cmds.duplicate(
            shape, name="{}_{}_{}".format(shape, radius, rbf.__name__)
        )[0]
        set_points(dupe, points)

    end_time = time.time()
    print("Transferred in {} seconds".format(end_time - start_time)) 
开发者ID:chadmv,项目名称:cmt,代码行数:36,代码来源:meshretarget.py

示例13: transfer_shapes

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def transfer_shapes(source, destination, blendshape=None):
    """Transfers the shapes on the given blendshape to the destination mesh.

    It is assumed the blendshape indirectly deforms the destination mesh.

    :param source: Mesh to transfer shapes from.
    :param destination: Mesh to transfer shapes to.
    :param blendshape: Optional blendshape node name.  If no blendshape is given, the
        blendshape on the source mesh will be used.
    :return: The new blendshape node name.
    """
    if blendshape is None:
        blendshape = get_blendshape_node(source)
        if blendshape is None:
            return
    connections = zero_weights(blendshape)
    targets = get_target_list(blendshape)
    new_targets = []
    for t in targets:
        cmds.setAttr("{}.{}".format(blendshape, t), 1)
        new_targets.append(cmds.duplicate(destination, name=t)[0])
        cmds.setAttr("{}.{}".format(blendshape, t), 0)
    cmds.delete(destination, ch=True)
    new_blendshape = cmds.blendShape(new_targets, destination, foc=True)[0]
    cmds.delete(new_targets)
    for t in targets:
        cmds.connectAttr(
            "{}.{}".format(blendshape, t), "{}.{}".format(new_blendshape, t)
        )
    restore_weights(blendshape, connections)
    return new_blendshape 
开发者ID:chadmv,项目名称:cmt,代码行数:33,代码来源:blendshape.py

示例14: testAllRotateOrdersForGimbal

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def testAllRotateOrdersForGimbal(obj):

    #duplicate node without children
    dup = mc.duplicate(obj, name='temp#', parentOnly=True)[0]

    tolerences = list()
    for roo in ROTATE_ORDERS:
        mc.xform(dup, preserve=True, rotateOrder=roo)
        tolerences.append(gimbalTolerence(dup))

    #delete node
    mc.delete(dup)

    return tolerences 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:16,代码来源:ml_convertRotationOrder.py

示例15: duplicate_with_skin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import duplicate [as 别名]
def duplicate_with_skin(nodes, parentNode=None):
    #親子付けがあってもエラーはかないように修正
    #print nodes
    # リストタイプじゃなかったらリストに変換する
    if not isinstance(nodes, list):
        nodes = [nodes]
    dupObjs = []
    for node in nodes:
        #子供のノード退避用ダミーペアレントを用意
        dummy = common.TemporaryReparent().main(mode='create')
        common.TemporaryReparent().main(node,dummyParent=dummy, mode='cut')
        #複製
        dup = cmds.duplicate(node)[0]
        #ウェイト転送メソッドをSimpleWeightコピペに変更
        weight.SimpleWeightCopyPaste().main(node, mode='copy', saveName=__name__, weightFile=node)
        weight.SimpleWeightCopyPaste().main(dup, mode='paste', saveName=__name__, weightFile=node)
        #親子付けを戻す
        common.TemporaryReparent().main(node,dummyParent=dummy, mode='parent')
        #ダミーペアレントを削除
        common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
        if parentNode is not None:
            cmds.parent(dup, parentNode)
        dupObjs.append(dup)
    return dupObjs
    
#シーン内、もしくは入力メッシュ内にゼロポリゴンオブジェクトがあるかどうか調べる関数 
开发者ID:ShikouYamaue,项目名称:SIWeightEditor,代码行数:28,代码来源:modeling.py


注:本文中的maya.cmds.duplicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。