How to run task of Geometry.DoesIntersect with Python code in Dynamo? I am using the OOTB node Geometry.DoesIntersect, it works but takes ages!! so I would like to run a similar task but using Python in Dynamo instead.
In this example I got a first list of Solids geometry and I want to check if a second list of other geometry that can be a point, line, solid is intersecting with each Solid of the first list.
I tried this but I wonder if there is better way to handle this:
import clr
clr.AddReference('RevitAPI') # Add reference to Revit API
from Autodesk.Revit.DB import *
# Define input lists of geometry
t1 = IN[0] # List of Solid geometry
t2 = IN[1] # List of geometry (point, line, or solid)
# Initialize an empty list to store the results
t3 = []
# Loop through each solid geometry in t1
for i in range(len(t1)):
# Initialize a sublist for each solid geometry
sublist = []
# Loop through each geometry in t2
for j in range(len(t2)):
# Check if the solid geometry intersects with the current geometry in t2
result = t1[i].DoesIntersect(t2[j])
# If the intersection is found, append the current geometry in t2 to the sublist
if result:
sublist.append(t2[j])
# Append the sublist to the main list of results
t3.append(sublist)
# Output the list of lists
OUT = t3