[Closed] rename object name to filename
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 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…
vishal
Hi Vishal,
here is what you ask,
$sphere01.name=maxfilename
but maybe you will need more!
max select all
sel=selection as array
for s in sel do s.name+=maxfilename
Josh.
I took the freedom to take a premade script from the MAX Script Reference. You´ll have to thank Bobo for putting it down there, I just did some humble kit bashing (Adding the filenmae input and the first button) so it better suits your needs:
max_file_name = getFilenameFile maxFilename
rollout rename_rollout "Enter New Base Name"
(
edittext base_name "" text:max_file_name
button rename_them_single "RENAME JUST 1 OBJECT..."
button rename_them "RENAME SELECTED OBJECTS..."
on rename_them_single pressed do
(
if base_name.text != "" do
$.name = base_name.text
)--end on
on rename_them pressed do
(
if base_name.text != "" do
for i in selection do i.name = uniquename base_name.text
)--end on
)--end rollout
createDialog rename_rollout 250 100
Basically, on execution it creates a GUI with your file name in the input name and you can then press 2 buttons. The first is for renaming a single object and renames it with your filename, the second is for renaming several objects at once and renames them filename01, filename02…etc.
Have fun, I hope I could help you there
Chris
first i want to thank you all people, and very happy to see communication very fast,
though this script solves some part ,
max_file_name = getFilenameFile maxFilename
rollout rename_rollout “Enter New Base Name”
(
edittext base_name “” text:max_file_name
button rename_them_single “RENAME JUST 1 OBJECT…”
button rename_them “RENAME SELECTED OBJECTS…”
on rename_them_single pressed do
(
if base_name.text != "" do
$.name = base_name.text
)–end on
on rename_them pressed do
(
if base_name.text != “” do
for i in selection do i.name = uniquename base_name.text
)–end on
)–end rollout
createDialog rename_rollout 250 100
i want to export this selected object in obj or 3ds format after renaming, and i dont want any dialogues open and specify path, the path also should be embeded in the script, for example, like, it shoud save the obj or 3ds file to c:\work\ and the obj or 3ds file name should be the object name , right now its saving export all, how to update this better??
my updated script is this
max_file_name = getFilenameFile maxFilename
rollout rename_rollout “Enter New Base Name”
(
edittext base_name “” text:max_file_name
button rename_them_single “RENAME JUST 1 OBJECT…”
button rename_them “RENAME SELECTED OBJECTS…”
on rename_them_single pressed do
(
if base_name.text != "" do
$.name = base_name.text
DestroyDialog rename_rollout
theClasses = exporterPlugin.classes
exportFile (GetDir #scene + “/exportTest” )
selectedOnly:true
using:theClasses[1]
)–end on
on rename_them pressed do
(
if base_name.text != “” do
for i in selection do i.name = uniquename base_name.text
DestroyDialog rename_rollout
)–end on
)–end rollout
createDialog rename_rollout 250 100
try this…
max_file_name = getFilenameFile maxFilename
FolderName = GetDir #scene + "\\exportTest\\" [color=Lime]--- Give the folder name here for export
[/color]
rollout rename_rollout "Enter New Base Name"
(
edittext base_name "" text:max_file_name
button rename_them_single "RENAME JUST 1 OBJECT..."
button rename_them "RENAME SELECTED OBJECTS..."
fn export3ds obj =(
theClasses = exporterPlugin.classes
exportFile (FolderName+ obj.name) #noprompt selectedOnly:true using:theClasses[1]
)
on rename_them_single pressed do
(
if base_name.text != "" do $.name = base_name.text
export3ds $
DestroyDialog rename_rollout
)--end on
on rename_them pressed do
(
if base_name.text != "" do
sel = selection as array
for i in sel do
(
i.name = uniquename base_name.text
select i
export3ds i
)
DestroyDialog rename_rollout
)--end on
)--end rollout
createDialog rename_rollout 250 100
thanks for the reply akram, but no success , its not exporting at all…,
FolderName = GetDir #scene + “\exportTest\” — Give the folder name here for export
i think u are not having a folder named exportTest in the scenes directory. Create the folder manually then it will export the files without any issues.