Retrieve solids from IFC

Retrieve solids from IFC

Anonymous
Not applicable
1,064 Views
6 Replies
Message 1 of 7

Retrieve solids from IFC

Anonymous
Not applicable

Hi there,

 

I am trying to get the geometryobjects from an linked IFC file in Revit 2019. With a Revit element you can use the .get_Geometry(options); to loop through the Geometryobjects in an element, but when I try this approach with an IFC, it doesn't result in any solids.

In my case I have an IFC stair (category stair) and I want to determine in what room it starts and to what room on the next level it leads.

 

 

 

0 Likes
Accepted solutions (1)
1,065 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Nevermind,

 

A little recursive function found solids at a very deep level 🙂

0 Likes
Message 3 of 7

jeremytammik
Autodesk
Autodesk

Dear Remy,

 

Thank you for your query and solution. Congratulations on sorting it out.

 

If it was tricky enough for you to post the question, may it also be worth while to share the solution showing how you implement this very deep recursion?

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

Ofcourse:

This is the first function:

 

private IEnumerable<XYZ> Sketchlines(Element stair)
{
List<XYZ> sketchlines = new List<XYZ>();
Options opt = new Options();
GeometryElement geoelem = stair.get_Geometry(opt);

foreach (GeometryObject go in geoelem)
{
GeometryInstance gi = go as GeometryInstance;
sketchlines.AddRange(GetSolid(gi));
}

return sketchlines.OrderBy(x => x.Z).ToList();
}

 

// call recursive

private List<XYZ> GetSolid(GeometryInstance gi)
{
List<XYZ> sketchlines = new List<XYZ>();
foreach (GeometryObject geob in gi.SymbolGeometry)
{
Solid sol = geob as Solid; //I know I need solid, so I am not testing for Faces
if (sol != null)
{
foreach (Edge edg in sol.Edges)
{
Curve cur = edg.AsCurve();
sketchlines.Add(cur.GetEndPoint(0));
sketchlines.Add(cur.GetEndPoint(1));
}
}
else
{
GeometryInstance gin = geob as GeometryInstance;
GetSolid(gin);
}
}
return sketchlines.OrderBy(x => x.Z).ToList();
}

0 Likes
Message 5 of 7

Anonymous
Not applicable

Sorry, this is not the solution 😞 I was looking at the wrong linked file which actually had a stair. The method described as above does not return sketchlines of IFC objects, since the solid does not have edges or faces.

 

So, still looking for a method to get this information. Anyone?

0 Likes
Message 6 of 7

Anonymous
Not applicable

Well, it turned out the approach I posted was correct afterall. I was lookat at the wrong file and that was why I kept getting "empty" solids. So, case closed.

0 Likes
Message 7 of 7

jeremytammik
Autodesk
Autodesk

🙂

 

Sounds like good fun...

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes