Multiple Arrays -> Multidimensional Array

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2009   #1
Multiple Arrays -> Multidimensional Array

Hello.
I need some help with Maxscript, the situation is the following.

Here's my source text...
theArray1 = #(diffuse,alpha,background) --#(diffuse,alpha,background,etc,etc...)
 theArray2 = #(true,false,true)		  --#(true,false,true,etc,etc...)
 theArray3 = #("name1","name2","name3")  --#("name1","name2","name3",etc,etc...)
 
 theArray_all = #()
 for i = 1 to theArray1.count do
 (
 	append theArray_all theArray1[i] 
 	append theArray_all theArray2[i] 
 	append theArray_all theArray3[i]
 )
 
 print theArray_all #nomap
 --#(diffuse, true, "name1", alpha, false, "name2", background, true, "name3")
 


I would like to do this way.
--from
 #(diffuse, true, "name1", alpha, false, "name2", background, true, "name3")
 --to
 #(#(diffuse, true,"name1"), #(alpha, false, "name2"), #(background, true, "name3"))
 

Any help would be appreciated.
 
Old 03 March 2009   #2
Can you use a struct?

have a look in the MXS help.

J.
__________________
www.joshuanewman.net
 
Old 03 March 2009   #3

append theArray_all #(theArray1[i], theArray2[i], theArray3[i])

?
 
Old 03 March 2009   #4
Hi cubecube,
is this what you're looking for?

theArray1 = #(diffuse,alpha,background) --#(diffuse,alpha,background,etc,etc...)
theArray2 = #(true,false,true)          --#(true,false,true,etc,etc...)
theArray3 = #("name1","name2","name3")  --#("name1","name2","name3",etc,etc...)

-- Number of arrays to process 
iNumArray = 3

-- Number of elements per array assuming all arrays have the same dimension
iNumElemPerArray = theArray1.count

-- If arrays have a smart name with a fixed part and a progressive number,
-- the code can be a little automated:

-- Initialize the array holder
theArray_all = for i = 1 to iNumElemPerArray collect #()

for i = 1 to iNumElemPerArray do
(
    for j = 1 to iNumArray do
    (
        append theArray_all[i] (execute("theArray" + (j as String)))[i]
    )
)
format "Automatic: %\n" theArray_all

-- Otherwise, if names cannot be handled:

-- Initialize the array holder
theArray_all = for i = 1 to iNumElemPerArray collect #()

for i = 1 to iNumElemPerArray do
(
    append theArray_all[i] theArray1[i]
    append theArray_all[i] theArray2[i]
    append theArray_all[i] theArray3[i]
)
format "Manual:    %\n" theArray_all

- Enrico
__________________
IllusionCatalyst Instrument set for 3ds Max │ AliquaForma Personal portfolio in fieri
 
Old 03 March 2009   #5
Overcomplicating?

append theArray_all theArray1
  append theArray_all theArray2 
  append theArray_all theArray3


will give you exactly what you expected.
__________________
Bobo
 
Old 03 March 2009   #6
Originally Posted by Bobo: Overcomplicating?

append theArray_all theArray1
   append theArray_all theArray2 
   append theArray_all theArray3


will give you exactly what you expected.


wouldn't that give..

#(#(Diffuse, alpha, Background), #(true, false, true), #("name1", "name2", "name3"))


As opposed to...

#(#(Diffuse, true, "name1"), #(alpha, false, "name2"), #(Background, true, "name3"))
 
Old 03 March 2009   #7
Thanks for many reply.
My problem was solved with "collect".

Many thanks!!
 
Old 03 March 2009   #8
Originally Posted by ZeBoxx2: wouldn't that give..

 #(#(Diffuse, alpha, Background), #(true, false, true), #("name1", "name2", "name3"))
 


As opposed to...

 #(#(Diffuse, true, "name1"), #(alpha, false, "name2"), #(Background, true, "name3"))
 


Ah, I should start drinking coffee in the morning (I never do)
__________________
Bobo
 
Old 03 March 2009   #9
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:55 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.