Geometry Intersect not working

Hello,

I try to use the geometry.Intersect() to find the intersected geometry between two geometry. It worked before if I input use geometry as input. However, I want to use element as input this time(Like the captured image below). And errors happened in the python script. In what step do I go wrong?

Thanks.

ducts = UnwrapElement(IN[0]) 
rooms = UnwrapElement(IN[1]) 
	
duct = ducts[0].Geometry[Options()]
room = rooms[0].Geometry[Options()]
result = duct.Intersect(room) #Error on this line

OUT = result

Hello
Autodesk.Revit.DB GeometryElement (List) has no Intersect method.
You cannot use objects from one API (Revit API) to another API (Dynamo API) without conversion.

an example with Dynamo API

import sys
import clr
import itertools

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

elemsA = IN[0]
elemsB = IN[1]
intersect = []	
geoSetElemsA = elemsA[0].Geometry()
geoSetElemsB = elemsB[0].Geometry()
for geoa, geob in itertools.product(geoSetElemsA, geoSetElemsB):
	if geoa.DoesIntersect(geob):
		intersect.extend(geoa.Intersect(geob))

OUT = intersect

here is a useful link

4 Likes

thanks for your reply. Does my understanding in the grouping as below is correct?

room = rooms[0].Geometry[Options()] #Revit API
result = duct.Intersect(room) #Dynamo API

Moreover, how can I know which object is from Revit API or Dynamo API?
Is that everything from this doc is belonged to Revit API?
https://www.revitapidocs.com/2015/d8a55a5b-2a69-d5ab-3e1f-6cf1ee43c8ec.htm

About the conversion you mentioned, is that UnwrapElement covert the object Dynamo to Revit and I need to covert back in order to use the Intersect() ?

Thanks.

No, if you want to use Intersect method (Dynamo) duct and room must be Dynamo object (Dynamo Geometry object)

You can use GetType() method

Here some link about the wrapper and geometry conversion;

2 Likes