PDA

View Full Version : how to make backup copy of "selection" array?


MatthiasBuehlmann
03-08-2012, 07:19 AM
How can I make a copy of the array "selection" to use later? my script changes the selection of objects, but i still want to maintain a list of what was originally selected. But as soon as i make a change to the selection, the copy of my list changes too. I made a simple script to illustrate this:

allObjs = deepCopy selection

for obj in allObjs do(
select obj
move obj [0,0,10]
)

I would expect this script to move all selected Objects upwards. If the line "select obj" is commented out, it does this. but with the line "select obj", only one object will be moved, as apparently as soon as "selection" changes, also my allObjs array changes (which is supposed to be a copy though)

how to properly create a duplicate array containing the current selection?

stigatle
03-08-2012, 08:00 AM
[edit] , my answer was irrelevant.

lo
03-08-2012, 08:58 AM
the keywords selection is a collection, not an array. It is live and always represents the current selection at any time. To make a snapshot of it as an array, use one of the following two methods:
getCurrentSelection()
or
selection as array

MatthiasBuehlmann
03-08-2012, 02:30 PM
that's it! thank you!

by the way - is there any way to program actionscript in a typesafe way? and maybe have something like intellisense with an external ide?

lo
03-08-2012, 02:45 PM
that's it! thank you!

by the way - is there any way to program actionscript in a typesafe way? and maybe have something like intellisense with an external ide?

I think you mean maxscript?
Maxscript is inherently not typesafe. Changing that would be rewriting the language and breaking most existing scripts.

CGTalk Moderation
03-08-2012, 02:45 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.