Cannot get rebar centerline curve using GetCenterlineCurves()

Cannot get rebar centerline curve using GetCenterlineCurves()

longt61
Advocate Advocate
3,411 Views
7 Replies
Message 1 of 8

Cannot get rebar centerline curve using GetCenterlineCurves()

longt61
Advocate
Advocate

I am using Revit 2019 API and I want to get the center line curve of the first and the last rebar in a rebar set. When I used the following method:

Rebar.GetCenterlineCurves(bool adjustForSelfIntersection,

                                                bool suppressHooks,

                                                bool suppressBendRadius,

                                                MultiplanarOption multiplanarOption,

                                                int barPositionIndex);

 

it seems that the parameter "barPositionIndex" has no effect at all. No matter what valid position index of the rebar set I inputted, the curve list I received is the curves of the first bar - the same result of :

RebarShapeDriveAccessor.ComputeDrivingCurve();

How is this possible? Is there anything I missed in the document?

P/s: I found an other way to achieve what I want by translating the first rebar curves along the direction of rebar set though.

0 Likes
Accepted solutions (1)
3,412 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Take a look at the new external command CmdRebarCurves in The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

Does it achieve what you need?

 

If not, please supply a minimal reproducible case demonstrating your problem:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Best regards,

 

Jeremy

 



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

Message 3 of 8

jeremytammik
Autodesk
Autodesk

Congratulations on solving the problem as described in your post scriptum.

 

In fact, that seems to be the same approach used by CmdRebarCurves.

 

 



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

0 Likes
Message 4 of 8

manuel.solis.lopez
Contributor
Contributor
Accepted solution


Rebar.GetCenterlineCurves(… , ) will return the curves of the Rebar at the i-th position.

However, You must distinguish among 3 different cases:

  • Rebar.DistributionType == DistributionType.Uniform. The rebar curves will be equal at all valid positions.
  • Rebar.DistributionType == DistributionType.VaryingLength. According to the rebar constraints, the rebar curves may vary along the distribution path. For example, a set of straight rebar in a triangular slab.
  • Rebar.IsRebarFreeForm() == true. The Rebar curves of FreeFormRebar at each position will be defined by the given constraints but also by the specific RebarUpdateServer to which the Rebar is subscribed, for instance using SurfaceDistribution or AlignedDistribution.

The Rebar curves at each i-th position could vary or not, but in case of non-FreeFormRebar (Rebar.IsRebarFreeForm() == false), you would have to apply the corresponding Transformation in order to obtain the actual location in 3D Space: Rebar.GetShapeDrivenAccessor().GetBarPositionTransform(i);

 

Regards.

Message 5 of 8

longt61
Advocate
Advocate

Thank you for the explanation. For more information, I was using Rebar driven by shape and uniform distribution, thus, the shape of rebar is the same for every bar.

However, I just find it strange and quite confusing that the GetCenterlineCurves() does not return the actual position of the bar but we have to explicitly transform it ourselves without mentioning it in the api documentation. It seems to me if the method return the actual position of the center line, then the barPositionIndex parameter would make more sense.

Message 6 of 8

jeremytammik
Autodesk
Autodesk

Thank you very much, Manuel, for the helpful explanation.

 

I preserved this solution for posterity on the blog and added your explanation there as well:

 

https://thebuildingcoder.typepad.com/blog/2019/07/roadmap-rebar-curves-wizard-zip-and-more.html#4

 

Best regards,

 

Jeremy

 



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

Message 7 of 8

Anonymous
Not applicable

Hello,

Could you please give an example of usage Rebar.GetShapeDrivenAccessor().GetBarPositionTransform(i) ? With GetBarPositionTransform I can get a Transform of each bar in group, but I don't know how to use it to create bars.

I would like to recreate each rebar from given rebar group as a single rebar.

As said in this topic GetCenterlineCurves with index doesn't do anything, all what I get is a list with the same shape of first rebar.

mp = MultiplanarOption.IncludeOnlyPlanarCurves
rebar = UnwrapElement(IN[0])
n = rebar.NumberOfBarPositions

curves = []
curvesDynamo = []
i = 0
for x in range(n):
	curves.append(rebar.GetCenterlineCurves(False, False, True,mp,i))
	i+=1
for curve in curves:
	for	c in curve:
		curvesDynamo.append(c)

 

 

 

 

0 Likes
Message 8 of 8

Mr.Borges
Enthusiast
Enthusiast

Last year I spent a lot of time trying to get a little Add-in to work. What I wanted is exactly what "Rebar Bending Detail" (introduced at 2024 Revit Release) does. I could extract the centerline curves using:

 

rebarCurves = (List<Curve>)rebar.GetCenterlineCurves(false,
                                                    false,
                                                    false,
                                         MultiplanarOption.IncludeOnlyPlanarCurves,
                                                    0);

 

from Rebar and project it to the view as detail lines using:

 

Document.ConvertModelToDetailCurves(view, modelCurves);

 

mentioned here and Typepad awesome examples. But I never was able to do the same with the most special type of Rebar: Spiral.

Always get a exception: "Curve must be on the plane". I've researched a lot about it until I realize that even draw a Helix using default Revit tools is hard. Seems Revit lack's a lot of usefully "basic" geometric operations. Then I gave up. 

Now trying the Revit 2024 tool for Bending Details I remembered this work of mine, and I was excited to see how Revit's Team worked in Spiral Rebars bend detail. The answer proved my point: Revit lack's a lot of basic geometric operations. They simple draw a simplified detail using basic lines instead of a projection of the Spiral (as I tried before). For other Rebar seems to be a projection. Simple solution. Works. But exposes the lack of basic operations from API.

0 Likes