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.
Solved! Go to Solution.
Solved by jmreinhart. Go to Solution.
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.
Can't find what you're looking for? Ask the community or share your knowledge.