Rs.Area() method

This method, undocumented in the Help, actually autocompletes. It’s in geometry.py. However, if the input object causes the method to fail, it raises an error and the script bails. From geometry.py:

def Area(object_id):
    "Compute the area of a closed curve, hatch, surface, polysurface, or mesh"
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    mp = Rhino.Geometry.AreaMassProperties.Compute(rhobj.Geometry)
    if mp is None: raise Exception("unable to compute area mass properties")
    return mp.Area

So, (preferred solution) maybe it could be documented in the Help and it could be modified to just return None if something goes wrong instead of raising an error…

Or, (less preferable solution) - remove it from geometry.py… There is no equivalent on the vb Rhinoscriptsyntax side…

Thx, --Mitch

Added to the pile.

http://mcneel.myjetbrains.com/youtrack/issue/RH-29136

For future reference, below is a quick-fix to compute (crash-free!) the area of surfaces or polysurfaces. It skips invalid surfaces but doesn’t make the whole script fail. Works on Rhino 6.

import rhinoscript.utility as rhutil
import Rhino

def Area(object_id):
    "Compute the area of a closed curve, hatch, surface, polysurface, or mesh"
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    mp = Rhino.Geometry.AreaMassProperties.Compute(rhobj.Geometry)
    if mp is not None:
        return mp.Area
1 Like

Eight year old issue that has been fixed…