Get the curves constructing a conduit fitting path

Get the curves constructing a conduit fitting path

Mustafa.Salaheldin
Collaborator Collaborator
515 Views
3 Replies
Message 1 of 4

Get the curves constructing a conduit fitting path

Mustafa.Salaheldin
Collaborator
Collaborator

Hello 

I'm trying to get the path of the conduit fitting by reading the center line geometry.

There is a way to do this in LookUp.

MustafaSalaheldin_0-1728635401660.png

I followed the same logic:

foreach (FamilyInstance fitting in fittings)
{
    GeometryElement geomElem = fitting.get_Geometry(options);
    LocationPoint? lp = fitting.Location as LocationPoint;

    IList<ElementId> centerlineIds = fitting.GetDependentElements(new ElementCategoryFilter(BuiltInCategory.OST_ConduitFittingCenterLine));

    StringBuilder sb = new StringBuilder();

    foreach (ElementId centerlineId in centerlineIds) {

        sb.AppendLine(centerlineId.ToString());

        Element? curve = doc.GetElement(centerlineId);

        if (null != curve)
        {


            IEnumerable<GeometryObject> curves = curve.get_Geometry(new Options { IncludeNonVisibleObjects = true, ComputeReferences = true });

            foreach (GeometryObject obj in curves)
            {
                    TaskDialog.Show("Revit", "curve found");
            }
        }
    }
}

First, I access all the instances of the Conduit Fittings in the model through element collector, then get their geometries. Using GetDependentElements I can reach the conduit fittings centerlines, which were supposed when I read their geometries (as done in LookUp) is to get the IEnumerable of the composing Arcs and Lines.

In line 20 of my code, I tried to cast to GeometryElement/GeometryObject/IEnumerable<GeometryObject> but they all return no objects.
Any ideas?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Accepted solutions (1)
516 Views
3 Replies
Replies (3)
Message 2 of 4

Mohamed_Arshad
Advisor
Advisor
Accepted solution

Hi @Mustafa.Salaheldin 

 

    I'm feeling proud to reply your query, Since you're one of the prime contributors in Autodesk Forums. You have written everything correct I have made small correct by adding View to options on extracting curves. Kindly check the below code snippet for additional reference.

 

Reference Code

 

IEnumerable<GeometryObject> curves = curve.get_Geometry(new Options { IncludeNonVisibleObjects = true, ComputeReferences = true, View=doc.ActiveView });

 

 

Hope this will Helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)

Message 3 of 4

Mustafa.Salaheldin
Collaborator
Collaborator

@Mohamed_Arshad Thanks mate, and I appreciate your nice words. Adding the view did the trick. Sometimes you need to refresh your memory and sometimes you are busy with other stuff. 😅
But thanks anyway.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 4 of 4

Mohamed_Arshad
Advisor
Advisor

Hi @Mustafa.Salaheldin 

 

Thank you for your kind words 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)