[Closed] Is there any way to keep my original ploygn selection
Hello
let say i select the ( 2,3,6,7,8,5 ) th polygons of an object by mouse click , so my actual selection order is #(2,3,6,7,8,5) and i like to keep this order ,
But when i say
myPloyselAr = polyOp.getFaceSelection myObject as array
it returns as #(2, 3, 5, 6, 7, 8) so max order the number .
is there any way to keep my original selection order i mean #(2,3,6,7,8,5)
the answer is clear – NO
you can use node events monitoring system to check sub-selection changed events. that’s the only possible solution
Thanks for the quick reply
Too bad.
Actually I try to find the middle of the common segment between 2 selected polygons and it was not so difficult , till i face this issue .
So it seems that i have to detach the polygons but now how to find the middle of intersected segment between t separated(or detached) polygons , i couldn’t find anything like that.
as Denis says theres no easy option as it comes from the way selections are stored internally as bitarrays, as a memory efficient method, which unfortunately have no “concept” of order.
Works properly only when each face is selected with single mouse click.
(
(
global rol_getFacesSelectionOrder
try(destroyDialog rol_getFacesSelectionOrder)catch()
rollout rol_getFacesSelectionOrder "Get Faces Order"
(
local poGetFaceSelection = polyOp.getFaceSelection
local poSetFaceSelection = polyop.setFaceSelection
button btn_getSelection "Get Faces Selection Order"
on btn_getSelection pressed do
(
if selection.count == 1 do
(
selObj = selection[1]
selFacesBA = poGetFaceSelection selObj
curSelFacesBA = poGetFaceSelection selObj
numSelFaces = selFacesBA.numberset
selFacesOrderArr = for i = 1 to numSelFaces collect undefined
for i = numSelFaces to 2 by -1 do with redraw off
(
max undo
tmpSelFacesBA = poGetFaceSelection selObj
lastSelFaceBA = selFacesBA - tmpSelFacesBA
selFacesBA -= lastSelFaceBA
selFacesOrderArr[i] = (lastSelFaceBA as array)[1]
)
selFacesOrderArr[1] = (selFacesBA as array)[1]
poSetFaceSelection selObj curSelFacesBA
format "selFacesOrderArr: %
" selFacesOrderArr
)
)
)
createdialog rol_getFacesSelectionOrder
)
in the example below i show how to monitor selection…
i do it for current editable poly node, and collect changes of its face selection.
try(destroydialog subSelectDialog) catch()
rollout subSelectDialog "Sub Select Dialog" width:210
(
checkbutton subsel_bt "Sub Select Monitor" width:192 align:#right offset:[4,0]
local sub_source = undefined
local sub_handler = undefined
local sub_selection = undefined
fn deleteHandler =
(
if iskindof sub_handler ChangeHandler do
(
deleteAllChangeHandlers id:#sub_sel_monitor
sub_handler = undefined
)
)
fn getSubSelection = if iskindof sub_source Editable_poly and iskindof sub_selection Array do
(
append sub_selection (polyop.getfaceselection sub_source)
)
on subsel_bt changed state do
(
node = modpanel.getcurrentobject()
if isvalidobj node and state then
(
sub_source = node
sub_selection = #()
sub_handler = when select node change id:#sub_sel_monitor do (getSubSelection())
)
else
(
deleteHandler()
format "node:% selection:%
" sub_source sub_selection
if iskindof sub_selection Array do
(
cur = #{}
for k=1 to sub_selection.count do
(
sel = sub_selection[k]
format "%: %
" k (sel - cur)
cur = sel
)
)
subsel_bt.state = off
)
)
on subSelectDialog open do
(
deleteHandler()
)
)
createdialog subSelectDialog