I want to select the edges between different Material IDs in an Editable Poly object.
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 edge = 1 to eCount do --loop through all edges ( --get the faces sharing the current edge theFaces = (polyOp.getFacesUsingEdge theEP #(edge)) 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 edge )--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
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.