我一直在互联网上寻找解决方案,但无济于事。我目前正在尝试添加一个基于索引的复合属性(即“object.attribute[0]、object.attribute[1]、object.attribute[2] 等...),类似于顶点和 uv 属性的方式使用过。查看文档似乎没有明确的方法来实现这一点。
尝试:我如何定义父母:cmds.addAttr(nodeType, ln=theParent, nc=x, at='compound')
- 在 addAttr 中通常使用复合标志。
- 使用带有字符串格式的 for 循环:
for i in range(x):
cmds.addAttr(ln='object.attribute[%s]' %i, p=theParent)
-评估:
for i in range(x):
mel.eval("addAttr -ln attribute["+str(i)+"] -p theParent;")
使用字符串格式,我遇到了这个错误。
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# RuntimeError: Error occurred during execution of MEL script
# line 1: Long name 'attribute[0]' contains invalid characters. //
此复合属性最终将包含任意数量的 Int32Array 数据类型。
我可以创建自己的节点并通过 API 创建必要的属性,但我不想创建任何额外的依赖项。
对于我的问题中的任何漏洞或不清楚的地方,我深表歉意。请询问,我可以进一步解释。
谢谢你。