collapse to problem

hello
I made a little script to add an edit poly modifier at bottom of the stack of selected objects, so I can move for eg vertexes of all the objects in same time, AND when I have made my modifs in edit poly modifier I can "collapse to" the instanced edit poly modifier without touching modifiers on top of the stack.
But when I "collapse to" in the attached example (.png) I loose a modifier.
I can't manage to make a script to collapse just the lower modifier....
Anybody ?

AttachmentSize
collapse.png110.94 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ruramuq's picture

---------

if youre sure that all objects have the modifier you want to delete,after the baseobject then:
--
for o in selection do maxops.CollapseNodeTo o o.modifiers.count true
--

@Anubis, coping/instancing , does not always preserve all the data, in mods like editpoly..

titane357's picture

waow ! really cool ! I don't

waow ! really cool ! I don't understand the script itself, but it works :-)

Anubis's picture

thanks for reminder

Oh, i was forgot about maxOps.CollapseNodeTo
The Ruramuq code collapse most bottom modifier

[edit] here is a macro script with ui, cheers

AttachmentSize
customcollapse.ms 1.3 KB
ccollapse01.png 1.95 KB

my recent MAXScripts RSS (archive here)

Anubis's picture

yep, batch processing

yep, batch processing collapse in this manner hide some weakness :) i think the function can be modified to select the desirable modifier and collapse when. it w'd be more slower but more correct (no backup copies).

my recent MAXScripts RSS (archive here)

titane357's picture

hello anubis. If you select

hello anubis.
If you select lower modifier in the stack and "collapse to", you keep all other modifiers.
Now, with your script I'm the king : it works like a charm !!! Thanks.

titane357's picture

argh ! is it possible to

argh ! is it possible to remove just lowest editpoly modifier ?

Anubis's picture

Sure it possible, i think

Sure it possible, i think so.
Now the function 'scan' from top and stop then find the 1st searched mod's, but you can rewrite it to 'scan from bottom.

my recent MAXScripts RSS (archive here)

Anubis's picture

u'r lucky man

Haha, you are lucky then some mod's survive after collapse, how you achieve this?

Else, to keep certain mod's on top of the stack, you need to backup them, remove too, collapse and then re-apply saved mods.

here you go a function...
(you can use it for other modifiers types)

fn CollapseToModClass objOwner modClass = (
	if objOwner.modifiers.count > 0 do ( --if there mod's at all
		local backMods = #(), run = true
		while run do ( -- backup mod's
			if ClassOf objOwner.modifiers[1] != modClass then (
				append backMods objOwner.modifiers[1]
				deleteModifier objOwner 1
			) else ( run = false )
			if objOwner.modifiers.count == 0 do run = false
		)
		collapseStack objOwner -- collapse
		if backMods.count > 0 do ( -- restore mod's
			for m = backMods.count to 1 by -1 do
				addModifier objOwner backMods[m]
		)
	)
)
-- usage:
for obj in selection do
	CollapseToModClass obj Edit_Poly

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.