PDA

View Full Version : Multidimensional Array


chrsmrphy
02-22-2012, 05:00 PM
Hey guys,

I've read over lots of stuff on multidimensional arrays in MaxScript. Everything has been helpful, but it's not quite what I need.

I've done python coding before, specifically in Maya. There, I am able to gather a list/array of objects. Using this, I can nest lists of the objects attributes/properties.

Here is where I am and how I would do it. I feel like MaxScript is being too smart, and I want it to be dumb right now. It will take everything and make one big array. I need one array containing a bunch of arrays.

deformerArray = for o in objects where classof o == SpaceWarp collect o

hugeArray = #()
for obj in deformerArray do (
newArray=#()
for p in getPropNames obj do
append newArray (p as string + ":" + (getProperty obj p) as string)
join hugeArray (newArray)
)

Essentially, I want my hugeArray to contain individual arrays of all the properties of each individual spacewarp object.

I've tried formatting the code properly, but it doesn't seem to be indenting correctly.

Panayot
02-22-2012, 05:50 PM
if i get it ...deformerArray = for o in objects where classof o == SpaceWarp collect o

hugeArray = #()
for obj in deformerArray do (
newArray=#(obj)
for p in getPropNames obj do
append newArray (p as string + ":" + (getProperty obj p) as string)
append hugeArray newArray
)

chrsmrphy
02-22-2012, 06:54 PM
Thank you sir. I believe I'm able to achieve what I need to achieve with this. I knew I was close. I'm new to MaxScript, so the syntax kind of has me stumped sometimes.

lo
02-22-2012, 07:31 PM
or in the minimalistic version:

hugeArray = for o in objects where classof o == SpaceWarp collect
(
for p in getPropNames o collect (p as string + ":" + (getProperty o p) as string)
)

chrsmrphy
02-23-2012, 01:33 PM
Thank you as well. I really like the trimmed version, but I do need access to my original array. It's very helpful for my future scripts though. Thanks.

CGTalk Moderation
02-23-2012, 01:33 PM
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.