Select any objects in your scene - say $head, $body, and $shirt
on buttonName pressed do
Script will clone the selected objects, then attach and weld the clones
Apply a Skin Wrap modifier to the unified clone
Add the original objects to the Skin Wrap’s Control Objects list
What I’m missing is #4. I don’t know how to store those objects so I can access that list for a later function. I think I need to getCurrentSelection () and pass that into another variable, but I’m not sure how to do that and get Max to “remember” the objects I had selected at the beginning.
Here’s what I have so far that works:
on weldGeo pressed do
(
undo off
(
maxOps.cloneNodes $ cloneType:#copy newNodes:&nnl
while selection.count > 1 do
(
selcount = selection.count
for i = selcount to 2 by -2 do
(
macros.run "Modifier Stack" "Convert_to_Poly"
polyop.attach selection[i] selection[i-1]
)
)
update selection[1]
$.name = "geo_welded"
)
subobjectLevel = 3
max select all
macros.run "Editable Polygon Object" "EPoly_Convert_Sel_To_Vertex"
$.weldThreshold = 0.01
$.EditablePoly.weldFlaggedVertices ()
subobjectLevel = 0
$.wirecolor = color (random 0 255) (random 0 255) (random 0 255)
--APPLY SKIN WRAP MODIFIER
max modify mode
select $geo_welded
modPanel.addModToSelection (Skin_Wrap engine:0 weightAllVerts:true) ui:on
)
In the beginning of your button event, you can define an array to store all of your currently selected objects in. Here’s a tiny test script to demonstrate this functionality.
Thanks. I’m learning here, so please bear with me. If that’s really storing the selected objects in an array, I’d think I should be able to run that then type “select objs” in the listener and those same objects should get selected again. That isn’t happening.
The keyword “local” in front of the var “objs” tells MaxScript that the var is only available within the scope of the function. Once the function has finished running, the local variable is effectively removed from play.
I.e, it can’t be accessed at a global, listener level.