Get CenteLinesCurves from rebar

Get CenteLinesCurves from rebar

Anonymous
Not applicable
499 Views
2 Replies
Message 1 of 3

Get CenteLinesCurves from rebar

Anonymous
Not applicable

Hello, I´m a newbie in this area.

 

I´m trying to get the center lines curves from the rebar to create a detail line with the shape of the rebar.

 

I´m cannot find the method to do this operation.

 

Any help will be welcome.

 

This is my code, I´m stuck at this point.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.Attributes;

namespace CreateImageRebar 
{
    [TransactionAttribute(TransactionMode.Manual)] 
    [RegenerationAttribute(RegenerationOption.Manual)]
    public class ReinforcementDetail : IExternalCommand 
    {
        //Clase de filtro de selección
        public class RebarPickFilter : ISelectionFilter
        {
            public bool AllowElement(Element e)
            {
                return (e.Category.Id.IntegerValue.Equals((int)BuiltInCategory.OST_Rebar));
            }
            public bool AllowReference(Reference r, XYZ p)
            {
                return false;
            }
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 
        {
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;

            Reference pickedRef = null;
            

            Selection sel = uiApp.ActiveUIDocument.Selection;
            RebarPickFilter selFilter = new RebarPickFilter();
            pickedRef = sel.PickObject(ObjectType.Element, selFilter, "Seleccione una Armadura");
            //Obtener referencia
            Element el = doc.GetElement(pickedRef);
            Rebar myRebar = el as Rebar; 
               
500 Views
2 Replies
Replies (2)
Message 2 of 3

Mustafa.Salaheldin
Collaborator
Collaborator

Dear pipiyedu

I completed your code to accomplish the mission. Good luck.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.Attributes;

namespace CreateImageRebar
{
    [TransactionAttribute(TransactionMode.Manual)]
    [RegenerationAttribute(RegenerationOption.Manual)]
    public class ReinforcementDetail : IExternalCommand
    {
        //Clase de filtro de selección
        public class RebarPickFilter : ISelectionFilter
        {
            public bool AllowElement(Element e)
            {
                return (e.Category.Id.IntegerValue.Equals((int)BuiltInCategory.OST_Rebar));
            }
            public bool AllowReference(Reference r, XYZ p)
            {
                return false;
            }
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;

            Reference pickedRef = null;
            

            Selection sel = uiApp.ActiveUIDocument.Selection;
            RebarPickFilter selFilter = new RebarPickFilter();
            pickedRef = sel.PickObject(ObjectType.Element, selFilter, "Seleccione una Armadura");
            //Obtener referencia
            Element el = doc.GetElement(pickedRef);
            Rebar myRebar = el as Rebar;
            List<Curve> lc = myRebar.GetCenterlineCurves(true, true, false).ToList();
            return Result.Succeeded;
         }
     }
}
               

 


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

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you! I´ll try it!

0 Likes