Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get area of mesh face

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bmagner888
293 Views, 2 Replies

get area of mesh face

How do I get the (worldspace units) of the area of any given mesh face?  Looking for a python solution.

most faces are not rectilinear and might contain any number of edges, so getting the attaced verts and doing some sort of spatial calculation is a nightmarish idea.

 

OpenMaya.MItMeshPolygon has a getArea() function but I can't figure out how to jump through all the hoops to actually use it, because  OpenMaya makes you recast everything through a hundred different class instances just to do simple things.  And the documentation isn't very helpful.

 

def get_face_area( 'polySurface1.f[0]'):
    area =?????????????????????
    return area

Thanks for any help.

2 REPLIES 2
Message 2 of 3
jmreinhart
in reply to: bmagner888

 

 

import maya.api.OpenMaya as om2

def getMeshFaceArea(meshFace):
    # Get the mesh object as a dagPath
    selectionList = om2.MSelectionList()
    selectionList.add(meshFace)
    dagPath, component = selectionList.getComponent(0)
    
    # Create a polygon iterator
    meshIt = om2.MItMeshPolygon(dagPath,component)

    return meshIt.getArea(om.MSpace.kWorld)

Is there something specific about the documentation that you found difficult? I know I struggled when getting started with the API, so I'm happy to answer any questions.

 

Message 3 of 3
bmagner888
in reply to: jmreinhart

this is perfect.  thank you.

-b

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report