Hello I am trying to Get Elements intersected by a non-existing geometry (geometry generated in Dynamo) in a project with OOTB/Python nodes.
I tried:
-
Bimorph has a node to interect Solid with Elements but I would like to do something more simple.
-
get the geometry of elements but it takes ages and method discarded.
-
Bounding boxes from elements but the boxes are oriented to project Axis and it does not work for what I need.
Any more ideas?
My rule of thumb is: if you’re python scripting you’ve got access to the Revit API and once you have access to that context stay there and avoid any of the Dynamo libraries as they’re slow and create extra unecessary dependencies in your code.
Since you’re starting with a Dynamo solid, you’ll need a reference to RevitNodes so you can convert it to a Revit API Solid which breaks the rule of thumb, but the addendum here is: get into the Revit API context immediately and stay there (don’t mix and match calls to Dynamo libraries and the Revit API as it will impact on performance and result in garbage code).
Once converted to a Revit API Solid, you can now use the ElementIntersectsSolidFilter which is highly performant (it’s what BimorphNodes uses) compared to anything Dynamo has to offer. You can also optimise it and squeeze even more performance out of this method by throwing in a bounding box (quick) filter first to reduce the number of elements to intersect the Solid against.
The only pitfall is the geometry conversion which has a habit of failing especially if your Dynamo geometry is cylindrical.
4 Likes
Thanks @Thomas_Mahon really great answer. Do you mean with thumb that foreground blue lines of Dynamo geometry in Revit?
Getting geometry of all project elements crash dynamo, a way of filter elements can be a bounding box intersecting with a geometry and Getting solid geometry of those, but the process consumes loads of memory RAM and time, also some elements intersecting are missing because don’t contain solid geometry or don’t generate bounding box either, then I was looking for alternatives.
I was wondering if I can intersect lines to elements
to know if they are intersecting, without getting elements geometry as first instance. Bounding boxes can be massive because aligned with project axis
Well geometry in Dynamo isn’t necessarily a bad thing if that’s what you mean, it just depends on where it came from. If for example you extract solids or other geometry from a Revit element using Dynamo nodes, and then perform an intersection test on that geometry this is really bad and will scale horribly to the point where it becomes unusable.
So keeping on topic with Python scripts; in scenarios where you have a workflow which involves an unavoidable mix of Dynamo geometry and Revit elements (like the OP) then your first objective should be to transfer everything to the Revit API context at the entry point to your mainline function and only make calls to the Revit API from that point on.
You can obtain the bounding box of a Revit element with virtually no overhead using the Revit API (even the Dynamo node Element.BoundingBox is performant) - but what you should avoid is doing anything weird like extracting the geometry from an Element to get its bounding box, as this will render the performance advantages bounding boxes offer useless.
If you are using nodes (visual programming) to perform intersection operations then this will always be difficult to manage due to the way graphs execute as it carries huge memory penalties; it just isn’t the right tool for the job, whereas scripting (Python or C#) is.
Lastly you can intersect lines with elements but to do this even using the Revit API will require extracting the solid geometry. It wont provide any advantages over say, the ElementIntersectsElementFilter for example, if anything it would actually take longer. Basically you need to forget Dynamo workflows (without packages ) if you need to perform intersection tests on Revit Elements as this will invariably involve geometry extraction using Dynamo’s geometry library which is a futile endeavour; instead, focus on what the Revit API has to offer, such as the ElementIntersectsElementFilter, as this doesn’t need expensive geometry extraction to work and it can be optimised (like what BimorphNodes does) using bounding box quick filters to get surrounding elements and reduce the number of elements in an intersection test.
2 Likes