/// <summary>
 /// Create a Rebar from an existing reference
 /// </summary>
 /// <param name="rebar"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static RebarBarType FromExisting(Autodesk.Revit.DB.Structure.RebarBarType rebarBarType, bool isRevitOwned)
 {
     return(new RebarBarType(rebarBarType)
     {
         // Cannot access base classes internal bool IsRevitOwned
         //IsRevitOwned = isRevitOwned
     });
 }
        private void InitRebarFreeForm(IList <IList <Curve> > curves,
                                       Autodesk.Revit.DB.Structure.RebarBarType barType,
                                       Autodesk.Revit.DB.Element host)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var rebarElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Structure.Rebar>(document);



            bool changed = false;



            // Check for existing Geometry
            // TBI



            if (rebarElem == null || changed)
            {
                // Delete exsiting Rebar Element
                if (rebarElem != null && rebarElem.Id != ElementId.InvalidElementId)
                {
                    document.Delete(rebarElem.Id);
                }

                Autodesk.Revit.DB.Structure.RebarFreeFormValidationResult res = new Autodesk.Revit.DB.Structure.RebarFreeFormValidationResult();
                rebarElem = Autodesk.Revit.DB.Structure.Rebar.CreateFreeForm(document, barType, host, curves, out res);
                if (res != Autodesk.Revit.DB.Structure.RebarFreeFormValidationResult.Success)
                {
                    TransactionManager.Instance.ForceCloseTransaction();
                    throw new Exception(res.ToString());
                }
            }
            else
            {
                rebarElem.SetHostId(document, host.Id);
                rebarElem.ChangeTypeId(barType.Id);
            }


            InternalSetRebar(rebarElem);

            TransactionManager.Instance.TransactionTaskDone();


            if (rebarElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
Beispiel #3
0
        public static Dictionary <string, object> GetRebarTypeProperties(double cover, Revit.Elements.Element barType)
        {
            Autodesk.Revit.DB.Structure.RebarBarType revitBarType = (Autodesk.Revit.DB.Structure.RebarBarType)barType.InternalElement;

            return(new Dictionary <string, object>
            {
                { "BarDiameter", revitBarType.BarDiameter },
                { "StandardBendDiameter", revitBarType.StandardBendDiameter },
                { "StandardHookBendDiameter", revitBarType.StandardHookBendDiameter },
                { "StirrupTieBendDiameter", revitBarType.StirrupTieBendDiameter },
            });
        }
Beispiel #4
0
        /// <summary>
        /// Cover value to Offset value
        /// </summary>
        /// <param name="cover">Cover Value</param>
        /// <param name="barType">Rebar Bar Type</param>
        /// <returns>Offset</returns>
        public static double CoverToOffset(double cover, Revit.Elements.Element barType)
        {
            double offset = cover;

            if (barType.InternalElement != null)
            {
                Autodesk.Revit.DB.Structure.RebarBarType revitBarType = (Autodesk.Revit.DB.Structure.RebarBarType)barType.InternalElement;
                offset = cover + revitBarType.BarDiameter / 2;
            }

            return(offset);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="curve"></param>
 /// <param name="barType"></param>
 /// <param name="barStyle"></param>
 /// <param name="host"></param>
 /// <param name="startHook"></param>
 /// <param name="endHook"></param>
 /// <param name="startHookOrientation"></param>
 /// <param name="endHookOrientation"></param>
 /// <param name="normal"></param>
 /// <param name="useExistingShape"></param>
 /// <param name="createNewShape"></param>
 private Rebar(object curve,
               Autodesk.Revit.DB.Structure.RebarBarType barType,
               Autodesk.Revit.DB.Structure.RebarStyle barStyle,
               Autodesk.Revit.DB.Element host,
               Autodesk.Revit.DB.Structure.RebarHookType startHook,
               Autodesk.Revit.DB.Structure.RebarHookType endHook,
               Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
               Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
               Autodesk.Revit.DB.XYZ normal,
               bool useExistingShape,
               bool createNewShape)
 {
     SafeInit(() => InitRebar(curve, barType, barStyle, host, startHook, endHook, startHookOrientation, endHookOrientation, normal, useExistingShape, createNewShape));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="curve"></param>
 /// <param name="barType"></param>
 /// <param name="barStyle"></param>
 /// <param name="host"></param>
 /// <param name="startHook"></param>
 /// <param name="endHook"></param>
 /// <param name="startHookOrientation"></param>
 /// <param name="endHookOrientation"></param>
 /// <param name="normal"></param>
 /// <param name="useExistingShape"></param>
 /// <param name="createNewShape"></param>
 private RebarContainer(System.Collections.Generic.List <object> curve,
                        Autodesk.Revit.DB.Structure.RebarBarType barType,
                        Autodesk.Revit.DB.Structure.RebarStyle barStyle,
                        Autodesk.Revit.DB.Element host,
                        Autodesk.Revit.DB.Structure.RebarHookType startHook,
                        Autodesk.Revit.DB.Structure.RebarHookType endHook,
                        Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
                        Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
                        System.Collections.Generic.List <Autodesk.Revit.DB.XYZ> normals,
                        bool useExistingShape,
                        bool createNewShape)
 {
     SafeInit(() => InitRebarContainer(curve, barType, barStyle, host, startHook, endHook, startHookOrientation, endHookOrientation, normals, useExistingShape, createNewShape));
 }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="barType"></param>
        /// <param name="barStyle"></param>
        /// <param name="host"></param>
        /// <param name="startHook"></param>
        /// <param name="endHook"></param>
        /// <param name="startHookOrientation"></param>
        /// <param name="endHookOrientation"></param>
        /// <param name="normal"></param>
        /// <param name="useExistingShape"></param>
        /// <param name="createNewShape"></param>
        private void InitRebar(object curve,
                               Autodesk.Revit.DB.Structure.RebarBarType barType,
                               Autodesk.Revit.DB.Structure.RebarStyle barStyle,
                               Autodesk.Revit.DB.Element host,
                               Autodesk.Revit.DB.Structure.RebarHookType startHook,
                               Autodesk.Revit.DB.Structure.RebarHookType endHook,
                               Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
                               Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
                               Autodesk.Revit.DB.XYZ normal,
                               bool useExistingShape,
                               bool createNewShape)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var rebarElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Structure.Rebar>(document);


            // geometry wrapper for polycurves

            List <Curve> geometry = new List <Curve>();

            if (curve.GetType() == typeof(DynamoRebar.RevitPolyCurve))
            {
                DynamoRebar.RevitPolyCurve polycurve = (DynamoRebar.RevitPolyCurve)curve;
                geometry = polycurve.Curves;
            }
            else
            {
                geometry.Add((Curve)curve);
            }


            rebarElem = Autodesk.Revit.DB.Structure.Rebar.CreateFromCurves(document, barStyle, barType, startHook, endHook, host, normal, geometry, startHookOrientation, endHookOrientation, useExistingShape, createNewShape);

            InternalSetRebar(rebarElem);

            TransactionManager.Instance.TransactionTaskDone();


            if (rebarElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
Beispiel #8
0
        public static Dictionary <string, object> GetRebarTypeProperties(double cover, Revit.Elements.Element barType)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.Structure.RebarBarType revitBarType = (Autodesk.Revit.DB.Structure.RebarBarType)barType.InternalElement;
            var getDocUnits     = doc.GetUnits();
            var getDisplayUnits = getDocUnits.GetFormatOptions(RVT.UnitType.UT_Length).DisplayUnits;

            return(new Dictionary <string, object>
            {
                { "BarDiameter", RVT.UnitUtils.ConvertFromInternalUnits(revitBarType.BarDiameter, getDisplayUnits) },
                { "StandardBendDiameter", RVT.UnitUtils.ConvertFromInternalUnits(revitBarType.StandardBendDiameter, getDisplayUnits) },
                { "StandardHookBendDiameter", RVT.UnitUtils.ConvertFromInternalUnits(revitBarType.StandardHookBendDiameter, getDisplayUnits) },
                { "StirrupTieBendDiameter", RVT.UnitUtils.ConvertFromInternalUnits(revitBarType.StirrupTieBendDiameter, getDisplayUnits) },
            });
        }
Beispiel #9
0
        /// <summary>
        /// Cover value to Offset value
        /// </summary>
        /// <param name="cover">Cover Value</param>
        /// <param name="barType">Rebar Bar Type</param>
        /// <param name="autoconvert">Optional: Convert Units (default: false)</param>
        /// <returns>Offset</returns>
        public static double CoverToOffset(double cover, Revit.Elements.Element barType, bool autoconvert = false)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            var getDocUnits     = doc.GetUnits();
            var getDisplayUnits = getDocUnits.GetFormatOptions(RVT.UnitType.UT_Length).DisplayUnits;

            double offset = cover;

            if (barType.InternalElement != null)
            {
                Autodesk.Revit.DB.Structure.RebarBarType revitBarType = (Autodesk.Revit.DB.Structure.RebarBarType)barType.InternalElement;
                var diam = (autoconvert) ? RVT.UnitUtils.ConvertFromInternalUnits(revitBarType.BarDiameter, getDisplayUnits) : revitBarType.BarDiameter;
                offset = cover + diam / 2;
            }

            return(offset);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="barType"></param>
        /// <param name="barStyle"></param>
        /// <param name="host"></param>
        /// <param name="startHook"></param>
        /// <param name="endHook"></param>
        /// <param name="startHookOrientation"></param>
        /// <param name="endHookOrientation"></param>
        /// <param name="normal"></param>
        /// <param name="useExistingShape"></param>
        /// <param name="createNewShape"></param>
        private void InitRebarContainer(System.Collections.Generic.List <object> curves,
                                        Autodesk.Revit.DB.Structure.RebarBarType barType,
                                        Autodesk.Revit.DB.Structure.RebarStyle barStyle,
                                        Autodesk.Revit.DB.Element host,
                                        Autodesk.Revit.DB.Structure.RebarHookType startHook,
                                        Autodesk.Revit.DB.Structure.RebarHookType endHook,
                                        Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
                                        Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
                                        System.Collections.Generic.List <Autodesk.Revit.DB.XYZ> normals,
                                        bool useExistingShape,
                                        bool createNewShape)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var rebarElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Structure.RebarContainer>(document);

            // Parse Geometry

            List <List <Curve> > curvature = new List <List <Curve> >();

            foreach (object curve in curves)
            {
                List <Curve> geometry = new List <Curve>();

                if (curve.GetType() == typeof(DynamoRebar.RevitPolyCurve))
                {
                    DynamoRebar.RevitPolyCurve polycurve = (DynamoRebar.RevitPolyCurve)curve;
                    geometry = polycurve.Curves;
                }
                else
                {
                    geometry.Add((Curve)curve);
                }

                curvature.Add(geometry);
            }



            if (rebarElem == null)
            {
                ElementId stdC = Autodesk.Revit.DB.Structure.RebarContainerType.CreateDefaultRebarContainerType(DocumentManager.Instance.CurrentDBDocument);
                rebarElem = Autodesk.Revit.DB.Structure.RebarContainer.Create(DocumentManager.Instance.CurrentDBDocument, host, stdC);
            }
            else
            {
                //rebarElem.ClearItems();
                rebarElem.SetHostId(document, host.Id);
            }


            int counter = rebarElem.ItemsCount;

            for (int i = 0; i < counter; i++)
            {
                Autodesk.Revit.DB.Structure.RebarContainerItem item = rebarElem.GetItem(i);

                int index = GeometryMatches(item.ComputeDrivingCurves(), curvature);

                if (index == -1)
                {
                    rebarElem.RemoveItem(item);
                }
                else
                {
                    item.SetHookOrientation(0, startHookOrientation);
                    item.SetHookOrientation(1, endHookOrientation);
                    item.SetHookTypeId(0, startHook.Id);
                    item.SetHookTypeId(1, endHook.Id);
                    curvature.RemoveAt(index);
                    if (normals.Count > 1)
                    {
                        normals.RemoveAt(index);
                    }
                }
            }



            for (int i = 0; i < curvature.Count; i++)
            {
                // If there is only one normal in the list use this one for all curves
                XYZ          normal   = (normals.Count == 1) ? normals[0] : normals[i];
                List <Curve> geometry = curvature[i];

                rebarElem.AppendItemFromCurves(barStyle, barType, startHook, endHook, normal, geometry, startHookOrientation, endHookOrientation, useExistingShape, createNewShape);
            }



            // Update Quantity Parameter
            Autodesk.Revit.DB.Parameter quantityParameter = rebarElem.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS);
            Autodesk.Revit.DB.Structure.RebarContainerParameterManager containerParameters = rebarElem.GetParametersManager();
            containerParameters.AddOverride(quantityParameter.Id, curves.Count);


            InternalSetRebarContainer(rebarElem);

            TransactionManager.Instance.TransactionTaskDone();


            if (rebarElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="barType"></param>
        /// <param name="barStyle"></param>
        /// <param name="host"></param>
        /// <param name="startHook"></param>
        /// <param name="endHook"></param>
        /// <param name="startHookOrientation"></param>
        /// <param name="endHookOrientation"></param>
        /// <param name="normal"></param>
        /// <param name="useExistingShape"></param>
        /// <param name="createNewShape"></param>
        private void InitRebarContainer(System.Collections.Generic.List <object> curves,
                                        Autodesk.Revit.DB.Structure.RebarBarType barType,
                                        Autodesk.Revit.DB.Structure.RebarStyle barStyle,
                                        Autodesk.Revit.DB.Element host,
                                        Autodesk.Revit.DB.Structure.RebarHookType startHook,
                                        Autodesk.Revit.DB.Structure.RebarHookType endHook,
                                        Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
                                        Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
                                        System.Collections.Generic.List <Autodesk.Revit.DB.XYZ> normals,
                                        bool useExistingShape,
                                        bool createNewShape)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var rebarElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Structure.RebarContainer>(document);


            if (rebarElem == null)
            {
                ElementId stdC = Autodesk.Revit.DB.Structure.RebarContainerType.CreateDefaultRebarContainerType(DocumentManager.Instance.CurrentDBDocument);
                rebarElem = Autodesk.Revit.DB.Structure.RebarContainer.Create(DocumentManager.Instance.CurrentDBDocument, host, stdC);
            }
            else
            {
                rebarElem.ClearItems();
            }



            for (int i = 0; i < curves.Count; i++)
            {
                // If there is only one normal in the list use this one for all curves
                XYZ normal = (normals.Count == 1) ? normals[0] : normals[i];

                // geometry wrapper for polycurves

                List <Curve> geometry = new List <Curve>();

                if (curves[i].GetType() == typeof(DynamoRebar.RevitPolyCurve))
                {
                    DynamoRebar.RevitPolyCurve polycurve = (DynamoRebar.RevitPolyCurve)curves[i];
                    geometry = polycurve.Curves;
                }
                else
                {
                    geometry.Add((Curve)curves[i]);
                }

                rebarElem.AppendItemFromCurves(barStyle, barType, startHook, endHook, normal, geometry, startHookOrientation, endHookOrientation, useExistingShape, createNewShape);
            }

            InternalSetRebarContainer(rebarElem);

            TransactionManager.Instance.TransactionTaskDone();


            if (rebarElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="rebar"></param>
 private void InternalSetRebarBarType(Autodesk.Revit.DB.Structure.RebarBarType rebarBarType)
 {
     InternalRebar     = rebarBarType;
     InternalElementId = rebarBarType.Id;
     InternalUniqueId  = rebarBarType.UniqueId;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="barType"></param>
        /// <param name="barStyle"></param>
        /// <param name="host"></param>
        /// <param name="startHook"></param>
        /// <param name="endHook"></param>
        /// <param name="startHookOrientation"></param>
        /// <param name="endHookOrientation"></param>
        /// <param name="normal"></param>
        /// <param name="useExistingShape"></param>
        /// <param name="createNewShape"></param>
        private void InitRebar(object curve,
                               Autodesk.Revit.DB.Structure.RebarBarType barType,
                               Autodesk.Revit.DB.Structure.RebarStyle barStyle,
                               Autodesk.Revit.DB.Element host,
                               Autodesk.Revit.DB.Structure.RebarHookType startHook,
                               Autodesk.Revit.DB.Structure.RebarHookType endHook,
                               Autodesk.Revit.DB.Structure.RebarHookOrientation startHookOrientation,
                               Autodesk.Revit.DB.Structure.RebarHookOrientation endHookOrientation,
                               Autodesk.Revit.DB.XYZ normal,
                               bool useExistingShape,
                               bool createNewShape)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var rebarElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Structure.Rebar>(document);



            // geometry wrapper for polycurves

            List <Curve> geometry = new List <Curve>();

            if (curve.GetType() == typeof(DynamoRebar.RevitPolyCurve))
            {
                DynamoRebar.RevitPolyCurve polycurve = (DynamoRebar.RevitPolyCurve)curve;
                geometry = polycurve.Curves;
            }
            else
            {
                geometry.Add((Curve)curve);
            }


            bool changed = false;



            // Check for existing Geometry

            if (rebarElem != null)
            {
                foreach (Curve existingCurve in rebarElem.GetShapeDrivenAccessor().ComputeDrivingCurves())
                {
                    bool curveIsExisting = false;

                    foreach (Curve newCurve in geometry)
                    {
                        if (CurveUtils.CurvesAreSimilar(newCurve, existingCurve))
                        {
                            curveIsExisting = true; break;
                        }
                    }

                    if (!curveIsExisting)
                    {
                        changed = true;
                    }
                }
            }



            if (rebarElem == null || changed)
            {
                // Delete exsiting Rebar Element
                if (rebarElem != null && rebarElem.Id != ElementId.InvalidElementId)
                {
                    document.Delete(rebarElem.Id);
                }

                rebarElem = Autodesk.Revit.DB.Structure.Rebar.CreateFromCurves(document, barStyle, barType, startHook, endHook, host, normal, geometry, startHookOrientation, endHookOrientation, useExistingShape, createNewShape);
            }
            else
            {
                rebarElem.SetHostId(document, host.Id);
                rebarElem.SetHookTypeId(0, startHook.Id);
                rebarElem.SetHookTypeId(1, endHook.Id);
                rebarElem.SetHookOrientation(0, startHookOrientation);
                rebarElem.SetHookOrientation(1, endHookOrientation);
                rebarElem.ChangeTypeId(barType.Id);
            }


            InternalSetRebar(rebarElem);

            TransactionManager.Instance.TransactionTaskDone();


            if (rebarElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
 /// <summary>
 /// Initialize a Rebar element
 /// </summary>
 /// <param name="rebar"></param>
 private void InitRebarBarType(Autodesk.Revit.DB.Structure.RebarBarType rebar)
 {
     InternalSetRebarBarType(rebar);
 }
 /// <summary>
 /// Create from an existing Revit Element
 /// </summary>
 /// <param name="rebar"></param>
 private RebarBarType(Autodesk.Revit.DB.Structure.RebarBarType rebarBarType)
 {
     SafeInit(() => InitRebarBarType(rebarBarType));
 }
Beispiel #16
0
        /// <summary>
        /// Cuts a set of Rebars by Plane
        /// </summary>
        /// <param name="plane">Plane to cut by</param>
        /// <param name="rebarContainerElement">Rebar Container</param>
        /// <param name="firstPart">Return the first or the last part of the splitted elements</param>
        public static void Cut(Surface plane, Revit.Elements.Element rebarContainerElement, bool firstPart)
        {
            // Get Rebar Container Element
            Autodesk.Revit.DB.Structure.RebarContainer rebarContainer = (Autodesk.Revit.DB.Structure.RebarContainer)rebarContainerElement.InternalElement;

            // Get the active Document
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            // Open a new Transaction
            TransactionManager.Instance.EnsureInTransaction(document);

            // Get all single Rebar elements from the container
            List <Autodesk.Revit.DB.Structure.RebarContainerItem> rebars = rebarContainer.ToList();

            // Walk through all rebar elements
            foreach (Autodesk.Revit.DB.Structure.RebarContainerItem rebar in rebars)
            {
                // Buffer Rebar properties for recreation
                RVT.Structure.RebarBarType         barType              = (RVT.Structure.RebarBarType)document.GetElement(rebar.BarTypeId);
                RVT.Structure.RebarHookType        hookTypeStart        = (RVT.Structure.RebarHookType)document.GetElement(rebar.GetHookTypeId(0));
                RVT.Structure.RebarHookType        hookTypeEnd          = (RVT.Structure.RebarHookType)document.GetElement(rebar.GetHookTypeId(1));
                RVT.Structure.RebarHookOrientation hookOrientationStart = rebar.GetHookOrientation(0);
                RVT.Structure.RebarHookOrientation hookOrientationEnd   = rebar.GetHookOrientation(1);

                // create a list to store the remaining part of the curve after cutting it
                List <RVT.Curve> result = new List <RVT.Curve>();

                // get the center line curves of the rebar elements
                foreach (RVT.Curve curve in rebar.GetCenterlineCurves(false, true, true))
                {
                    // if the curve is a line or an arc consider it being valid
                    if (curve.GetType() == typeof(RVT.Line) || curve.GetType() == typeof(RVT.Arc))
                    {
                        // Get a DesignScript Curve from the Revit curve
                        Curve geocurve = curve.ToProtoType();

                        // Intersect the selected plane with the curve
                        foreach (Geometry geometry in plane.Intersect(geocurve))
                        {
                            // if the intersection is a point
                            if (geometry.GetType() == typeof(Point))
                            {
                                // Get the closest point to the intersection on the curve
                                Point p = geocurve.ClosestPointTo((Point)geometry);

                                // Split the curve at this point
                                Curve[] curves = geocurve.ParameterSplit(geocurve.ParameterAtPoint(p));

                                // If the curve has been split into two parts
                                if (curves.Length == 2)
                                {
                                    // return the first or the second part of the splitted curve
                                    if (firstPart)
                                    {
                                        result.Add(curves[0].ToRevitType());
                                    }
                                    else
                                    {
                                        result.Add(curves[1].ToRevitType());
                                    }
                                }
                            }
                        }
                    }
                }

                // If the result has some elements, create a new rebar container from those curves
                // using the same properties as the initial one.
                if (result.Count > 0)
                {
                    rebar.SetFromCurves(RVT.Structure.RebarStyle.Standard, barType, hookTypeStart, hookTypeEnd, rebar.Normal, result, hookOrientationStart, hookOrientationEnd, true, false);
                }
            }

            // Commit and Dispose the transaction
            TransactionManager.Instance.TransactionTaskDone();
        }
 private Rebar(IList <IList <Curve> > curves,
               Autodesk.Revit.DB.Structure.RebarBarType barType,
               Autodesk.Revit.DB.Element host)
 {
     SafeInit(() => InitRebarFreeForm(curves, barType, host));
 }