I've been looking around the internet for a solution but to no avail. I am currently trying to add a compound attribute that is index based (i.e. "object.attribute[0], object.attribute[1], object.attribute[2], etc...) similar to how vertex and uv attributes are used. Looking through the documentation it seems that there is no clear way to achieve this.
Attempts:
How I define the parent: cmds.addAttr(nodeType, ln=theParent, nc=x, at='compound')
-Usual use of the compound flag in addAttr.
-Using a for loop with string formatting:
for i in range(x):
cmds.addAttr(ln='object.attribute[%s]' %i, p=theParent)
-Eval:
for i in range(x):
mel.eval("addAttr -ln attribute["+str(i)+"] -p theParent;")
With string formatting I run into the this error.
# 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. //
This compound attribute will eventually hold an arbitrary number of Int32Array data types.
I could create my own node and create the necessary attributes through the API but I don't want to create any additional dependencies.
I apologize for any holes in my question or if something is unclear. Kindly ask and I can explain further.
Thank you.