[Closed] "Detach every poly to element" using Edit Poly Modifier
Hi
I,m trying to make “Detach every poly to element” using Edit Poly Modifier
macroscript DetachAllPolygonAsElements category:“My”
(
on isEnabled return
(
selection.count == 1 and classof (modPanel.getCurrentObject()) == Edit_Poly) and subObjectLevel == 4
)
on execute [color=cyan]do
[/color](
theObject = modPanel.getCurrentObject()
thePolys = (theObject.GetSelection #Face node:selection[1]) as array
PolyNumber = thePolys.count
for p = 1 to PolyNumber do
theObject.detachFaces obj #{p}
)
)
This is my script, but it keep causing “Runtime error: No such handler: #execute”. I can not figure out what is wrong.
Please sombody help me.
[size=1]
[/size]
Looks like you’re missing an opening parenthesis
classof (modPanel.getCurrectObject()) == Edit_Poly)
should be:
classof ((modPanel.getCurrectObject()) == Edit_Poly)
Hi,
This script should make what you want:
macroscript DetachAllPolygonAsElements category:"My"
(
on isEnabled return ( selection.count == 1 and classof (modPanel.getCurrentObject()) == Edit_Poly and subObjectLevel == 4 )
on execute do (
local theObject = modPanel.getCurrentObject()
local thePolys = ( theObject.GetSelection #Face node:selection[1] ) as array
for i=1 to thePolys.count do (
local thePolyToDetach = #{thePolys[thePolys.count]}
theObject.SetSelection #Face thePolyToDetach node:selection[1]
theObject.ButtonOp #DetachFace
deleteItem thePolys thePolys.count
)
)
)
And if you want just to detach all selected polygons in one object, it is:
on execute do (
local theObject = modPanel.getCurrentObject()
theObject.ButtonOp #DetachFace
)
I hope this helps