[Maxscript] Finding UV Area per face

Hi, I’m trying to find a way to get the UV area of a face without adding an Unwrap_UVW modifier.

The modifier has a function to return this data but I can’t seem to find a way to do this purely in the polyops/meshops API because I need

Is there an API I’m missing? Thanks for any help :slight_smile:

You can get an area of each face as a half of cross product of its two edge vectors.

There doesn’t seem to be a way to get per poly UV area in Max’s API.

I solved this by doing the following in pseudo code:

-- triToPolyLookup: lookup table, indices are tri id, value is poly id
-- loop through poly indices of EditablePoly
  -- build a [triangle to polygon lookup table](https://forums.autodesk.com/t5/3ds-max-programming/get-face-poly-by-face-mesh-in-maxscript/td-p/7552039)

-- nodeMesh: snapshot of EPoly node as mesh tri
-- polyUvAreas: temp array of poly UV areas, indexed by poly id
-- loop through tri indices of nodeMesh
  -- meshop.getMapFace of triangle
  -- [calculate area of triangle](https://stackoverflow.com/questions/451426/how-do-i-calculate-the-area-of-a-2d-polygon) using getMapFace values
  -- add triangle UV area to polyUvAreas, using poly index from triToPolyLookup

current_unwrap_uv_modfiy= Unwrap_UVW()
addModifier obj current_unwrap_uv_modfiy

current_unwrap_uv_modfiy.edit()
subObjectLevel = 3 --1 is vtx 2 is edge 3 is face
max select all – edit here to fit your task

unwrap_mod= modpanel.getcurrentobject()
selected_face = unwrapmod.getselectedfaces()
current_unwrap_uv_modfiy.getArea selected_face &mX &mY &mWidth &mHeight &mAreaUVW &mAreaGeom

COPY/PASTE channel data from UV to mesh
now you have your UVW transferred into XYZ space, you can easily calculate face area and do other mesh-related things with your UV.