How to get the area of a surface in Python script

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