Help with (simple?) script


I’m a student that is just stumped by what seems a simple assignment. I simply need to write a script that will parse a given scene and delete anything that is NOT a box. I can accurately determine if something isn’t a box with:

for i in $objects do
if classOf i!=box then

but as soon as I try to delete those objects by using:

delete i

I get a Unknown Exception Error. I have tried the help files for delete. I have also tried placing the objects in an array, iterating through the array and then deleting. I just can’t see why this shouldn’t work. Help please…


give this a try

for i in objects do
if classof i != Box do
delete i


When you use an array and you want to delete specific array items or nodes by using an index you haveto make sure running this array from the end to the start like:

for lvi = Arr.count to 1 by -1 do ( deleteitem Arr lvi)

I know this is not the exact answer to your question but this should work. If you do it the other way round you’re changing the array size. Maybe that is what also hapens in your current case.


@jfjohnny5, check the scriptspot thread.


Thanks! I finally got it.


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.