Help with object names and selection!!
I am trying to make a script to add skin modifier with the bone with the same name of the object I want to skin.
I made a spinner where I can select the object I want and I would like when I press double click apply the skin to that object and get the bone with the same number, for example double click in "piece_08" and then add a skin modifier and add the "bone08". Is there a way to do this? I am going to use only one bone for object.
Another little thing, can I order the spinner list in alphabetical order? as it gets the list in random order.
Here is the code I did so far. I have attached the max file in that way maybe you can see it better. Any help please?
rollout skinner_group "Skinner"
label lab1 "SKINNER"
listbox objectToSkin "Objects:" items:(for o in objects collect o.name)
spinner piece_number "Piece number:" range:[1,150,1] type:#integer
button StartButton "START" width:60 height:40
label lab2 "RENAMER"
edittext base_name ""
button rename_them "RENAME SELECTED OBJECTS..."
on objectToSkin selected nameIndex do
select (getNodeByName objectToSkin.items[nameIndex])
on objectToSkin doubleClicked itm do
macros.run "Modifiers" "Skin"
skinOps.addBone $.modifiers[#Skin] $bone01 1 -- Here is where I want to put the bone with the same object number selected
$.modifiers[#Skin].cross_radius = 65.625
on rename_them pressed do
if base_name.text != "" do
for i in selection do i.name = uniquename base_name.text
base_name.text = ""
on StartButton pressed do
theName = "Piece_"
extension = piece_number as string -- Another option I thought is adding the extension from the spinner the problem I have is I don't know how to exchange integer number to string
theObject = Execute ("$"+theName+extension)
-- Here I would put the skin modifier and then I would do the same system to use the "bone" name with the same "extension" string
createDialog skinner_group 250 350