Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Varying Rebarset - Rebar Numbers

daniel
Enthusiast
Enthusiast

Varying Rebarset - Rebar Numbers

daniel
Enthusiast
Enthusiast

HI, 

I am trying to access all the Rebar numbers in my document..

 

Usually I do this by accessing the elements parameter (rebar number) and withdraw the value. 

 

In the case of varying rebar set, I can't find the values inside of the rebarset. Is this value not available ? ?? 

 

Is there any other way of retrieving all the numbers ? 

 

The use case is when I Want to duplicate a schedule, which has a filter on Rebar numbers, and I try to create multiple schedules with 

series of rebar numbers (1-20, 21-40... ) to put these schedules on sheets.. Then I need all the available values, so that I can populate a combobox.. 

 

Daniel 

 

0 Likes
Reply
Accepted solutions (1)
1,680 Views
4 Replies
Replies (4)

JimJia
Alumni
Alumni

Dear Daniel Aase,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue these days.

 

Yes, as far as I know, the API to access rebar number is to use element parameter. Regarding rebar set, Revit doesn't support this because it's not Rebar element.

 

Besides, in order to diagnose deeply, could you isolate your test project and send us a small, reproducible sample? Note, please do not send us any information you think are confidential to your company.

 

We appreciate your understanding and your patience again!


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes

manuel.solis.lopez
Contributor
Contributor
Accepted solution

Hi,
Varying rebar sets are special since each rebar in the set gets a "Rebar Number". In order to retrive a specific parameter for a bar position you could use ParameterValueProvider or Rebar.GetParameterValueAtIndex(...) Method

 

var pVal = rebar.GetParameterValueAtIndex(new RvtDB.ElementId(BuiltInParameter.REBAR_NUMBER), 0) as StringParameterValue;
var rebarNumber = pVal.Value;

JimJia
Alumni
Alumni

Thanks for Manuel.solis.lopez's sharing! The GetParameterValueAtIndex should be the answer! note that this API is available since Revit 2017.


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes

jamess166
Advocate
Advocate

Good day, I try to apply a filter rule based on the Rebar Number, as I have it in my code does not work, I do not know what I can be doing wrong. Thank you.

 

try
            {
                Element e = SelectElement(uidoc, sel) as Rebar;
                Rebar rb = e as Rebar;

                var parNumber = rb.GetParameterValueAtIndex(new ElementId(BuiltInParameter.REBAR_NUMBER), 0) as StringParameterValue;
                var rebarNumber = parNumber.Value;
                int valueNumber = Convert.ToInt32(rebarNumber);

                TaskDialog.Show("ff", valueNumber.ToString());

                //crear filtro
                ParameterValueProvider provider = new ParameterValueProvider(new ElementId(builtRebarNumber));
                FilterNumericRuleEvaluator evaluator = new FilterNumericEquals();
                FilterRule rule = new FilterIntegerRule(provider, evaluator, valueNumber);
                ElementParameterFilter filter = new ElementParameterFilter(rule);

                //collector
                FilteredElementCollector collector = new FilteredElementCollector(view.Document, view.Id);

                //obtener todas las barras
                collector.OfCategory(BuiltInCategory.OST_Rebar).WherePasses(filter);
                ICollection<ElementId> rebars = collector.ToElementIds();

                uidoc.Selection.SetElementIds(rebars);

            }
            catch { }
0 Likes