ScriptSpot

Forum topic · General Scripting

rename object name to filename

By kutty · 2009-08-18

Description

hi,

can any body help me out to get this easy task..

select $sphere01

with this script line,, i am able to select with script,, but i want extend this script by making the selected file object with script, to make the selection name to be same as file name. if my file name is testing.max,, i want this sphere01 object in max file to be renamed by testing

can anybody help me... thanking you..

kutty

Comments (2)

Anubis · 2009-08-18

Hi Kutty,
maxFileName is what you looking for (#step_1):

$.name = maxFileName -- but if the scene not saved (Untitled) maxFileName return empty string

. So, if the scene file name is "test.max", your selected object will be with the same name. But if you want only the name of the scene (without ".max") - #step_2:

$.name = trimRight $.name ".max" -- now your object name is "test"

Or combine code in 1 step only:

$.name = trimRight maxFileName ".max"

fajar · 2009-08-18

just using Track script , you can find it here, it's cool and have ability to select object with given name too !! you'll gonna love it!