Pages

Monday, November 22, 2010

Clone and Select


How to clone array of objects and select this new objects at the end? Shortly, this was the question on this forum topic. Yes, its a MaxScript topic. May looks simple, but there covered some basic and important things about array and mapped functions. While helping on Ian, I wrote by the way the script who asked for (get the script), but the info itself posted in the forum is more interesting/useful to the people going to learn MaxScript. Well, still not explain too much about the mapped functions, but hey, this is a quick help, not large essential book :) The difference between mapped and non-mapped functions is not just in their performance. Mapped functions are more faster but not applicable sometimes. After reading the forum topic, I hope the next short example can help to bring some idea about the mapped functions.

-- Lets say we have 3 objects with names A01, A02, A03.

-- And wish to make 2 instance clones on each of them.




select #($A01, $A02, $A03) -- select them



-- mapped instance copy:

for i = 1 to 2 do instance selection



-- iterated instance copy:

for obj in selection do

for i = 1 to 2 do instance obj

In the 1st case the A01 would have 2 instances: A04 and A07.
In the 2nd case the A01 would have 2 instances: A04 and A05.

Here is the result showed in table format (instances are sorted in columns):

Case 1:      Case 2:

-----------..-----------

A01 A02 A03 A01 A02 A03

A04 A05 A06 A04 A06 A08

A07 A08 A09 A05 A07 A09

As you see, the order of creation is different and that could affect on the rest
operations on this objects. Ok, that's it for now.

No comments:

Post a Comment

Thanks for your comment