How to select cylinder axis edge

How to select cylinder axis edge

Anonymous
Not applicable
985 Views
3 Replies
Message 1 of 4

How to select cylinder axis edge

Anonymous
Not applicable

Hello,

 

I'm completely new to MEL and I'm looking for a command or series of commands that can select a specific edge.

 

The targeted edge is any axis edge on a one sided cylinder pipe (made from combine[two no-cap cylinders] -> bridge [blend]). This edge will be have SelectContiguousEdges called on it to select a full length-wise array of edges.

 

I am unable to determine if the edges are numbered in a certain order based on axis subdivisions or another condition, so right now I have to manually record the edge selected and provide it to my script.

 

My next attempt is to:

select an arbitrary edge ->

SelectContiguousEdges ->

CreateCurveFromPoly ->

somehow select endpoints of the curve (perhaps start and end CV, but the pipe must be longer than it is wide between two continuous CVs, so it wouldn't be a the best solution) ->

check if the positions are almost equal ->

yes, it is a cylinder ring and check a different edge -> continue

no, it is what I'm looking for -> exit loop

0 Likes
986 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Using an assumption that edge 0 is always part of a cylinder ring,

select pipe edge 0 ->

polySelectSp -loop ->

polySelectSp -ring ->

select -tgl pipe edge [0:lastEdge]

provides me with all the axis edges.

 

jznhsi_0-1586884302089.png

 

Now, I'm wondering if there is a command for "reverse" select edge loop, so that only one of the axis edges is selected?

0 Likes
Message 3 of 4

Anonymous
Not applicable

I am abusing the fact that polyToCurve only creates one curve in order to force selection to one curve (first curve to be processed), which is what I need.

0 Likes
Message 4 of 4

jmreinhart
Advisor
Advisor
//get the tube
string $cylinder[] = `ls -sl`;
//get a list off all the verts
string $verts[] = `ls -fl ($cylinder[0] + ".vtx[*]")`;

string $length_edge;

$edge_found = false;

for ($vert in $verts){
    $edges = `polyListComponentConversion -fv -te $vert`;
    $edges = `ls -fl $edges`;
    if (size($edges) == 3){
        for ($edge in $edges){
            $faces = `polyListComponentConversion -fe -tf $edge`;
            $faces = `ls -fl $faces`;
            if (size($faces) == 2){
                $edge_found = true;
                select $edge;
                SelectContiguousEdges;
                break;
            };
          
        };
    };
    if ($edge_found){
        break;
    };

}

A cleaner way would be to check each vertex to see if it has 3 adjacent edges (so we know it's at the end of the tube). Then check those adjacent edges to find which one has 2 adjacent faces. And that edge is the one we want.