MAXScript Frequently Asked Questions
I want to select the edges between different Material IDs in an Editable Poly object.
The following code implements a possible solution:
macroScript SelMatIDEdges category:"MXS Help"
--The ActionItem will only be enabled when a single object with
--Editable_Poly base object is selected:
on isEnabled return
selection.count == 1 and classof selection.baseobject == Editable_Poly
on execute do
theEP = selection.baseobject --get the base object of the selected object
edgeSelArray = #() --init. an empty array to collect the edges
eCount = polyOp.getNumEdges theEP --get the total number of edges
for e = 1 to eCount do --loop through all edges
--get the faces sharing the current edge
theFaces = (polyOp.getFacesUsingEdge theEP #(e)) as array
--if there are two faces sharing the edge,
if theFaces.count == 2 do
--compare their Material IDs. If different, collect the edge
if polyOp.getFaceMatID theEP theFaces != polyOp.getFaceMatID theEP theFaces do
append edgeSelArray e
--After checking all edges, select the collected ones
polyOp.setEdgeSelection theEP edgeSelArray
max Modify Mode -- switch to modify panel
modPanel.setCurrentObject theEP -- go to the BaseObject level
subObjectLevel = 2 --and go to Edge SubObject level to show the result
)--end on execute
primitive has 6 Material IDs assigned to its 6 sides.
In this example, a box with 4x4x4 segments was converted to Editable Poly.
Then the above script was executed.
Editable Poly Methods - Face Material IDs
Frequently Asked Questions