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

Get center bar of a Rebar Layout

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1264 Views, 5 Replies

Get center bar of a Rebar Layout

Anonymous
Not applicable

Hi All,

 

I'm looking a way to get the center Rebar from a Rebar Layout (Maximum spacing). I need to get this element to get its Centerline to create a DetailLine in the same position.

 

Any thoughts?

 

Thanks in advance!

0 Likes

Get center bar of a Rebar Layout

Hi All,

 

I'm looking a way to get the center Rebar from a Rebar Layout (Maximum spacing). I need to get this element to get its Centerline to create a DetailLine in the same position.

 

Any thoughts?

 

Thanks in advance!

5 REPLIES 5
Message 2 of 6
jeremytammik
in reply to: Anonymous

jeremytammik
Autodesk
Autodesk

I asked the development team for you...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

I asked the development team for you...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable

Thanks @jeremytammik! I'll be very attent to hear from you.

 

Regards!

0 Likes

Thanks @jeremytammik! I'll be very attent to hear from you.

 

Regards!

Message 4 of 6
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Hi @jeremytammik , by now I managed to do this:

 

double numBars = barra.NumberOfBarPositions;

                        double indice = 0;

                        // Si es Par
                        if (numBars % 2 == 0)
                        {
                            indice = (numBars / 2) - 1;
                        }

                        // Si es impar
                        else
                        {
                            indice = Math.Truncate(numBars / 2);
                        }

                        #endregion

                        #region SE CREAN LOS DETAIL LINES EN LA POSICION DE LA BARRA CENTRAL

                        if (numBars > 1)
                        {
                            IList<Curve> curva_patron = barra.GetCenterlineCurves(
                                true,
                                true,
                                true,
                                MultiplanarOption.IncludeOnlyPlanarCurves,
                                Convert.ToInt32(indice));

                            DetailCurve dc = doc.Create.NewDetailCurve(
                                doc.ActiveView,
                                curva_patron.First());

                            dc.LineStyle = fe_losa;
                        }

In my iteration, get the "indice" variable (index) as the number I want (the middle index), and using the GetCenterlineCurves with that index, I always get the first one and my detail line is created in this position. 

 

What am I doing wrong?

 

image.png

 

Regards!

0 Likes

Hi @jeremytammik , by now I managed to do this:

 

double numBars = barra.NumberOfBarPositions;

                        double indice = 0;

                        // Si es Par
                        if (numBars % 2 == 0)
                        {
                            indice = (numBars / 2) - 1;
                        }

                        // Si es impar
                        else
                        {
                            indice = Math.Truncate(numBars / 2);
                        }

                        #endregion

                        #region SE CREAN LOS DETAIL LINES EN LA POSICION DE LA BARRA CENTRAL

                        if (numBars > 1)
                        {
                            IList<Curve> curva_patron = barra.GetCenterlineCurves(
                                true,
                                true,
                                true,
                                MultiplanarOption.IncludeOnlyPlanarCurves,
                                Convert.ToInt32(indice));

                            DetailCurve dc = doc.Create.NewDetailCurve(
                                doc.ActiveView,
                                curva_patron.First());

                            dc.LineStyle = fe_losa;
                        }

In my iteration, get the "indice" variable (index) as the number I want (the middle index), and using the GetCenterlineCurves with that index, I always get the first one and my detail line is created in this position. 

 

What am I doing wrong?

 

image.png

 

Regards!

Message 5 of 6
jeremytammik
in reply to: Anonymous

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Jorge,

 

Thank you for your update and congratulations on the progress.

 

I heard back from the development team, and they say:

 

The property Rebar.NumberOfBarPositions will give us the number of bars in the set.

 

The Method Rebar.GetCenterlineCurves receives a barPositionIndex and will return the centreline curves for that bar.

 

I’m not sure what you mean by 'centre bar'; if in the set are 4 bars (indexes 0,1,2,3). It should be index 1 or 2?

 

  public IList<Curve> GetCenterlineCurves(
    bool adjustForSelfIntersection,
    bool suppressHooks,
    bool suppressBendRadius,
    MultiplanarOption multiplanarOption,
    int barPositionIndex)

 

What is missing in your code: GetCenterlineCurves will return the curves as they are positioned on the first bar.

 

You can obtain a transform which will move the curves into the desired position:

 

  RebarShapeDrivenAccessor accessor = rebar.GetShapeDrivenAccessor();
  Transform trf = accessor.GetBarPositionTransform(indice);
  // Now apply the trf on each curve obtained from calling GetCenterlineCurves()

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Dear Jorge,

 

Thank you for your update and congratulations on the progress.

 

I heard back from the development team, and they say:

 

The property Rebar.NumberOfBarPositions will give us the number of bars in the set.

 

The Method Rebar.GetCenterlineCurves receives a barPositionIndex and will return the centreline curves for that bar.

 

I’m not sure what you mean by 'centre bar'; if in the set are 4 bars (indexes 0,1,2,3). It should be index 1 or 2?

 

  public IList<Curve> GetCenterlineCurves(
    bool adjustForSelfIntersection,
    bool suppressHooks,
    bool suppressBendRadius,
    MultiplanarOption multiplanarOption,
    int barPositionIndex)

 

What is missing in your code: GetCenterlineCurves will return the curves as they are positioned on the first bar.

 

You can obtain a transform which will move the curves into the desired position:

 

  RebarShapeDrivenAccessor accessor = rebar.GetShapeDrivenAccessor();
  Transform trf = accessor.GetBarPositionTransform(indice);
  // Now apply the trf on each curve obtained from calling GetCenterlineCurves()

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 6
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable

Hi @jeremytammik , 

 

Following your indication I made exactly what I needed. Here is a snippet of the code II'm using so it may help some else in the future and the visual representation of what I achieved!

 

IList<Curve> curva_patron = barra.GetCenterlineCurves(
                                true,
                                true,
                                true,
                                MultiplanarOption.IncludeOnlyPlanarCurves,
                                Convert.ToInt32(indice));

                        // Se lleva la curva a la posicion central
                        RebarShapeDrivenAccessor accessor = barra.GetShapeDrivenAccessor();
                        Transform trf = accessor.GetBarPositionTransform(Convert.ToInt32(indice));

                        Curve curva_trans = curva_patron.First().CreateTransformed(trf);

                        DetailCurve dc = doc.Create.NewDetailCurve(
                            doc.ActiveView,
                            curva_trans);
                        dc.LineStyle = fe_losa;

 

image.png

 

Again, thanks a lot!

 

Regards.

Hi @jeremytammik , 

 

Following your indication I made exactly what I needed. Here is a snippet of the code II'm using so it may help some else in the future and the visual representation of what I achieved!

 

IList<Curve> curva_patron = barra.GetCenterlineCurves(
                                true,
                                true,
                                true,
                                MultiplanarOption.IncludeOnlyPlanarCurves,
                                Convert.ToInt32(indice));

                        // Se lleva la curva a la posicion central
                        RebarShapeDrivenAccessor accessor = barra.GetShapeDrivenAccessor();
                        Transform trf = accessor.GetBarPositionTransform(Convert.ToInt32(indice));

                        Curve curva_trans = curva_patron.First().CreateTransformed(trf);

                        DetailCurve dc = doc.Create.NewDetailCurve(
                            doc.ActiveView,
                            curva_trans);
                        dc.LineStyle = fe_losa;

 

image.png

 

Again, thanks a lot!

 

Regards.

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

Post to forums  

Autodesk Design & Make Report