[Closed] Accessing an array within an array
Hi,
I am curently working on a script that allows the user to select scene objects one-by-one and then lets you choose which controller tracks for that object you want to instance (from either the transform or modifier tracks) so that you can then paste all the tracks into one place on a PEN_Attribute_Holder02 modifier on one master control object.
This will be great for saving out a ‘skin pose’ for custom rigged characters as well as other poses.
This will also be very useful for arch vis as it will allow you to store all max light values for different times of day or moods.
No doubt there should be lots of helpful uses for this if I can get it to work!
I am stuck however with an array problem; within the script I have managed to create an array like so:
“#(”#(Controller:Position_Rotation_Scale, Controller:Position_XYZ, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Euler_XYZ, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Scale)”, “#(Controller:Position_Rotation_Scale, Controller:Position_XYZ, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Euler_XYZ, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Float, Controller:Bezier_Scale)”)”
The above array as far as I am aware should be an array within an array. The first array inside the main array is a list of keyable tracks from the first object I picked in my program, the second array is a list of keyable tracks from the next object I picked.
I get the listener to show the above result using:
print (objectTrackArray as string)
The problem I am having is that I cannot return one of the controllers listed inside the sub arrays. If I use:
print objectTrackArray[1][3]
the listener returns
“C”
as if the array within the array is broken down into individual characters rather that the control objects that created them.
Does anyone understand where I am going wrong with this?
Thanks in advance for any help.
Spence
Its OK I have found a work around now. My problem was the way in which i was constructing the array of arrays.
I still do not completely understand how it works but at least I can get on now.
That isn’t an array of arrays. It’s an array with a two string elements that happen to look like arrays. The third character of the first element is the letter “C” which is why you get that back when you type: objectTrackArray[1][3].
Each element in the inner arrays needs to be it’s own string, not combined into a single string so:
“#(a, b, c)” becomes #(“a”, “b”, “c”)
And then those arrays need to be put into a master array as values (not surrounded in quotation marks) so:
#(“#(a, b, c)”,”#(a, b, c)”) becomes #(#(“a”, “b”, “c”), #(“a”, “b”, “c”))
now you have an array of arrays that you can access with the [1][3] syntax.