-
Notifications
You must be signed in to change notification settings - Fork 7
Get Array Attr Command
Ryan Porter edited this page Feb 25, 2018
·
1 revision
getArrayAttr
[attribute]
getArrayAttr is NOT undoable, NOT queryable, and NOT editable.
This command returns the values of the named object's attribute. This is only usable on attributes that are array types. Currently, the types of attributes that can be displayed are:
- angle array attributes
- double array attributes
- float array attributes
- euler array attributes
- int array attributes
- point array attributes
- quat array attributes
- matrix array attributes
- vector array attributes
Because the arrays are always returned as flat list, arrays that represent structured data, such as the point array or matrix array, will need to be grouped. This can be done with Python, based on an example found here
If anyone knows how to make the API return nested data structures, feel free to submit the fix as a pull request.
Long name (short name) | Argument types | Properties |
---|
# Get an array attribute of type point array with three values.
m = cmds.getArrayAttr("node.aMatrixArray")
# Result: [0, 1, 0, 1, 2, 3, 1, 0, 1]
# Use the group function (linked above) to re-pack the data in tuples.
m = group(m, 16)
# Result: [
# (0, 1, 0),
# (1, 2, 3),
# (1, 0, 1)
# ]
# Get an array attribute of type matrix array with three values.
m = cmds.getArrayAttr("node.aMatrixArray")
# Result: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
# Use the group function (linked above) to re-pack the data in tuples.
m = group(m, 16)
# Result: [
# (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),
# (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),
# (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
# ]