I want to filter the edge selection and create arrays containing connected edges, something like "edge selection elements". Edges from two arrays will never be connected, in other words will not share vertices.
The following pseudo-code describes a possible approach:
Get the current edge selection into a main selection array.
Create an empty array to hold the unconnected selections.
(A) Append a new empty array to it as a sub-array.
Note the index of the current sub-array.
Get the first edge from the main selection array.
Delete it from the main selection array, append to the current sub-array of the unconnected selections array.
For every edge in the new sub-array, get its corresponding vertices that define the edge.
For each of the two vertices, get their edges - this gives you all neighbor edges sharing a vertex with the current edge.
Loop through the neighbors and see if they appear in the main selection array.
If an edge is in the main selection array, delete it from there and append it to the current sub-array.
Finish the loop when you have checked all edges from the sub-array.
At this point, if all edges are connected, the main array will be empty. If it is not empty, there are edges unconnected to the selections you already collected.
Add a new empty sub-array to the collection array.
Repeat starting with (A).
The function is ready when there are no edges left in the main array.
This will give you as many sub-arrays as there are unconnected edge selections.
The following function implements the pseudo-code in MAXScript code:
SCRIPT
fn getEPolyUnconnectedEdgesSelections thePoly = ( --get the edge selection mainSelection = (polyOp.getEdgeSelection thePoly) as array --init. an array to collect sub-arrays with selections "elements" unconnectedSelections = #() --repeat until the main selection array is empty while mainSelection.count > 0 do ( --append a new empty sub-array: append unconnectedSelections #() --remember the current sub-array's index: currentSelCount = unconnectedSelections.count --append the first edge from the main selectionarray to the sub-array: append unconnectedSelections[currentSelCount] mainSelection[1] --and remove the first edge from the main selectionarray: deleteItem mainSelection 1 --initialize a counter: cnt = 0 --while the counter is less than the edges in the sub-array while cnt < unconnectedSelections[currentSelCount].count do ( cnt += 1--increase the counter by 1 --get the vertices of the current edge in the current sub-array: currentEdgeVerts = (polyOp.GetVertsUsingEdge thePoly unconnectedSelections[currentSelCount][cnt]) as array neigborEdges = #()--init. an array to collect neighbor --for every vertex in the current edge, for v in currentEdgeVerts do --add the edges used by the vertex to the neighbors array join neigborEdges ((polyOp.GetEdgesUsingVert thePoly v) as array) --for each neighbor edge, for edge in neigborEdges do ( --see if the edge is in the main selection array checkInSelection = findItem mainSelection edge --if it is, if checkInSelection > 0 do ( --delete the edge from the main array deleteItem mainSelection checkInSelection --and add it to the current sub-array append unconnectedSelections[currentSelCount] edge )--end if )--end for edge loop )--end while cnt )--end while mainSelection.count --finally, return the array containing the sub-arrays of connected edges: unconnectedSelections )--end fn -- create box and mesh: b = box() convertTo b editable_poly select b getEPolyUnconnectedEdgesSelections $Box001--call the function