Zero Touch Node. Return wrapped Revit Curve

Hi Guys,

I have very recently started to get in to Zero Touch Node development. I have a very simple method that filters Areas by name and Level and retreives their boundary curves. The problem I am having is that I need to wrapp an Autodesk.Revit.DB.Curve in to a Revit wrapper. I don’t really know what should be the proper way of doing this since Autodesk.Revit.DB.Curve does not inherit from Autodesk.Revit.DB Element making it not possible to call ToDSType() on it. Also, is there any online documentation for the Revit namespace?

Any pointers would be great!

Here is the method:

using unwrappedRevitElement = Autodesk.Revit.DB.Element;
using wrappedRevitElement = Revit.Elements.Element;
using unwrappedRevitLevel = Autodesk.Revit.DB.Level;
using wrappedRevitLevel = Revit.Elements.Level;
using Curve = Autodesk.Revit.DB.Curve;


   [Autodesk.DesignScript.Runtime.MultiReturn(new[] { "Boundary Curves", "Area Names" })]
        public static Dictionary<string, object> GetAreasByProperties(List<wrappedRevitElement> areaObjects, wrappedRevitLevel level, string areaName) 
        {
            
            // Get current document
            Document doc = DocumentManager.Instance.CurrentDBDocument;

            // Initilaize transaction
            TransactionManager.Instance.EnsureInTransaction(doc);

            SpatialElementBoundaryOptions bOptions = new Autodesk.Revit.DB.SpatialElementBoundaryOptions();
 

            // Create Revit Element list
            List<unwrappedRevitElement> revitElements = new List<unwrappedRevitElement>();

            // Loop through all wrapped Revit Elements and unwrapp them 
            for (int i = 0; i < areaObjects.Count; i++)
            {
                revitElements.Add(areaObjects[i].InternalElement);
            }

            // Convert Dynamo Level to Revit Level
            unwrappedRevitLevel revitLevel = level.InternalElement as Autodesk.Revit.DB.Level;



            // List that stores output of boundary curves. Should be of wrapped curve type 
            List<Curve> areaBoundaryCurves = new List<Curve>();


            List<string> areaNames = new List<string>();

           
            foreach (var item in revitElements)
            {
               
                Area areaObj = null;
       
               
                if (item.Category.Name == "Areas")
                {
                    areaObj = item as Area;

                   
                    if (areaObj.Name == areaName && areaObj.Level.Name == revitLevel.Name)
                    {
                        areaNames.Add(areaObj.Name);

                        if (areaObj.Area <= 0) throw new ArgumentException("Area Element must have an Area greater than 0!");
                        else
                        {
                                                  
                            IList<IList<BoundarySegment>> boundSegments = areaObj.GetBoundarySegments(bOptions);
                    
                            for (int i = 0; i < boundSegments.Count; i++)
                            {
                                IList<BoundarySegment> data = boundSegments[i];

                                for (int j = 0; j < data.Count; j++)
                                {
                     

                                    Curve unwrappedRevitCurve = data[j].GetCurve();

                                    // Need to wrapp Revit Curve  ---> //  var wrappedCurve = unwrappedRevitCurve.ToDSType(true); ???

                                    areaBoundaryCurves.Add(unwrappedRevitCurve);

                                }
                            }

                        }
                    }


            }
        }

           // if(areaBoundaryCurves.Count==0) throw new ArgumentException("Boundary curves list is returning empty!");

            TransactionManager.Instance.TransactionTaskDone();

        

            return new Dictionary<string, object>
            {
                {"Boundary Curves", areaBoundaryCurves },
                {"Area Names", areaNames }

            };


        }

Hi,

for curves you should use .ToProtoType()
here you have a nice list of conversion functions:

Awesome