ScriptSpot

Forum topic · General Scripting

How to Rename a Specific Object with MaxScript?

By enrico_sanchez · 2017-06-27

Description

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 (1)

`

pixamoon · 2017-06-28

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
)