Notifications
Clear all

[Closed] how to store a 2d array in a CA


 SMData = attributes "SMData"	
 				(
 					parameters main rollout:blank
 					(		
 						Layer_Name type:#StringTab tabSizeVariable:true	animatable:false			--array of strings.
 						Layer_GroupName type:#StringTab tabSizeVariable:true	animatable:false	--Array of strings.					
 					)
 					rollout blank "blank"
 					(
 					)
 				)
 				--	
 			custAttributes.add globaltracks SMData
 			--empty the arrays
 				
 globaltracks.SMData .Layer_Name =#("dedo","casa")
 globaltracks.SMData.Layer_groupname = #(#("dedo",#("casa","dedo")))
 

this will create a ca in the global tracks where i am saviong arrays.

i can add array of string without problem as seen on the globaltracks.SMData .Layer_Name =#(“dedo”,“casa”)

but can save 2d arrays as #(#(“dedo”,#(“casa”,“dedo”)))

is any parameter that will be allow to save 2d or 3d array. i ben sen of kind of parameter but loks oneone can do it.

or if not is any option method.

help will be much apreciated

4 Replies

found a solurtion ,save each 2d array as string and ad later the info of the 2d array with an execute.



 SMData = attributes "SMData"	
(
	parameters main rollout:blank
	(		
		Layer_Name type:#StringTab tabSizeVariable:true	animatable:false			--array of strings.
		Layer_GroupName type:#StringTab tabSizeVariable:true	animatable:false	--Array of strings.					
	)
	rollout blank "blank"
	(
	)
)
--	
custAttributes.add globaltracks SMData
--empty the arrays
				
globaltracks.SMData .Layer_Name =#()
a = #("dedo",#("hola", "casa" ))
b = a as string

globaltracks.SMData.Layer_groupname =#( b)

c= globaltracks.SMData.Layer_groupname
				
d=execute c[1]

d[2]
 

if you want to create a multidimensional array you can define it as:

 myMultiDimArray = #(#(1,2,3,4,5,6,7,8,9,10),#(10,20,30,40,50,60,70,80,90,100))
 -- add a third element to the array containing 10 more elements
 append myMultiDimArray #(100,200,300,400,500,600,700,800,900,1000)
 myMultiDimArray[2][5] --> returns 50 - the 5th element of the 2nd sub-array 
 

this is from the maxscript reference file… Tag: How to create a multi-dimensional array

hope this helps

Edit: Should have read the whole post… Just repeated your solution :surprised

sorry abyjoe i dint want to know how too do 2d arrays (that i already know) it was more about how to save the 2d array in a atributte inside of a custom atributte.

Hey wahooney thanks for the time to write the code, i loving your scripts :), goood to know we endup with the same solution :).