CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-16-2013, 05:08 AM   #1
Animru94
New Member
portfolio
United Kingdom
 
Join Date: Feb 2013
Posts: 12
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-16-2013, 02:07 PM   #2
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
you'll need to use some string parsing to get out the indices.

for example:

Code:
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-17-2013, 04:17 AM   #3
Animru94
New Member
portfolio
United Kingdom
 
Join Date: Feb 2013
Posts: 12
Post

Cheers, I managed to find a different way though:

Code:
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:


Code:
[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 :

Code:
[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:

Code:
[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-17-2013, 03:29 PM   #4
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
polyInfo does give you the edges in order, just parse the results to extract the indices.
 
Old 04-17-2013, 09:10 PM   #5
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
Quote:
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

Code:
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

Code:
edges = cmds.polyListComponentConversion(cmds.ls(sl=1), toEdges=True) expandedEdges = cmds.ls(edges, l=True, fl=True) # always use full path names!
 
Old 04-17-2013, 09:10 PM   #6
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:42 PM.


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