How to Rename a Specific Object with MaxScript?

Hi, I've been searching for several hours looking for a simple command to rename a specific object. It can't be that hard, right?

In Windows Command Line you just write "rename rouge.txt red.txt" to rename a file.
How do I rename a specific object in the same way in 3D Studio Max?

I feel kind of stupid asking such a simple question, but when I searched for an answer all I could find was scripts with generic renaming and irrelevant solutions to my case.

Thanks in advance!

Edit: Nevermind, I found it myself... for example, if I have an object named "Rouge" I rename it $Rouge.name = "Red" .

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pixamoon's picture

`

Hi,

try this loop:

oldName = "old"
newName = "new"
 
for o in objects where o.name == oldName do o.name = newName

or

oldName = "old"
newName = "new"
 
while getNodeByName oldName != undefined do (
	local o = getNodeByName oldName
	o.name = newName
)

or if you want new unique names:

oldName = "old"
newName = "new"
 
for o in objects where o.name == oldName do o.name = uniqueName newName

or

oldName = "old"
newName = "new"
 
while getNodeByName oldName != undefined do (
	local o = getNodeByName oldName
	o.name = uniqueName newName
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.