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