i'm slowly converting to max, but want some customization in the toolset, and i encountered a wall.
I'm really just discovering maxscript and i can't find a way to get the sub object selection count in editable poly.
It's really frustrating because the values are given in the modifier tab

Can you help me ?
Thanx.
Replies
Nodes:
- Node Common Properties, Operators, and Methods
Editable Poly Stuff:
- Interface: EditablePoly
- Editable_Poly Methods
Array and BitArray
- Array Values
- BitArray Values
( -- create a plane and convert it to Editable Poly local theNode = convertToPoly(Plane()) -- get the Base Object of the plane node -- the first element at the bottom of the modifier stack -- in this case is not needed because there is only one item, but is a good practice -- in this case theBase is a pointer to the Editable Poly local theBase = theNode.baseObject -- set the selection at vert level to verts from 1 to 5 and from 10 to 17 polyOp.setVertSelection theBase #{1..5, 10..17} -- get current vert selection -- baVertSelection is a type BitArray local baVertSelection = polyOp.getVertSelection theBase -- get the count of elements in baVertSelection BitArray local iVertSelectionCount = baVertSelection.numberSet -- print vert selection in the listener format "Current vert selection is: %, made by % elementsn" baVertSelection iVertSelectionCount -- Same goes for Edges and Faces -- Edges polyOp.setEdgeSelection theBase #{6..9, 15..17, 20} local baEdgeSelection = polyOp.getEdgeSelection theBase local iEdgeSelectionCount = baEdgeSelection.numberSet format "Current edge selection is: %, made by % elementsn" baEdgeSelection iEdgeSelectionCount -- Faces (Polys) polyOp.setFaceSelection theBase #{1..2, 7, 9..14} local baFaceSelection = polyOp.getFaceSelection theBase local iFaceSelectionCount = baFaceSelection.numberSet format "Current face selection is: %, made by % elementsn" baFaceSelection iFaceSelectionCount )Edit Note: elementsn should be elementsBACKSLASHn to jump to a new line. The html eats it away.
Press F11 to open the MaxScript listener. After the execution of this code you can select the plane and by cycling through sub-object levels, verify the actual selections.
I need Max to return the number of Elements/SubObjects (4 in this test case). I tried getOpenEdges and converting these to FaceSelections and reading those but I'm stuck now comparing these to get the number of Elements.
Am I on the right track and how could this comparison work or is there an easier way to do this? (why is there no getNumElements
Edit: I think I got it, have to test it though:
Create a bitArray with all open Edges
Select the first Edge
Set NumberOfElements +1
Convert to Element Selection
Convert to Edge Selection
Subtract those Edges from the bitArray
Select the next Edge and loop.
Edit: It worked
global alledges = #{} addElement = false emptyedges = #{} alledges += polyop.getOpenEdges $.baseobject alledgesComp = alledges numberOfElements = 0; for i in alledges do ( $.EditablePoly.SetSelection #Edge #{i} $.EditablePoly.ConvertSelection #Edge #Element $.EditablePoly.ConvertSelection #Element #Edge alledges -= polyOp.getEdgeSelection $.baseobject for i in (alledgesComp - alledges) do ( addElement = true ) if (addElement == true) do ( numberOfElements += 1 ) addElement = false alledgesComp = alledges ) format "%\n" numberOfElements