Rebar for curved beams with spacing and diameter(using c#)

Rebar for curved beams with spacing and diameter(using c#)

tinuthomasGE9RJ
Advocate Advocate
1,060 Views
13 Replies
Message 1 of 14

Rebar for curved beams with spacing and diameter(using c#)

tinuthomasGE9RJ
Advocate
Advocate

Hi everyone,
could anyone help me to create rebar for the attached image. The spacing and the diameter of bar need to be changed as per our need.

tinuthomasGE9RJ_0-1724064030571.png

 

0 Likes
1,061 Views
13 Replies
Replies (13)
Message 2 of 14

jeremy_tammik
Alumni
Alumni

First of all, before you address the task programmatically, it helps to know the manual UI approach to achieve what you need, the optimal workflows and best approaches. The result can be analysed using RevitLookup to find a similar programmatic solution, which will mostly follow the similar lines.

   

Next, once that is clear, and before you ask here, you might want to take a look at the Revit SDK rebar samples and see whether any of them fits your needs:

  

  • NewRebar
  • MultiplanarRebar
  • RebarContainerAnyShapeType
  • RebarFreeForm

   

The first of those samples demonstrates how to create rebar via NewRebar (RebarShape rebarShape, RebarBarType rebarType, Element host, XYZ origin, XYZ xVec, XYZ yVec) and how to customise RebarShape, including straight segments and arc shapes. Maybe it is exactly what you are looking for?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 14

tinuthomasGE9RJ
Advocate
Advocate

I used ; 

CreateFreeForm(Document, RebarBarType, Element, IList CurveLoop , RebarFreeFormValidationResult );

but this creates a bar group, we cannot change the spacing in the revit.
when i use :

CreateFromCurves(Document, RebarStyle, RebarBarType, RebarHookType, RebarHookType, Element, XYZ, ILi...
I'm getting the output like;

tinuthomasGE9RJ_1-1724067077403.png

 

Rebar's going straight to the normal not in the circular host
could you give a small example that gives the rebar in circular host, that will help me to understand better. since I'm new in Revit.

0 Likes
Message 4 of 14

jeremy_tammik
Alumni
Alumni

Welcome to Revit. I do not know rebar myself. How do you achieve the desired result manually in the UI? You mostly need to understand that before addressing the task programmatically in the API.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 14

tinuthomasGE9RJ
Advocate
Advocate

Firstly, I choose rebar ,  

There i will have the option "FreeForm" , with that I selects the surface as in the below image;

tinuthomasGE9RJ_0-1724067912347.png

 

Then I select the path as the curved one;

tinuthomasGE9RJ_1-1724068321760.png

then the rebar will created  as per the selection;

tinuthomasGE9RJ_2-1724068388623.png

could you able to give an idea about this via API. 

 

0 Likes
Message 6 of 14

tinuthomasGE9RJ
Advocate
Advocate

Could any one can help me on this  🙂 ?

0 Likes
Message 7 of 14

jeremy_tammik
Alumni
Alumni

I asked the development team for you.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 8 of 14

tinuthomasGE9RJ
Advocate
Advocate

I wanted to extend my sincere thanks for your prompt response and the valuable help you've provided so far. I appreciate your efforts in addressing the issues, and I'm eagerly awaiting the further solutions you mentioned.

0 Likes
Message 9 of 14

jeremy_tammik
Alumni
Alumni

I have n ot mentioned any solution yet, I'm afraid. I mentioned that I asked for help. Now I asked again in a more appropriate group. I'll let you know when I hear anything more.

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 10 of 14

jeremy_tammik
Alumni
Alumni

The customer is using the aligned distribution from UI. In this case he will need to create a free form with constraints. To do this they will need to use the function that takes a server GUID, the overload CreateFreeForm Method (Document, Guid, RebarBarType, Element):

  

 

There are two solutions:

 

  • Create your own server
  • Use the existing server that is also used for UI

 

To create your own server, implement IRebarUpdateServer interface:

 

 

The RebarFreeForm SDK sample shows how to do it.

 

However, since you want to do from API what you can do from UI, I’m recommending the following second solution:

 

Use the already existing server. In this case you will need to pass the GUID - 78CE2A95-71E7-4FE2-96EE-A38554320EA6.  

 

After the rebar was created, you need to set constraints for all the RebarConstrainedJHandles:

 

 

You can call GetCustomHandleTag() to get the tag and identify each handle:

 

    

Here are the possible values:

  

  enum FreeFormAlignedHandleTags
  {
    HostSurface = 0,
    DistributionPath1 = 1,
    DistributionPath2 = 2,
    StartDistribPath = 3,
    EndDistribPath = 4,.
    SetOrientation = 5,
    StartOfBar = 6,
    EndOfBar = 7
  };

     

It looks like the Guids and the handles tags that are used for servers implemented in Revit (and used in UI) are not clearly exposed, and this is why I provided them. I submitted a development ticket REVIT-225775 for this to be fixed.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 11 of 14

tinuthomasGE9RJ
Advocate
Advocate

 

Thank you so much for the solution you provided! As a beginner in Revit API, your guidance has been incredibly helpful.

I’ve applied the constraints as suggested, but I’m facing an issue when trying to pass a curved wall face as a reference in the Create method of RebarConstraint:

 

public static RebarConstraint Create( RebarConstrainedHandle handle, IList<Reference> targetReferences, bool isConstraintToCover, double offsetValue )

 

Specifically, I’m struggling to obtain the correct reference from a curved face to use in this method. Could you please provide a small example or guidance on how to extract a reference from a curved surface to pass it to the RebarConstraint creation?

Your insights would be greatly appreciated!

Thank you once again for your support.

0 Likes
Message 12 of 14

jeremy_tammik
Alumni
Alumni

One standard approach to retrieve a reference to a nested internal geometric object such as a face within a BIM element is to traverse the element geometry with ComputeReferences = true and use criteria such as dimensions, location, orientation and other properties to identify the target object. The Building Coder shares many examples of doing so:

   

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 13 of 14

tinuthomasGE9RJ
Advocate
Advocate

Could you please provide a sample code which creates a rebar using the above steps???

0 Likes
Message 14 of 14

jeremy_tammik
Alumni
Alumni

I don't think I ever used that technique myself to create rebar. So, no, sorry, I cannot. Have you looked at the rebar creation SDK samples?

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes