Node Geometry.DoesIntersect and Python Script

Hi, i`m trying to write a python script where I receive a List of Walls, and a List of Doors with XYZ points. I want to take these XYZ point and see if any wall line intersect with the Point. I can do it outside of Python script with the Geometry.DoesIntersect passing a XYZ point (from the window) and a Line ( from the Wall). But with python i get an Error saying i need Two geometry as a parameter and dont accept a line and a XYZ as the Node does.

DoesIntersect IntersectPython

 

Hi Marcelo,

Try changing Geometry.DoesIntersect node with cross Lacing.

Thanks for the reply, i dont have a problem with the node Geometry.DoesIntersect , it works fine, but i really need to make it works only using the Python script because i’m doing some complex work. So do you mean use cross lacing on the python script? If so how? Can you give me an example? Thanks in Advance

What’s your end goal, Marcelo? Doors always need to be hosted inside a wall. You can already check if a wall hosts any doors with nodes from the clockwork package or simply extract a door’s host.

2015-09-04_12-34-55

To perform a " Geometry.DoesIntersect" operation inside of python, you’ll need to loop through all the walls and then create a loop inside of that for each of the doors. You can’t use Dynamo’s lacing inside of a python script.

I dont want to use Dynamo lacing inside python, This is what i already have (All using python):

-An excell sheet with all the data for the Walls and Doors

-I already read all, loop from all the line on the sheet and create the walls based on that information

-Than i can loop through all the walls and place a door inside than based on the excel data. BUT i dont want to place a door in all walls , only the ones that are in the XYZ point that i got from the file, this is where i’m having trouble, because when i try inside the Python script Geometry.DoesIntersect(MyLineData,MyPointXYZData) i got an error “Geometry expected got Line” but the dynamo node Geometry.DoesIntersec outside the script i can pass the same Line and XYZ point and got no Error

I see. Try the following:

2015-09-04_22-23-25

1 Like

Dimitar thanks for your time, this way it works, but why if you take the Code block part, do it inside python ( the line and the point) it doesnt work??

Well roughly speaking, in DS only constructors need to preserve the constructor name. So when you’re creating a new point, line or a surface, you need to have a Point/Line/Surface.BySomething and that will generate a new object of the appropriate type.

All actions and queries need to be performed on an existing object. In the above case, the “Geometry.DoesIntersect” node performs an action on the curve object - Mycurve.DoesIntersect(something else).

Hope that makes sense :slight_smile:

But something like this should work dont you think?

Example:

MyPoint = XYZ(0,0,0)

StartP = XYZ(0,0,0)

EndP = XYZ(10,10,10)

MyLine = Line.CreateBound(StartP,EndP)

booleanInt = Geometry.DoesIntersect(MyLine ,MyPoint)

 

But with this i get the error “Geometry expected got Line” . So you are saying my line and point arent an object? How would you change this exactly code?

(Or if i try Intersect from Line class it expect a curve as input paramater not a Point )

Hi Marcelo,

The result of the above code is Revit geometry elements. Dynamo can not work directly with Revit elements. We’ll need to translate those to Dynamo’s native geometry first. Once translated, we’re free to use any of Dynamo’s methods on it.

2015-09-05_10-46-36

You can find more examples like the above here:

 

 

1 Like

Thanks a lot, it worked, you helped a lot. Just 1 last question where did you get the clr.ImportExtensions(Revit.GeometryConversion) ?

And just to note if someone else had the same problem. I was using a Point that i got from a dynamo node, it worked but it was wrong, if you print your EndPoint from your line you see the X=10 but if you print the same line after ToProtoType it is X = 304 because dynamo and revit use different metric. So i had to make an XYZ from my point than use .ToPoint() to make it have the same metric of ToProtoType

It’s mentioned in the link above. God catch on the point conversion - I missed that part.