[Closed] Copy Edit_Poly modifier problem
I’ve got an issue copying Edit_Poly modifiers from one object to another. I’ve got an array of flat shapes with multiple splines. I’m extruding the splines with random heights. I need to keep a stack to enable or disable the extrusions, so I’m using an Edit_Poly modifier. Applying the random extrusions takes a bit of time, so I’d like to do that once and copy that modifier to the other objects.
When I copy an Edit_Poly modifier by hand, the extrusions are working nicely, however when I do this by script the extrusions aren’t applied. I’m wondering if I miss a step. Check out the example.
(
--the plane and box have the same amount of faces, though this isn't strictly necessary
thePlane = plane lengthsegs:2 widthsegs:3
theBox = box lengthsegs:1 widthsegs:1 heightsegs:1 pos:[50,0,0]
--set up the edit poly with the extrusions
theMod = Edit_Poly()
addModifier thePlane theMod
max modify mode
select thePlane
subObjectLevel = 4
theMod.extrudeFaceHeight = 20
theMod.SetOperation #ExtrudeFace
theMod.extrudeFaceType = 2
theMod.SetSelection #Face #{}--clear selection
theMod.Select #Face #{1,6}--select some faces
theMod.Commit()
subobjectLevel = 0
--copy the modifier to the box. the extrusions don't work
select theBox
addModifier theBox (copy theMod)
)
If you copy the modifier from the plane to the box by hand, the 2 faces are extruded. Does anyone know how to do this by script?
In this example I tried epoly modifier in animation mode.
Also U need to check if both geo have similar number of polygons
delete objects
obj_plane = Plane length:100 width:100 pos:[150,0,0] isSelected:on
ep = edit_poly animationMode:1 currentOperation:41 --Extrude Polygon
addmodifier obj_plane ep ; max modify mode
subObjectLevel = 4
ep.select #Face #{2,7,12,15}
ep.extrudeFaceHeight = 20
ep.extrudeFaceType = 1
obj_box = Box lengthsegs:3 widthsegs:3 heightsegs:3 length:50 width:50 height:50
fn instanceEPoly mody obj = if isKindOf mody Edit_poly and mody.animationMode == 1 do
(
if GetCommandPanelTaskMode() != #modify do SetCommandPanelTaskMode #modify
node = (refs.dependentNodes mody)[1]
format "NODE %
" node
--with redraw off
(
--select node
modPanel.setCurrentObject mody
bitarray = mody.GetSelection #Face
format "FACES %
" bitarray
select obj
modPanel.addModToSelection mody
subObjectLevel = 4
mody.select #Face bitarray --select:off
)
)
instanceEPoly (obj_plane.modifiers[#Edit_Poly]) obj_box
It is discussed here(I think) – when Edit Poly modifier is copied by script the changes of the geometry are not transferred to the new object. The “copy” command does not works.
Hi Kostadin,
In animation mode this modifier preserves all extrusion options but not selected faces.
What is the best way to force it to refresh selection? Any suggestion?
In your example the Edit_poly modifier is defined before to be applied to the objects.
If the Edit_Poly modifier is already applied to one object(parent) and the geometry is changed – can you copy the modifier to another object(child). The “child” object must receive all geometry changes of the “parent” object? This can be done manualy, but can it be done by script?
i spent many days of my life trying find any solution to copy correctly modifiers between nodes. there is NO solution via mxs. the same answer is for question: “How to copy skin modifier?”
the answer is – nohow!
And conclusions would be:
Some modifiers for tree most important areas (modeling, unwraping and animation [rigging and skining] allow only manually cloning but not via mxs.)
Great!
i can tell you a little more… there is no universal a sdk solution as well. how the max pastes copied modifiers is ‘black box’. i couldn’t find any clue about this matter in sdk examples and documentation.
This applies an active copy of the editpoly to the box.
Might be a workaround sometimes.
(
--the plane and box have the same amount of faces, though this isn't strictly necessary
thePlane = plane lengthsegs:2 widthsegs:3
theBox = box lengthsegs:1 widthsegs:1 heightsegs:1 pos:[50,0,0]
--set up the edit poly with the extrusions
theMod = Edit_Poly()
addModifier thePlane theMod
max modify mode
select thePlane
subObjectLevel = 4
theMod.extrudeFaceHeight = 20
theMod.SetOperation #ExtrudeFace
theMod.extrudeFaceType = 2
theMod.SetSelection #Face #{}--clear selection
theMod.Select #Face #{1,6}--select some faces
theMod.Commit()
subobjectLevel = 0
--copy the modifier to the box. the extrusions don't work
select theBox
-- addModifier theBox (copy theMod)
base = $Box001.baseobject
instanceReplace $Box001 $Plane001
InstanceMgr.MakeObjectsUnique #($Box001) #prompt
$Box001.baseobject = base
theBox
)