Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dependance failed "PolyCurve.ByJoinedCurves" to rectify a non-closed boundary

Message 1 of 4
1837 Views, 3 Replies

Dependance failed "PolyCurve.ByJoinedCurves" to rectify a non-closed boundary

Hello Everyone,

I'm trying to use methods used by some dynamo nodes in my revit IExternalCommand.

But unfortunatly i've encountered an error which I can't really identify :

Failed to load the file or the assembly "libG.ProtoInterface.dll" or one of its dependence


The PolyCurve object is inside ProtoGeometry.dll which is referenced in my visual studio project.

Here are all my dependencies :


I've tried to join the curves from an area to create a curveloop, in my implementation I decompose Revit elements in DesignScript elements to make the calculation and decompose it back to revit element.

Here is the method :



#region Namespaces
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.Exceptions;

using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Runtime;
using Autodesk.DesignScript.Interfaces;

namespace sia
    public partial class geometry
        public class polycurve
            public static CurveLoop get_joined_loop(IList<IList<BoundarySegment>> sloops)
                CurveLoop final = null;
                List<Autodesk.DesignScript.Geometry.Curve> curves = new List<Autodesk.DesignScript.Geometry.Curve>();

                    foreach (IList<BoundarySegment> sloop in sloops)
                        foreach (BoundarySegment s in sloop)
                            var c = s.GetCurve();

                            Autodesk.DesignScript.Geometry.Point p1 = Autodesk.DesignScript.Geometry.Point.ByCoordinates(c.GetEndPoint(0).X, c.GetEndPoint(0).Y, c.GetEndPoint(0).Z);
                            Autodesk.DesignScript.Geometry.Point p2 = Autodesk.DesignScript.Geometry.Point.ByCoordinates(c.GetEndPoint(1).X, c.GetEndPoint(1).Y, c.GetEndPoint(1).Z);

                        break; //to avoid holes
                catch { }          

                PolyCurve p = PolyCurve.ByJoinedCurves(curves, 0.1);

                Autodesk.DesignScript.Geometry.Curve[] joined_curves = p.Curves();

                    foreach (Autodesk.DesignScript.Geometry.Curve curve in joined_curves)
                        double x1 = curve.StartPoint.X;
                        double y1 = curve.StartPoint.Y;
                        double z1 = curve.StartPoint.Z;

                        double x2 = curve.EndPoint.X;
                        double y2 = curve.EndPoint.Y;
                        double z2 = curve.EndPoint.Z;

                        XYZ pt1 = new XYZ(x1, y1, z1);
                        XYZ pt2 = new XYZ(x2, y2, z2);

                        Autodesk.Revit.DB.Curve new_curve = Autodesk.Revit.DB.Line.CreateBound(pt1, pt2);

                catch { }

                return final;




Did anyone have a suggestion ?

Is it good to convert revit object to another one and to go back after the calculations or is it a simple way ?

My goal is to succeed in using the libraries in dynamo inside my IExternalCommands.



Virone Lorenzo


Labels (1)
Message 3 of 4
in reply to: jeremy_tammik

Hi@jeremy_tammik and tks for your answer,


I found 2 answers which explain why designscript cannot work in an addin (outside dynamo) :



So, I will try a different approach using the API instead of trying to merge things which are not made to work together.


The link you gave reorganize the curves (and it's great) but doesn't join them to form a curveloop. Is it a way in the API to connect the curves together ? Maybe I need to find the intersection point of the curves projection to re-create them using this calculated point ?

My problem comes from the fact that area and room can work in revit while being slightly open. This helps the user but to perform operations I need to close this boundary.


Thanks again for your quick answer,

Virone Lorenzo

Message 4 of 4
in reply to: l.virone

I have definitely sorted such edges and joined them to form closed loops in the past, so one or two valid answer to your question ought to be found somewhere in the links I pointed out above.


To close the room boundary, you could ask it for its closed shell:


Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups

Rail Community