Notifications
Clear all

[Closed] perform the loop for all specific objects?

i want to set up a loop to rename all the helpers in a scene based upon their existing name.
I got my rename code to work by stepping through it with one object
i am not sure how many objects there will be in the scene so i was hoping to perform the same loop for all the helpers in the scene. Is this possible?

Also i want to check the name of the file to see if it needs to be renamed ( only specific helpers need to be renamed) I got it to return the last 6 characters of the object name which i need to check against.

sorry guys i forgot to grab my code. its on another computer.

but any light you can throw on this would be cool

cheers

4 Replies

classOf() will help you immensely in this. It returns the class of the currently selection object.

Assuming you are limiting yourself to Dummy and Point helpers you can act only on those by itterating through the system variable objects, which refers to an array of all nodes in the scene, like this:


for obj in objects do


(if (classOf obj == Dummy) or (classOf obj == Point) then

(

[indent]if findString obj.name <Your 6 character search string> == true then 

 


([indent]obj.name = <new object name>

 
-- or use replace() if you just want to change part of the name

)


[/indent])


[/indent])

cheers thanks for such a quick reply!

You could also access the helpers by using helpers as a collection, in the same way that Jeff has accessed objects. This will also pick up group heads and other helpers like compasses etc.

 for obj in helpers do 
 
(
 
if isgrouphead obj==false then 
 
(
 
-- now test for name
 
)
 
)
 

maxfilename – will return the currently open scene filename

and

savemaxfile – will save your file with a new name.

Cheers,

J.