Auto Pick Script


#1

I need some help:
I need a simple script to rename quickly the picked objects in the scene, in rollout i want a Text Box with the name exemple: “name_01” and a Button to activate the auto name assignment.
When the option is ON i want that for each pick objects the script raname it “name_01”, after if i re-pick an other objects the script re-name “name_02” and so on until the option is ON.
I know a bit maxscript but i don’t know now create a cicled function like this :wink:


#2

Then you should definitely have a look at callbacks.
These allow your script to be called whenever something in the scene changes (depends on what you choose ofcourse). Have a look and post back what you tried!

Goodluck,
-Johan


#3

You could also do this with a mouse tool probably… just active the tool, and then start clicking objects, should be pretty straightforward to have it to the renaming on click.


#4

This is a test, but i don’t know now change the “stop” function “IF i>10” DO EXIT", exemple how can i stop the recursive autorename with right clic ?

macroScript AutoReName category:"MyTool" tooltip:"AutoReName"
(
local i=0
while true do
	(
	obj = pickObject()
	obj.name = "name_" + i as string
	messageBox ("obj picked: " + obj.name) -- this is only a test, i'll delete
	i+=1
	if i>10 do exit -- i want a different exit, exemple with a right clic....
	)
)


#5

I john
look at this example:


obj=pickobject()
i=0
while obj!=undefined then
(
	i+=1
-- do something

	obj=pickobject()
)


#6

If you just want to increment the number at the end of the name, you can just use the “uniqueName” command.

$.name = uniqueName "bob_"

Renames the selected object “bob_001”. If you run it again on another object, it will be named “bob_002”.

And if you’re using Max 2011, there’s a new parameter that controls the number of digits to use:

uniqueName "bob_" numDigits:4

This would give you “bob_0001” instead of “bob_001”.


#7

Very interesting but is only an exemple, the real name is:

		Cpx = formattedPrint CpxCount format:"02i"
		Str = formattedPrint StrCount format:"02i"
		Num = formattedPrint NumCount format:"03i"
		obj.name = "Cpx"+Cpx + "_Str"+ Str + "_Obj" + Num + "_1"

#8

i make a tool that work well but someone can suggest me something better?


#9

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.