【发布时间】:2019-06-01 17:15:00
【问题描述】:
我尝试将每个元素的所有对象类型放入 Outliner 中的组中。
这是我的代码。
from maya import cmds
objects = cmds.ls(selection=True, dag=True)
objects.sort(key=len, reverse=True)
# Now we loop through all the objects we have
for obj in objects:
# We get the shortname again by splitting at the last |
shortName = obj.split('|')[-1]
children = cmds.listRelatives(obj, children=True) or []
if len(children) > 0:
for current in children:
objType = cmds.objectType(current)
print(objType)
我收到了这个错误:
错误:RuntimeError:文件 /Users/jhgonzalez/Library/Preferences/Autodesk/maya/2018/scripts/AssigMaterialForEachMesh.py 第 26 行:没有对象匹配名称:SafetyHandle_019_allFromGun:pCylinderShape21 找不到对象“SafetyHandle_019_allFromGun:pCylinderShape21”。
我正在用这个测试这段代码
【问题讨论】:
-
您的代码没有为我产生任何错误。这是完整的脚本吗?
-
是的...但我知道问题出在哪里...问题是他们在这个场景中重复了一些网格。我解决了这些问题。