CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-13-2008, 06:45 PM   #1
AtrusDni
Maya Monkey
 
AtrusDni's Avatar
portfolio
Michael Cook
TD
Stargate Digital
Pasadena, California, USA
 
Join Date: Feb 2003
Posts: 468
Send a message via AIM to AtrusDni Send a message via Yahoo to AtrusDni
Python Help! - Get UVs from Face

I need to be able to find out what uvs are associated with a face, but in python. Any ideas anyone?
 
Old 10-13-2008, 09:57 PM   #2
DOor
RiskySnail
portfolio
Eric Lenerville
Midway Games
Aurora, USA
 
Join Date: Jul 2007
Posts: 114
I came across something similar to this recently. I worked in MEL but the commands I used are also available in python.

for each face get a list of vertexFaces (getAttr <obj>.vtxFace[*][faceId])
then convert those vtxFaces into UVs using polyListComponentConversion.

you will have to look at the documentation for hte polyListComponentConversion command because I dont know the python syntax off the top of my head. you could use polyListComponentConversion to convert the face into vtxFaces but its faster just to use the getAttr. knowing python can have multi-dimensional arrays it might even be better to getAttr on all the vtxFaces at once.

I wish I knew more about the maya open API because I am betting theres a faster method you could use but I know the above works and keeps the UVs in the proper order.
__________________
- elenerville
 
Old 10-14-2008, 07:00 PM   #3
Norb
Frequenter
 
Norb's Avatar
...
Technical Artist
Electronic Arts Canada
Canada
 
Join Date: Jul 2002
Posts: 266
This should do the trick...

Code:
import maya.cmds as mc #store original selection saSel = mc.ls(sl=True) print 'Selection: ' + saSel[0] #get faces from selected object mc.select(mc.polyListComponentConversion(saSel[0], toFace=1), r=1) saFaces = mc.ls(sl=1,fl=1) #iterate through the faces and print out the uv's with them for sFace in saFaces: print ' FACE: ' + sFace mc.select(mc.polyListComponentConversion(sFace, toUV=1), r=1) saUVs = mc.ls(sl=1, fl=1) for sUV in saUVs: print ' UV: '+ sUV
 
Old 10-14-2008, 10:23 PM   #4
AtrusDni
Maya Monkey
 
AtrusDni's Avatar
portfolio
Michael Cook
TD
Stargate Digital
Pasadena, California, USA
 
Join Date: Feb 2003
Posts: 468
Send a message via AIM to AtrusDni Send a message via Yahoo to AtrusDni
Awesome, thanks so much for the helps guys, Ill give it a shot.
 
Old 10-14-2008, 10:23 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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 12:00 PM.


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