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.
1 Like
Hello,
going through solid seems to work contrary to your Post scriptum
(green set 1 detail of 154,909m² +2)
Cordially
christian.stan
4 Likes
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.
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
4 Likes
Thank you both so much, they both seem to work quite well
1 Like