Modifier stack

Modifier stack

Anonymous
Not applicable
591 Views
1 Reply
Message 1 of 2

Modifier stack

Anonymous
Not applicable
From creating a cube the following code should select the top two triangles, invert that selection and then delete those newly selected faces. So far so good. However, I seem to run into trouble when there’s a modifier (or more) on the base cube.


(
--clear the listener
clearListener()

theObj = $

-- init. an array to collect faces
selArray = #{}
invArray = #{}

append selArray 3
append selArray 4

-- get the number of faces in the object
theMeshCount = theObj.numfaces

-- invert the array
for f = 1 to theMeshCount do
(
if (selArray == false) then invArray = true
else invArray = false
)

-- set the face selection in the EMesh
setFaceSelection theObj invArray

-- go to modify mode
max modify mode

-- select the mesh
select theObj

-- add the Mesh Select modifier
modPanel.addModToSelection (Mesh_Select ())

-- go to Face level
subObjectLevel = 3

--add a delete mesh, preserving the selection
modPanel.addModToSelection (deleteMesh())
)


So where am I going wrong?
0 Likes
592 Views
1 Reply
Reply (1)
Message 2 of 2

Swordslayer
Advisor
Advisor
Not at max now, but instead of working with the result of the stack (i.e. working with $) try working on the baseObject or using modPanel.getCurrentObject() instead (if the baseobject is already selected in the stack). This is what I would try:

(
--clear the listener
clearListener()

theObj = $
theMesh = theObj.baseObject.mesh
theMod = Mesh_Select()

-- init. an array to collect faces
selArray = #{3..4}
selArray.count = theMesh.numFaces
delete theMesh -- dispose of the .mesh object

-- go to modify mode
max modify mode

-- select the mesh
modPanel.setCurrentObject theObj

-- add the Mesh Select modifier
modPanel.addModToSelection theMod

-- go to Face level
subObjectLevel = 3

-- set the face selection on the modifier
setFaceSelection theObj theMod (-selArray)

--add a delete mesh, preserving the selection
modPanel.addModToSelection (DeleteMesh())
)
0 Likes