# Joining overlapping Surfaces to calculate net area

**URL:** <https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678>\
**Category:** Uncategorized\
**Created:** [April 18, 2023, 5:36pm UTC](https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678 "2023-04-18T17:36:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cianciale](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@cianciale](https://forum.dynamobim.com/u/cianciale)\
**Post date:** [April 18, 2023, 5:36pm UTC](https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678/1 "2023-04-18T17:36:06Z")

</div>

Hi all,  
I saw there is already a few similar topics but, unless I am doing something wrong, none of thems seem to be working with my case.  
I need to calculate the total net area of the vertical projections for these trees (picture1) Of course overlaps don’t have to be considered.

I tried to join the surfaces with the Surface.byUnion component. It creates a polysurface but then the area comes out exactly as the sum of the separate surfaces. what am I missing?

P.s. I also tried to extrude them all, apply boolean union and intersect the solid with a horizontal surface. Doesn’t seem to work either. Also it would be best to keep the script not too heavy as I need to make this work with hundreds of surfaces.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/0/b0f6a3521208d2f537ded9e5f5ab416aaf422076.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/dbbbfb3bc604cc7b4a60a26b0afc5d559c4de865.png)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [April 18, 2023, 6:40pm UTC](https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678/2 "2023-04-18T18:40:01Z")

</div>

Hello,  
going through solid seems to work contrary to your Post scriptum  
(green set 1 detail of 154,909m² +2)

 ![18 Avril Forum anglais repsurf_2023-04-18_08-34-51](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/c/9c8d0c0a237c19927baa0af5363351c8a62bc90a.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/8743db8d95384d7cadef7d7661a937b9a7771536.png)

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [April 19, 2023, 7:12am UTC](https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678/3 "2023-04-19T07:12:18Z")

</div>

This Python code should give you a boost. It’s not super efficient as it could over test content, but for me it typically runs in \<2 seconds and in a few dozen tests never suppassed 3.5 seconds to ‘merge 100 possibly overlapping circles’, which isn’t too shabby.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9bc6d17f1b781552d32c4c8c663e0f95c087c87f.png)

```auto
import clr #import the CLR or common language runtime
clr.AddReference('ProtoGeometry') #add the dynamo geometry library to the clr
from Autodesk.DesignScript.Geometry import Geometry, Surface #import the geometry and surface classes of the Dynamo geometry library

surfs = IN[0] #the list of surfaces from the Dynamo environment

for i in range(len(surfs)): #perform the following actions once for each item in the list, as at most we can have that many items
    surfSets = [] #set up an empty list for each surface set
    while surfs: #while there are items in the surfs list
        surfSet = surfs.pop() #pull one surface from the surfaces list
        for surf in surfs: #for each surface in the surfaces list
            if Geometry.DoesIntersect(surf, surfSet): #if the geometry of the surface intersects the surface set
                surfs.remove(surf) #remove the surface from the list of surfaces
                surfSet = Surface.ByUnion([surfSet,surf]) #build a new surfaces for the surfset by unioning the previous surfset and the intersecting surface
        surfSets.append(surfSet) #append the surfset to the surfsets list
    surfs = surfSets #set the surfs variable to the surfSets list

OUT = surfs #return the edited list of surfaces to the Dynamo environment

```

---

<div class="post-metadata">

**Author:** ![cianciale](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@cianciale](https://forum.dynamobim.com/u/cianciale)\
**Post date:** [April 20, 2023, 10:36am UTC](https://forum.dynamobim.com/t/joining-overlapping-surfaces-to-calculate-net-area/88678/4 "2023-04-20T10:36:44Z")

</div>

Thank you both so much, they both seem to work quite well
