How do I Select Edges Between Materail IDs?

MAXScript Frequently Asked Questions

A user asked:

I want to select the edges between different Material IDs in an Editable Poly object.

Answer:

The following code implements a possible solution:

 

Script:

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[1].baseobject == Editable_Poly

 

 

--When executed,

on execute do

(

theEP = selection[1].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[1] != polyOp.getFaceMatID theEP theFaces[2] do

append edgeSelArray e

)--end if

)--end loop

 

--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

)--end macroScript

 

 

Select_MaterialID_Edges.gif

A Box 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.

See also

Editable Poly Methods - Face Material IDs

Frequently Asked Questions