How to get a list of the index numbers of edges that make a face

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
How to get a list of the index numbers of edges that make a face

Heya,

So I've created a polyPlane, inserted two edge loops, and now I would like to be able to get a list of the edges that surround its faces.

What I have currently is


edgesOfFace = cmds.polyInfo('terrain', faceToEdge = True )

Result:

[u'FACE 0: 0 6 11 1 \n', u'FACE 1: 4 2 9 6 \n', u'FACE 2: 9 7 5 8 \n', u'FACE 3: 11 8 3 10 \n']


Is there any way I can get these index numbers in a list by themselves?
 
Old 04 April 2013   #2
you'll need to use some string parsing to get out the indices.

for example:

edgeData = 'FACE	  0:	  0	  6	 11	  1 \n'
edgeData = edgeData.strip() # strip off the newline characters
tokens = edgeData.split(' ') # separate by spaces
edgeIndices  = tokens[2:6] # extract just the indices
 
Old 04 April 2013   #3
Post

Cheers, I managed to find a different way though:

vtxFace=cmds.polyListComponentConversion('terrain.  f[1]', fromFace = True, toVertexFace= True)
edgeOrder = []

for vf in vtxFace:
    
    edge = cmds.polyListComponentConversion(vf, fromVertexFace = True, toEdge = True)
    edgeOrder.append(edge)


This ALMOST provides me with what I need. Unfortunately, the first polyListComponentConversion command gives a Result:


[u'terrain.vtxFace[6:7][1]', u'terrain.vtxFace[4][1]', u'terrain.vtxFace[2][1]']


Because of this, when I loop through my list and use the command again to convert from vertexFace to Edge, the terrain.vtxFace[6:7] gives me problems because it results in :

[u'terrain.e[6]', u'terrain.e[9]']

The problem is that this result is placed numerically rather than in the edge order. So if the command had just given terrain.vtxFace[6] and terrain.vtxFace[7] separately it would result in:

[u'terrain.e[9]', u'terrain.e[6]']

This would be far better for me because it has the edges in the order that they that make up the face.

*breathe out* phew, okay so my main question is:

Is there any way I can make the polyListComponentConversion command not give me a result where some of the components are like given like terrain.vtxFace[6:7] or[*] and instead are given separately as terrain.vtxFace[6] and terrain.vtxFace[7] ?
 
Old 04 April 2013   #4
polyInfo does give you the edges in order, just parse the results to extract the indices.
 
Old 04 April 2013   #5
Originally Posted by Animru94: *breathe out* phew, okay so my main question is:

Is there any way I can make the polyListComponentConversion command not give me a result where some of the components are like given like terrain.vtxFace[6:7] or[*] and instead are given separately as terrain.vtxFace[6] and terrain.vtxFace[7] ?


Yes, run the results through filterExpand

edges = cmds.polyListComponentConversion(cmds.ls(sl=1), toEdges=True)
expandedEdges = cmds.filterExpand(edges, sm=32, fp=True, ex=True) # always use full path names!


or

edges = cmds.polyListComponentConversion(cmds.ls(sl=1), toEdges=True)
expandedEdges = cmds.ls(edges, l=True, fl=True) # always use full path names!
 
Old 04 April 2013   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:23 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.