Notifications
Clear all

[Closed] how to make backup copy of "selection" array?

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?

4 Replies

[edit] , my answer was irrelevant.

 lo1

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

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?

1 Reply
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

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