Pipe with no BoundingBox, no Faces, no Volume - although seen in Revit

Pipe with no BoundingBox, no Faces, no Volume - although seen in Revit

Anonymous
Not applicable
848 Views
3 Replies
Message 1 of 4

Pipe with no BoundingBox, no Faces, no Volume - although seen in Revit

Anonymous
Not applicable

In my model I have several Pipe object (Autodesk.Revit.DB.Plumbing.Pipe), all of them Flex Ducts.

A few of them are very strange:

element.get_BoundingBox(null) returns null:

When traversing the geometry, including the subelements it contains just a single Solid, that has no volume, no faces, and no edges.

But yet the element is totally visible in Revit GUI.

 

How can I get the geometry of the object?

Am I missing something?

 

This is the code I use to traverse the element's geometry:

 

Options opt = new Options {IncludeNonVisibleObjects = true};
GeometryElement geomElem = element.get_Geometry(opt);
foreach (GeometryObject geomObj in geomElem)
{
    switch (geomObj)
    {
        case Solid geomSolid:
        { /* Handle */ break;}                
        case GeometryInstance geoInst:
            using (GeometryElement geoElem2 = geoInst.GetInstanceGeometry())
            {
                if (geoElem2 == null) {continue;}
                foreach (GeometryObject geoObj2 in geoElem2)
                {                        
                    switch (geoObj2)
                    {
                        case Solid solid:
                            { /* Handle */ break;}
                        case Mesh m:
                            { /* Handle */ break;}
                        case Curve c:
                            { /* Handle */ break;}
                        case Point p:
                        { /* Handle */ break;}
                        case PolyLine pl:
                            { /* Handle */ break;}
                        default:
                            throw new Exception("Unknown type");
                    }
                }
            }
            break;
        case Curve c:
        { /* Handle */ break;}
        case Point p:
        { /* Handle */ break;}
        default:
            throw new Exception("Unexpected element in GeometryElement");
    }
}
0 Likes
Accepted solutions (1)
849 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

I would assume that a flex duct isderived from the MEP curve class:

 

https://apidocs.co/apps/revit/2019/38714847-0f40-7021-aa79-2884c3a02ce2.htm

 

Ask it for its location curve.

 

Its geometry is probably simply an extrusion of its cross section along its location curve.

 

Cheers,

 

Jeremy

 



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

Message 3 of 4

Anonymous
Not applicable

Thank you for the answer.

 

I have 2 followup questions about that:

1) Is there any general way to get the geometry of an Element without checking it's exact type and having a specific handling for it?

I have a similar problem with other FamilyInstance objects that don't have any faces but do have a bounding box that encloses other parts of it (For example Taps of category "Plumbing Fixtures") that I want to be able to analyze.

Is there some way to get the geometry, no matter what type the Elements is?

2) Some of the other FlexDuct instances do have a valid geometry and can be analyzed completely. Why does it happen only with some of the elements?

 

 

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

The generic approach to retrieve geometry is the Element.Geometry property:

 

https://apidocs.co/apps/revit/2019/d8a55a5b-2a69-d5ab-3e1f-6cf1ee43c8ec.htm

 

Another approach is using the custom exporter:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.1

 

I just wish people would stop coming up with exceptional cases in which they do not work  🙂

 

Cheers,

 

Jeremy

 

P.S. Ours is not to reason why --- ours is but to do or die...

   



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