1

リストされたオブジェクトがブレンドシェイプ ノードであるかどうかを Maya に確認させようとしています。

これは私のコードです:

def bake(self, *args):
    self.items["selection"] = cmds.ls(sl = True)
    self.items["shapes"] = cmds.listRelatives(self.items["selection"], ad = True)
    shapes = ()
    for i in self.items["shapes"]:
        bs = cmds.listConnections(i, type = "blendShape", exactType = True)
        if cmds.objectType(bs, isType = "blendShape"):
            print bs

戻る# Error: RuntimeError: file X:/Documents/maya/scripts\jtBakeCharacter.py line 16: No object name specified

16 行目は次のとおりです。if cmds.objectType(bs, isType = "blendShape"):

オブジェクト名を指定していることを除いて、そのオブジェクト名は bs .. bs の結果を出力しましたが、多くのオブジェクトがリストされています。たくさんの。

4

3 に答える 3

1

Joojaa の答えはエレガントですが、デフォルトの選択動作を使用すると、さらに短くすることができます。

blendshapes = cmds.ls(cmds.listHistory(pdo=True), type='blendShape') or []
for item in blendshapes:
    print item

(さらに短くするために、選択をチェックしていないため、何も選択されていない場合、これは失敗します)。

PS: 変形されたシェイプではなく、上流のシェイプの 1 つからブレンドシェイプに到達する必要がある場合は、listHistory (f=True) を使用できます。

于 2013-05-15T05:54:50.613 に答える
0

これを試すことができます:

from pymel.core import *

for obj in selected():
    shapeNode = obj.getChildren()[0]
    for output in shapeNode.outputs():
        if nodeType(output) == "blendShape":
            print obj, "is a blendshape"
于 2013-05-07T22:28:38.960 に答える