model = Sketchup.active_model # Access the model ents = model.entities # Access the entities in the model sel = model.selection # Access selection object vertex_array = [] edges2 = [] for _Count1 in 1..7 vertex_array.clear # Clears the vertex_array to repopulate it with the newly added edge's vertices vertex_array = sel[_Count1 - 1].vertices edges2.clear # Clears the edges2 array to repopulate it with the newly added edge's vertices # Since the connector/short (spine) edges connecting the long (rib) edges are always descending, ... # ... find the vertex with the lowest value for the z-coordinate to identify the next set of edges, ... # ... where to find the next short (vertebrae) edge. if vertex_array[0].position.z.to_mm > vertex_array[1].position.z.to_mm edges2 = vertex_array[1].edges # Gathers the edges connected to the second vertex (index 1) to the array of edges else edges2 = vertex_array[0].edges # Gathers the edges connected to the first vertex (index 0) to the array of edges end # Now we get rid of the short edge that was last added to the selection, since it was included ... # ... in the edges2 array, as it is also connected to the vertex used to gather the edges. # after removingt this edge there would only be 3 edges in the edges2 array. _LastSelId = sel[_Count1 - 1].object_id.to_s for myCount in 0..(edges2.length - 1) if edges2[myCount].object_id.to_s == _LastSelId edges2.delete_at(myCount) end end # After getting rid of the short edge that was last added to the selection, of the 3 edges left, ... # the shortest one (a vertebrae) should be the one to be the next edge to add to the selection. _MinLengthEdge = [edges2[0].length, edges2[1].length, edges2[2].length].min for myCount2 in 0..(edges2.length - 1) if edges2[myCount2].length == _MinLengthEdge _MinLengthEdge = myCount2 end end # Now we just add the edge previously identified as the shortest in the edges2 array to the selection sel.add edges2[_MinLengthEdge] end