Notifications
Clear all

[Closed] getting face selection of PolyMeshObject

I’m feeling extremely stupid, but I can’t figure out a way to get the current face selection of a node with TurnToPoly modifier on top of the stack as bitarray.

When I put a temporary Edit_Poly modifier on top of it (which I don’t like, because I’m doing it in a loop for many objects) I can only get the face selection when the mod panel is active and redrawing (again, I can’t do it that way, because my loop would take forever to finish).

I can use snapShotAsMesh to get a bitarray of faces, but then it’s tri faces, not polys, and even if I convert that to the equivalent quads somehow, it’s still a dirty hack, for my taste.
There must be a simple way I’m overlooking??

5 Replies

your_node.getselection #face

Hi Denis,

Doesn’t work unfortunately:

test=Teapot()
  select test
  modPanel.addModToSelection (Edit_Poly ()) ui:on
  subobjectLevel = 4
  $.modifiers[#Edit_Poly].SetSelection #Face #{}
  $.modifiers[#Edit_Poly].Select #Face #{3..12, 15..16, 65..80, 83..84, 126..146, 189..190, 193..194, 197..198, 201..202, 205..206, 321..384}
  subobjectLevel = 0
  modPanel.addModToSelection (Turn_to_Poly ()) ui:on

(Quick and dirty macro recorder script to create an object similar to the ones I have to process…Mesh/Poly with selected faces in stack and TurnToPoly modifier on top)

now the code:

$.getselection #face

result:


 -- Error occurred in anonymous codeblock; filename: XXXXXX\; position: 20; line: 1
 -- Unknown property: "getSelection" in $PolyMesh:Teapot001 @ [0.000000,0.000000,0.000000]

You are right. GetSelection doesn’t work. Well. Only one way to get poly selection as I see is with undo off with redraw of to make a copy of the PolyMesh, convert the copy to editable poly, get selection, and delete the copy.

So here is the solution:

fn getPolyMeshObjectFaceSelection obj =
 (
 	with undo off with redraw off
 	(
 		tempEditablePoly=copy obj
 		convertToPoly tempEditablePoly
 		selectedFaces=polyOp.getFaceSelection tempEditablePoly
 		delete tempEditablePoly
 		selectedFaces
 	)
 )
 
 getPolyMeshObjectFaceSelection $

That’s a very ugly workaround if you ask me. I can’t believe that there is no better way…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s not too bad…


 fn getPolyMeshSelection node = if canconvertto node Editable_Poly do undo off
 (
 	disableRefMsgs()
 	new = converttopoly (copy node) 
 	faces = new.selectedfaces as bitarray
 	delete new
 --	format "node: % selection: %
" node faces
 	enableRefMsgs()
 	faces
 )
 

but it will be better to stay with the mesh face selection solution…