Get vector of IFC element/ solid

Hello everyone,

Been scratching my head with this. I am trying to get the vector (illustrated via the red line) of a beam that I have linked in, but my attempt has given me ‘incorrect’ points (circled)

The points are given by using BoundingBox.MinPoint and BoundingBox.MaxPoint. These are both connected to BoundingBox.ByGeometry and then Element.Geometry

The larger bounding box is from using BoundingBox.ToCuboid which I used as I had suspicion this is how it was getting the points (circled) to create the line/ vector

This is part of the dynamo script

Hope you’re sitting down as I had to do a dive into IFC the other day for an account and learned a few things which might help you and others in the future.

IFC geometry is really crucial to understanding this problem. The IFC file structure is VERY accessible - so much so they actually provide a website to help anyone who needs to read or write IFC format. Obviously these formats vary based on decisions in the encoding process, what values were ‘included’ or not (ie: not enabling the analytical export), and more. In all cases the IFC format requires the curve location data you’re after (see axis 3d geometry). So it’s just a matter of the importer reading the data correctly and encoding it into the resulting file. However not all importers are created equally and they change over time, so you’re best bet in a Revit context is to use the most current version of Revit possible (IFC file format doesn’t align to the Autodesk release cycle so it’s more likely that Revit will miss something if you’re using older software).

Now with that out of the way, onto solving your actual problem.

  1. Assuming your IFC has the curve contained in it and that you’re using a current Revit build (I tested on 2020.1), you can likely get the location curve directly from the imported element with an Element.Curves node. If you really need the vector not the line that’s an easy enough conversion (Curve.PointAtParameter with [0,1] as the parameters and use the points to define the vector - likely you want to reverse it if the Y component is negative).

  2. If the IFC omitted the axis geometry and you only have a generic mesh/topology then you have to get creative with your geometry. You can try Element.Solids > Element.Verticies > Vertex.PointGeometry > Line.ByBestFitThroughPoints, which usually get you the linear axis of the beam to some extent. Things get funny if you have voids in the beam as they throw off the symmetry (you may want to pull the curve onto the topmost or bottommost surface in those cases to get the true direction) and with round tubes (where verticies may not be consistent enough for good results without some further review), but it will usually get you most of the way there where geometry manipulation is possible.

  3. If that fails you could try matching the IFC GUID in Revit with the GUIDs in the textural formatted IFC, and see if you can pull the location curve from the text and use that to build your curve directly in Dynamo. That’s a good bit more work on your part but it’s certainly doable.

Hopefully one of those three gets you (and future visitors) where you need to go.

2 Likes

Whoops, managed to hit the enter key whilst writing.

Thank you soo much for your time to write this out. I had given your methods a shot, but unfortunatley had no luck. After fiddling around with it some more I ended up exploding the geometry to get the surface with the greatest Z value then getting the greatest curve length to then create the vector.

The surface thicken was just a visual check to make sure it worked properly :slight_smile:

The List.GetItemAtIndex was used since there would be a double count and I just wanted one of the curves created to form my vector