[Closed] move modifier in stack
hello!
how can i do such operation:
move the instanced FFD modifier in stack up or down? When i added it by hand, the ffd box is upon all objects selected. as using the
modPanel.addModToSelection (FFD_2x2x2 ())
But then i want to move it in each object in stack down, and using maxscript it breakes the box to the separate boxes around each object , while drag-n-drop by hand in stack is okay.
The only way i thought is to delete all modifiers upper , use modPanel.addModToSelection (FFD_2x2x2 ()), and return the deleted modifiers.
What can i do else?
Well you can use addModifier instead
theMod=FFD_2x2x2()
for x in selection do addModifier x theMod before:2
That will add the modifier before the second modifier from the top of the stack.
Because we made an instance of the modifier before doing the operation it will be instanced on all objects it is added to.
Hi Pen!
That’s not what i meant)
If you put FFD on some object set by hand, it seems that the ffb lattice is the only one to all the objects. That’s not true – it is of course unique to any object, but according to instancity and that the ModContextTM are aligned, it looks like identical.
When you move FFD by script by any method it adds and deletes this modifier, so it breaks the identity of the ffd latice on the objects. Now each object has it’s own lattice. You can eaily try it, or i can post screenshots.
So, i solved the problem using ‘setModContextTM’, ‘setModContextBBox’ functions, calculating them from the selectionset.
If you are suddenly interested i can post the code here =)
it couldn’t solve the problem of re-instancing. the only way that i see is to re-assign the stack of modifiers in new order using modPanel.addModToSelection
Hi Denis! Let’s see
-
Create 2 spheres, select them, add any FFD by hand – the lattice volume is one on both spheres, that’s ok. Delete FFD.
-
Select both spheres, execute
addModifier selection (FFD_2x2x2 ())
You can see that the lattice box surrounds each sphere separately, which is not good. If you use modPanel.addModToSelection instead off addModifier(), the result will be correct, but addModToSlection adds modifier only above all. So, let’s try to fix it.
So, we added Modifier by script, selected spheres, and run:
cx = selection.center
mi = selection.min
ma = selection.max
for s in (deepcopy (selection as array)) do
(
select s
max modify mode
x = modPanel.getCurrentObject()
setModContextBBox s x mi ma
pp = ((getModContextBBoxMin s x) + (getModContextBBoxMax s x) )/2 + s.pos
setModContextTM s x (matrix3 s.transform.row1 s.transform.row2 s.transform.row3 (pp - cx))
)
everything should be okay – as ffd was added by hand =)