Getting the Family Instance Geometry Curves Boundary Using C#

Getting the Family Instance Geometry Curves Boundary Using C#

ahmadkhalaf7892
Advocate Advocate
635 Views
2 Replies
Message 1 of 3

Getting the Family Instance Geometry Curves Boundary Using C#

ahmadkhalaf7892
Advocate
Advocate

Hi Everyone I wanted to ask if I had a family instance in C# And I want to get the curves of it how can I achieve that using C#?

For example in the below picture you can see some red Lines, I wanted to ask how can I get these red lines as a curve from a family instance using the Revit ApI. I would appreciate any method or a way to help me get through it . 
All I need is to obtain the boundary curves from a familyinstance or an element .

0 Likes
636 Views
2 Replies
Replies (2)
Message 2 of 3

Mohamed_Arshad
Advisor
Advisor

Hi @ahmadkhalaf7892 
   

  There is no direct method to get the edge loop.  You can use get_Geometry() method and iterate the geometry to get the particular face. Kindly refer the below code for additional reference.

 

Reference Code:

            Options opt = new Options();
            opt.ComputeReferences = true;
            opt.DetailLevel = ViewDetailLevel.Fine;

            //Pass Family Instance to this method
            GeometryElement geoElem = element.get_Geometry(opt);

            //For Family Instance we neec Iterate for again into InstanceGeometry
            foreach (GeometryInstance inst in geoElem)
            {
                GeometryElement elem = inst.GetInstanceGeometry(Transform.Identity);

                //In Sometime if it is a Nested Family Need to Iterate again for the InstanceGeometry
                foreach (GeometryObject obj in elem)
                {
                    if (obj is Solid && (obj as Solid).SurfaceArea != 0)
                    {
                        Solid solid = obj as Solid;

                        FaceArray faceArray = solid.Faces;

                        foreach (Face face in faceArray)
                        {
                            //Get the Edge of Face which you needed
                            List<CurveLoop> edgeLoop = face.GetEdgesAsCurveLoops().ToList();
                        }

                    }
                }
            }

 

Hope this Helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 3 of 3

jeremy_tammik
Alumni
Alumni

The Building Coder shares several different examples illustrating different approaches, e.g.,

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes