Python getting an ordered edge loop selection trouble

Python getting an ordered edge loop selection trouble

Anonymous
Not applicable
3,316 Views
4 Replies
Message 1 of 5

Python getting an ordered edge loop selection trouble

Anonymous
Not applicable

Hello everyone.

 

I am currently trying to script a tool with Python for automating bridges operations based on the edge loop (or border) which is selected. The issue is that I need to have my edges sorted in the order they follow each others on the loop, so that I can split them in two disctinctive groups of edges that could be bridged together.

 

I do get the correct edges list following each other on simple shapes (spheres, cylinders, etc...) But if I try to make a selection on another shapes (for example a cube subdivided with a hole in it, I don't).

 

I use this line of code in order to get the edges in a good order

orderedEdges = cmds.ls(orderedSelection=True, flatten=True)

 

I use this line in order to be able to change the starting and the ending point depending on the user offset input

ReorderedEdges = orderedEdges[userOffset:] + orderedEdges[:userOffset]

 

And I split them into two different lists using these lines:

firstHalf = ReorderedEdges[:len(ReorderedEdges)//2]
secondHalf = ReorderedEdges[len(ReorderedEdges)//2:]

 

I Then substract a user input from the beginning and end of both new lists :

while i < userInput:
del firstHalf[len(firstHalf)-1]
del firstHalf[0]
i += 1

 

And it works perfectly on shapes that already had this idea of loop, selecting here these opposite faces, and allowing me to merge them together

 

Working Example - Selected edges are opposite and can be bridged togetherWorking Example - Selected edges are opposite and can be bridged together

 

But here is the type of error I get on more "complicated shapes". Here, juste a simple divided cube from which I deleted the top faces:

 

Here I cannot bridge (or use the offset input), because the selection for the 2 parts to bride are actually 4Here I cannot bridge (or use the offset input), because the selection for the 2 parts to bride are actually 4

 

If think I am doing something wrong, but I really have trouble figuring out what.

 

If you guys had any idea, I would really appreciate it. Thank you so much.

 

Teillet Martin

0 Likes
Accepted solutions (1)
3,317 Views
4 Replies
Replies (4)
Message 2 of 5

olarn
Advocate
Advocate

U sure your component selection are actually ordered?

http://help.autodesk.com/view/MAYAUL/2018/ENU/?guid=GUID-8C8BA1F4-59EE-4A02-BFE7-9193C0D6F5BE

 

Track selection order
This option allows Maya to start tracking the selection order of components.

 

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hello Olarn. Unfortunately yes, track selection order was turned on. The issue must come from somewhere else.

Thank you a lot for your input !

 

Martin

0 Likes
Message 4 of 5

Anonymous
Not applicable

The thing is that when I split into two part the original (tracked) selection order, and asks Maya to select the 1st half, I get different results based on my initial selection.

 

With the cap of a cylinder / an edge loop of a sphere. I get a continuous half a loop selected. However, with a hole in a subdivided cube (containing as many edges as the sphere and the cylinder cap's edge loops). I get : not a continuous half selected suite of edges, but two opposite quarters.

 

Would anyone have any idea where it could come from ? Or would know about a reliable way of getting from an edge loop selected by the user two equal and continuous/connected lists of edges ? I would really appreciate it. Thank you in advance.

 

Martin Teillet

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

I finally found a workaround !

 

The issue is that the maya selection order functions following loops, and not edge borders. That is why the edge order of a squarish shape was not actually following the edge border order.

 

I made a work around by creating a list using grow selesction and substracting the non-border edges from it. This way, it allows me to have an order I can deal with in the list.

 

Thank you for your help !

 

Martin

0 Likes