Hi, I have a script in 3ds max that detaches model elements by ID, but it doesn't work when I select multiple objects, can anybody fix this script?
Thanks in advance!
Here's the script
(
for obj in selection do
macros.run "Modifier Stack" "Convert_to_Poly"
(
(
local MatID = 1
while (polyop.getNumFaces $ > 0) do
(
$.selectByMaterial MatID
polyList = polyop.getFaceSelection $
if (polyList.count > 0) do
(
newName = (uniquename "DetachedObject")
polyOp.detachfaces $ polyList delete:true asnode:true name:newName
)
MatID += 1
)
)
)
)
Replies
macroScript explode_by_matid category:"Claudes Utils" tooltip:"explode by material id" ButtonText:"explode" icon:#("Standard_Modifiers", 22) ( fn explode_by_matid poly del_original = ( matids = #{}; for f = 1 to poly.numfaces do matids[polyop.getFaceMatID poly f] = true; for matid in matids do ( poly.selectByMaterial matid; detach_faces = polyop.getFacesByFlag poly 1; newName = uniquename "DetachedObject"; polyOp.detachfaces poly detach_faces delete:true asnode:true name:newName ) if del_original then delete poly; ) on execute do ( selected_objs = $selection as array clearNodeSelection redraw:false; for obj in selected_objs where canconvertto obj Editable_Poly do ( poly = convertToPoly obj; explode_by_matid poly true; ) ) on isEnabled do $selection.count > 0; )