How to get the area of a surface in Python script

I am trying to recreate the OOTB node “Surface.Area” in Python. It is a part of a larger python script, so using the OOTB node complicates the code.

I have recreated the problem in a simpler form with the following code.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
surf = IN[0]
# Place your code below this line

out = Surface.Area(surf)

# Assign your output to the OUT variable.
OUT = out

Error message:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 11, in
TypeError: getset_descriptor is not callable

Any pointers and help are appreciated!

Heya,

Welcome to the community!

There are a few things I’m afraid… To start with, when pasting code into the forum, you want to hit the
image button so it formats nicely…

#Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

#The inputs to this node will be stored as a list in the IN variables.
surf = IN[0]

#Assign your output to the OUT variable
OUT = surf.Area

As to your code, you are trying to use Design Script, which is not the best documented language, there is a download here http://dynamobim.org/wp-content/links/DesignScriptGuide.pdf. I find it easiest to build the code in nodes, then use node-to-code (right click in an empty part of the window with the node(s) selected…

If you do that you’ll see that Area is a Property of the ‘surf’… So it doesn’t have () after it.

You will also note that OUT is the variable, python cares about the Case, so you want to get that right.

There are a few resources for learning python on the forum Python Nodes | The Dynamo Primer and here is a useful thread… Python Nodes Basics

Hope that helps :slight_smile:

Mark

1 Like

Thank you so much!

1 Like