Notifications
Clear all

[Closed] Collect continuous selected edges/vertices in order?

Thank you, that seems to be exactly what I needed, and was actually much simpler than my own initial attempt!

Hm… actually there seems to be a small issue with the convertEdgesToVerts function. Rather than trying to explain it, let me just use an image:

Here is a (clumsy) way of solving this problem, just replace this function:

fn convertEdgesToVerts obj edgeGroup =
(
	local vertsGroup = #()
	for i = 1 to edgeGroup.count do 
	(
		local verts = (polyop.getVertsUsingEdge obj edgeGroup[i]) as array
		
		if i == 1 and edgeGroup.count > 1 then 
		(
			local nextVerts = (polyop.getVertsUsingEdge obj edgeGroup[i + 1]) as array
			if findItem nextVerts verts[1] > 0 then
				swap verts[1] verts[2]
		)
		
		for j in verts do
			appendIfUnique vertsGroup j
	)
	vertsGroup
)

Thanks again!

If you have closed edges loops only, then the following algorithm may also work. It returns an array of both edges and vertices groups.

fn GetSortedEdgesVertsFromClosedLoops node =
    (
    	edges = polyop.getedgeselection node
    	
    	vertsGroups = #()
    	edgesGroups = #()
    	
    	while not edges.isempty and not keyboard.escPressed do
    	(
    		vGroup = #()
    		eGroup = #()
    
    		currentEdge = (edges as array)[1]
    		currentVert = ((polyop.getvertsusingedge node currentEdge) as array)[1]
    		
    		while currentEdge != undefined do
    		(
    			edges[currentEdge] = false
    			
    			append vGroup currentVert
    			append eGroup currentEdge
    			
    			nextVert = polyop.getvertsusingedge node currentEdge
    			nextVert[currentVert] = false
    
    			currentVert = (nextVert as array)[1]
    			currentEdge = (((polyop.getedgesusingvert node currentVert)*edges) as array)[1]
    		)
    		
    		append vertsGroups vGroup
    		append edgesGroups eGroup
    	)
    	return #(edgesGroups, vertsGroups)
    )
Page 2 / 2