Notifications
Clear all
[Closed] Extending Edit Poly modifier not works as expected
Feb 29, 2020 7:31 am
The main code is from this thread: Extend Edit_Poly to have Select Face by Area
plugin modifier polySelByArea
name:"Select By Area"
classID:#(0x45b71d21, 0x637cf590)
extends:Edit_Poly replaceUI:false version:2
(
fn mainCbFn ev nd =
(
local ob = (GetAnimByHandle nd[1])
if isValidNode ob do
(
for m in ob.modifiers where
classOf m == polySelByArea and m.setUpdate do m.minArea
)
)
fn setFaceSelByArea obj len =
(
-- not works. no edges are selected
local edgeListBA = #{}
local numEdge = obj.getNumEdges()
for i = 1 to numEdge do
(
local vertPair = #()
vertPair.count = 2
vertPair[1] = obj.GetEdgeVertex i 1
vertPair[2] = obj.GetEdgeVertex i 2
local dist = distance (obj.getVertex vertPair[1]) (obj.getVertex vertPair[2])
if dist < len do
(
append edgeListBA i
)
)
format ": % \n" edgeListBA.numberSet
obj.SetEPolySelLevel #Edge
obj.SetSelection #Edge #{}
obj.SetSelection #Edge edgeListBA
-- this works and the faces are selected
-- local theSelection = #{}
-- local numFaces = obj.getNumFaces()
-- for f = 1 to numFaces do
-- (
-- local face_Area = obj.GetFaceArea f
-- if face_Area <= len do append theSelection f
-- )
-- obj.SetSelection #Face theSelection
-- obj.SetEPolySelLevel #Face
)
parameters params_Area rollout:rol_SelByArea
(
minArea type:#float animateable:true ui:spn_MinArea default:5
setUpdate type:#boolean ui:chb_SetUpdate default:false
on minArea set val do
(
setFaceSelByArea delegate val
)
on minArea get val do
(
setFaceSelByArea delegate val ; val
)
)
rollout rol_SelByArea "Select By Area"
(
spinner spn_MinArea "Min Area: " range:[0.01,1e9,5]
checkbox chb_SetUpdate "Auto Update"
button ObjectSelectButton "Select by Area"
)
on create do
(
if ::cbUpdateModSelByArea == undefined do
cbUpdateModSelByArea = NodeEventCallback geometryChanged:mainCbFn topologyChanged:mainCbFn
)
on postLoad do
(
NodeEventCallback geometryChanged:mainCbFn topologyChanged:mainCbFn
)
)
The code works OK when it has to select faces. When edges has to be seleced – nothing is selected.