ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
Are all this modifiers on top of the stack? And there also not other kind of modifiers in-between, rihgt? If not, the final result would be unexpected, actually undesirable.
I'll presume that the modifiers you want to preserve are on top of the stack, and will post something (UNtested), and can't say is it better than Branko's idea :))
fn customCollapse force:off = ifselection.count > 0 do(
local modClasses = filterString (@"TurboSmooth
MeshSmoothMod
MapMod
Unwrap UVW"), "\n\t"
local arrObj = #(), oldSel, modIndex, run
local rptInstances = #(), trueInstances
max create mode
oldSel = selection as arraywhileselection.count > 0 do(
InstanceMgr.GetInstances $ &rptInstances
trueInstances = for n in rptInstances where \
(areNodesInstances selection[1] n) collect n
append arrObj selection[1]
deselect trueInstances
deselect selection[1])if force do(for obj in arrObj where \
obj.modifiers.count == 0 do(if validModifier obj Turn_To_Mesh do(addModifier obj (Turn_To_Mesh());
collapseStack obj)))
arrObj = for obj in arrObj where \
obj.modifiers.count > 0 collect obj
for obj in arrObj do(
modIndex = obj.modifiers.count
run = (modIndex > 1)while run do(if findItem modClasses (getClassName \
obj.modifiers[modIndex]) == 0 then
(modIndex -= 1)else(run = false)if run do run = (modIndex > 0))
modIndex += 1
if modIndex <= obj.modifiers.count do
maxOps.CollapseNodeTo obj modIndex off
if obj.modifiers.count == 1 and \
findItem modClasses (getClassName \
obj.modifiers[1]) == 0 do
collapseStack obj
)
select oldSel
)-- Usage:
customCollapse force:on -- collapse all selected
customCollapse()-- skip selected without modifiers
Comments
hey, Anubis! I like your idea
hey, Anubis! I like your idea with collapsing only upper modifiers, but your script has a lot of errors!
.
Fix the errors and post the result. :)
Tools and Scripts for Autodesk 3dsMax
hi Daniel
Are all this modifiers on top of the stack? And there also not other kind of modifiers in-between, rihgt? If not, the final result would be unexpected, actually undesirable.
I'll presume that the modifiers you want to preserve are on top of the stack, and will post something (UNtested), and can't say is it better than Branko's idea :))
my recent MAXScripts RSS (archive here)
try this
bga