problems with 2d arrays

I have an array that looks like this: #(4, 12, #{4, 11}, #{10..11}, #{10, 12})

how do i access the second '4'?

I've tried myArray[3][1], and a ton of other possibilities... but nothing works.

Basically, I just want to write a function that will collapse this array into something that looks like this: #(4, 12, 4, 11, 10, 11, 10, 12).

Can anyone help me? is there a quick fix function out there? How do I access these numbers?

btw, the reason some numbers are in pairs is because I appended 2 selected verts into the array.

the first two numbers in the array were created by this command:
myarray = $.editablepoly.getselection #vertex as array

the rest of the numbers were created through this command:
append myarray ($.editablepoly.getselection #vertex)

in both cases, two verts were selected.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kimarotta's picture

hi...

hi...

in this case the second vertex group is a bitarray.. search in maxscript help "Value > Collections > BitArray Values"

you need use...

myarray = $.editablepoly.getselection #vertex as array
#(5, 6, 7, 8)
---change selection vertex and
myarray2 = $.editablepoly.getselection #vertex as array
#(1, 2, 3, 4)
myarray + myarray2 
#(5, 6, 7, 8, 1, 2, 3, 4)

or use this to have a array

myarray = $.editablepoly.getselection #vertex as array
#(5, 6, 7, 8)
---change selection vertex and
for i in ($.editablepoly.getselection #vertex) do append myarray i
myarray
#(5, 6, 7, 8, 1, 2, 3, 4)

kimarotta.com.br
3d Artist  

barigazy's picture

myarray+myarray2 is the same

myarray+myarray2 is the same as join myarray myarray2
To convert multidimensionl array in one dimensional array like in your case
you can simply use:

temparr = #(4, 12, #{4, 11}, #{10..11}, #{10, 12})
newarr = #()
for i in temparr do
(
   case classof i of (
      (Integer): append newarr i
      (BitArray): join newarr (i as array)
   )
)

bga

kimarotta's picture

good... useful

good... useful code...
thanks

kimarotta.com.br
3d Artist  

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.