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


Python cmds.blendShape方法代碼示例

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


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

示例1: dpLoadBSNode

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def dpLoadBSNode(self, *args):
        """ Load selected object as blendShapeNode
        """
        selectedList = cmds.ls(selection=True)
        if selectedList:
            if cmds.objectType(selectedList[0]) == "blendShape":
                cmds.textField(self.bsNodeTextField, edit=True, text=selectedList[0])
                self.dpLoadBSTgtList(selectedList[0])
                self.bsNode = selectedList[0]
            elif cmds.objectType(selectedList[0]) == "transform":
                meshList = cmds.listRelatives(selectedList[0], children=True, shapes=True, noIntermediate=True, type="mesh")
                if meshList:
                    bsNodeList = cmds.listConnections(meshList[0], type="blendShape")
                    if bsNodeList:
                        self.dpLoadBSTgtList(bsNodeList[0])
                        self.bsNode = bsNodeList[0]
                    else:
                        mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
                else:
                    mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
            else:
                mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
        else:
            mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:26,代碼來源:dpFacialControl.py

示例2: get_blendshape_node

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def get_blendshape_node(geometry):
    """Get the first blendshape node upstream from the given geometry.

    :param geometry: Name of the geometry
    :return: The blendShape node name
    """
    geometry = shortcuts.get_shape(geometry)
    history = cmds.listHistory(geometry, il=2, pdo=False) or []
    blendshapes = [
        x
        for x in history
        if cmds.nodeType(x) == "blendShape"
        and cmds.blendShape(x, q=True, g=True)[0] == geometry
    ]
    if blendshapes:
        return blendshapes[0]
    else:
        return None 
開發者ID:chadmv,項目名稱:cmt,代碼行數:20,代碼來源:blendshape.py

示例3: export_blendshape_targets

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def export_blendshape_targets(blendshape, directory):
    """Export all targets of a blendshape as objs.

    :param blendshape: Blendshape name
    :param directory: Directory path
    """
    connections = zero_weights(blendshape)
    targets = get_target_list(blendshape)
    base = cmds.blendShape(blendshape, q=True, g=True)[0]
    for t in targets:
        plug = "{}.{}".format(blendshape, t)
        cmds.setAttr(plug, 1)
        file_path = os.path.join(directory, "{}.obj".format(t))
        export_obj(base, file_path)
        cmds.setAttr(plug, 0)
    restore_weights(blendshape, connections) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:18,代碼來源:blendshape.py

示例4: dpLoadBSTgtList

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def dpLoadBSTgtList(self, bsNodeName, *args):
        """ Add target list found in the blendShape node to target textScroll list
        """
        if cmds.objExists(bsNodeName):
            if cmds.objectType(bsNodeName) == "blendShape":
                tgtList = cmds.blendShape(bsNodeName, query=True, target=True)
                if tgtList:
                    cmds.textScrollList(self.bsTargetScrollList, edit=True, removeAll=True)
                    cmds.textScrollList(self.bsTargetScrollList, edit=True, append=tgtList)
                    cmds.textField(self.bsNodeTextField, edit=True, text=bsNodeName)
                    self.bsNode = bsNodeName 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:13,代碼來源:dpFacialControl.py

示例5: store_blend_shape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def store_blend_shape(mesh):
    shapes = cmds.listRelatives(mesh, s=True, f=True)
    skin = cmds.ls(cmds.listHistory(shapes), type='skinCluster')
    if skin:
        connections = cmds.listConnections(skin, s=True, d=False)
    else:
        connections = cmds.listConnections(shapes, s=True, d=False)
    blend_shapes = cmds.ls(connections, l=True, type='blendShape')
    bs_dict = {}
    if blend_shapes:
        for bs in blend_shapes:
            shape_target = cmds.ls(cmds.listConnections(bs, s=True, d=False), l=True, type='transform')
            bs_dict[bs]=shape_target
        return bs_dict
    return 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:17,代碼來源:freeze.py

示例6: set_blend_shape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def set_blend_shape(mesh, bs_dict):
    if not bs_dict:
        return
    for bs, shape_target in bs_dict.items():
        cmds.blendShape(shape_target+[mesh], name=bs, frontOfChain=True) 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:7,代碼來源:freeze.py

示例7: test_get_blendshape_on_new_shape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def test_get_blendshape_on_new_shape(self):
        shape = cmds.polyCube()[0]
        blendshape = bs.get_or_create_blendshape_node(shape)
        self.assertTrue(cmds.objExists(blendshape))
        blendshapes = cmds.ls(type="blendShape")
        self.assertEqual(len(blendshapes), 1)
        self.assertEqual(blendshapes[0], blendshape)

        blendshape = bs.get_or_create_blendshape_node(shape)
        blendshapes = cmds.ls(type="blendShape")
        self.assertEqual(len(blendshapes), 1)
        self.assertEqual(blendshapes[0], blendshape) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:14,代碼來源:test_cmt_blendshape.py

示例8: test_get_blendshape_on_existing_blendshape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def test_get_blendshape_on_existing_blendshape(self):
        shape = cmds.polyCube()[0]
        blendshape = cmds.blendShape(shape)[0]
        existing_blendshape = bs.get_or_create_blendshape_node(shape)
        self.assertEqual(blendshape, existing_blendshape) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:7,代碼來源:test_cmt_blendshape.py

示例9: get_or_create_blendshape_node

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def get_or_create_blendshape_node(geometry):
    """Get the first blendshape node upstream from the given geometry or create one if
    one does not exist.

    :param geometry: Name of the geometry
    :return: The blendShape node name
    """
    geometry = shortcuts.get_shape(geometry)
    blendshape = get_blendshape_node(geometry)
    if blendshape:
        return blendshape
    else:
        return cmds.blendShape(geometry, foc=True)[0] 
開發者ID:chadmv,項目名稱:cmt,代碼行數:15,代碼來源:blendshape.py

示例10: get_target_index

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import blendShape [as 別名]
def get_target_index(blendshape, target):
    indices = cmds.getAttr("{}.w".format(blendshape), mi=True) or []
    for i in indices:
        alias = cmds.aliasAttr("{}.w[{}]".format(blendshape, i), q=True)
        if alias == target:
            return i
    raise RuntimeError(
        "Target {} does not exist on blendShape {}".format(target, blendshape)
    ) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:11,代碼來源:blendshape.py

示例11: transfer_shapes

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


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