Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rename Objects

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dg3duy
884 Views, 4 Replies

Rename Objects

I need to write a new name to replace the word Character that already contains each of the objects in my scene with a new name that I can write.
My objects are called: Character_Nametest_001///Character_Othername_001///Character_Test_001

Ideally, you should use a menu like the one in this exercise:

 

macroScript RenameThem category: "HowTo"
(
 rollout rename_rollout "Enter New Base Name"
 (
  edittext base_name ""
  button rename_them "RENAME SELECTED OBJECTS..."
  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 50
)

 

 

4 REPLIES 4
Message 2 of 5
10DSpace
in reply to: dg3duy

@dg3duy 

 

Just making sure that you do know that the Rename Objects Tool in the Max Tool menu already let's you do this by removing the first 9 digits and putting your replacement name as a prefix: 

 

Rename tool.png

 

 

Message 3 of 5
dg3duy
in reply to: 10DSpace

It's not a bad idea to use it, it's just that I'd like to see it on the menu I show you below.

points.gif

Message 4 of 5
denisT.MaxDoctor
in reply to: dg3duy

macroScript NameChange 
	category: "MXS with denisT" 
	buttonText:"NAME CHANGE"
	toolTip:"Name Change with denisT"
	autoUndoEnabled:off
	silentErrors:off
(
	local d
	
	global NameChangeRol =
	(
		rollout NameChangeRol "Object Name Change" width:191
		(
			local opened = if opened != undefined do opened
	
			local dialog_pos = if dialog_pos != undefined then dialog_pos else unsupplied
			local source_text = if source_text != undefined then source_text else ""
			local target_text = if target_text != undefined then target_text else ""
			
			edittext source_name_ed "Source:" text:source_text fieldwidth:130 align:#right offset:[8,4]
			edittext target_name_ed "Target:" text:target_text fieldwidth:130 align:#right offset:[8,0]
			
			on source_name_ed changed text do source_text = text 
			on target_name_ed changed text do target_text = text 
			
			button name_replace_bt "Replace" width:180 align:#right offset:[8,0] \
				tooltip:"Replace Source part of object name with Target"
			button name_casechange_bt "Change Case" width:180 align:#right offset:[8,2] \
				tooltip:"Change object name case\n    Default\t - To Lower\n  +SHIFT\t\t - To Upper"

			on name_replace_bt pressed do undo "Name Change" on if source_name_ed.text.count > 0 do
			(
				for obj in selection do obj.name = substitutestring obj.name source_name_ed.text target_name_ed.text
			)
			on name_casechange_bt pressed do undo "Name Change" on 
			(
				for obj in selection do obj.name = (if keyboard.shiftPressed then toupper else tolower) obj.name 
			)
			
			on NameChangeRol close do
			(
				dialog_pos = getdialogpos NameChangeRol
				opened = off
				updateToolbarButtons()
			)
			on NameChangeRol open do
			(
				opened = on
				updateToolbarButtons()
			)
		)
	)
	
	fn destroy =
	(
		try(destroydialog d) catch()
	)
	fn create =
	(
		createdialog d pos:d.dialog_pos		
	)
	
	fn enabled = 
	(
		iskindof (d = try(globalvars.get #NameChangeRol) catch()) RolloutClass
	)
	on isChecked do enabled() and (d.opened == true)

	on execute do if enabled() do
	(
		if (d.opened != true) then create() else destroy()
		updateToolbarButtons()
	)
)			

 

I hope you know how to add Macroscript to the system

 

Message 5 of 5
dg3duy
in reply to: denisT.MaxDoctor

it works as usual on your part... wonderfully!
Thank you very much!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators