Hello people!
Quick question, why won't the bellow "Collapse To" script works on a selection of objects?
fn collapseTo =
(
for obj in selection do
(
for i in obj.modifiers.count to 1 by -1 where
obj.modifiers[i] == modPanel.getCurrentObject() do
(
maxops.CollapseNodeTo obj i off
exit
)
)
)
collapseTo()
.. from what I understand, maxscript didn't really exposed to the "collapse to" function so I hack in a way to make it work but currently only works for a single object. Does anyone can point out the mistake on my code that make it's not working as expected on multiple selection of objects?
Replies
If you're trying to collapse multiple objects to a specific class of modifier you will have to change your logic as modPanel.getCurrentObject() returns a specific modifier, thus it cannot also exist on another object. Instead you would have to loop through the objects' modifiers looking for a specific class of modifier, collect its index in the stack and collapse the object's stack to this specific index if it was found.
cheers
StereoVinny's solution is what I would do. But if you know you're always going to deal with an instanced modifier you can make a simple change.
And yea, I get what you mean now StereoVinny! even though that wasn't my original intention, but it sure does come in handy when I need it in the future! Also WELCOME TO POLYCOUNT!
Why use maxops commands in general? I usually rely on Node commands:
ConvertTo and it's shortcuts like convertToPoly, convertToMesh and so on.
You can find all of them in maxscript manual under "Node" chapter or using apropos "convertTo" on maxscript command line.
In fact, I do have a convert to function as well on my shortcut key list