Can we add Rebar Constraints to a particular Handle?

shindeaa15
Contributor

Can we add Rebar Constraints to a particular Handle?

shindeaa15
Contributor
Contributor

Hello,

 

I am trying to place rebars as shown in attached Image where I need to modify Constraints for Handle name "Bar Segment 2" so that Rebars are placed properly.

But while doing that Constraints for Handle name "Bar Segment 2" are null and I am not able to add Constraints and not able to modify.

 

Below Methods I have tried for modification or creation of Constraints.

oRebar.GetRebarConstraintsManager().GetPreferredConstraintOnHandle(handle).ReplaceReferenceTargets(handle, oRef, true, 0.0);


IList<RebarConstraint> rebConstraint= oRebar.GetRebarConstraintsManager().GetConstraintCandidatesForHandle(handle, selectTopRef);


IList<RebarConstraint> rebarConstraints = oRebar.GetRebarConstraintsManager().GetConstraintCandidatesForHandle(handle);


bool oRes = oRebar.GetRebarConstraintsManager().AllowConstraintTargets(handle, oRef);


bool resApply = oRebar.GetRebarConstraintsManager().ApplyRebarConstraints(rebConstraint, oRef, oRef);

 

oRebar.GetRebarConstraintsManager().SetPreferredConstraintForHandle(handle, RebarConstraint.Create(handle, oRef, false, 0.0));

 

 

Please let me know if I missing something or following wrong methods.

Here Rebars are Shape Driven Rebars.

 

 

Thank you,

Akshay Shinde

0 Likes
Reply
571 Views
9 Replies
Replies (9)

jeremy_tammik
Autodesk
Autodesk

I asked the development team for you.

   

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

shindeaa15
Contributor
Contributor

Thank you...

0 Likes

jeremy_tammik
Autodesk
Autodesk

They reply (in a very timely manner indeed): A sample (model + addon source) will help us understanding what’s not working. I’m suggesting to carefully read the documentation because for multiple functions is mentioned how they work for free form rebar versus shape driven rebar. For example, the method RebarConstraintsManager.ReplaceReferenceTargets will throw en exception if this is a constraint for Shape Driven Rebar:

  

  

I recommend using:

  

  

This will return all possible constraints for the specified handle. Once the one that is needed is found in this list, it can be set as preferred.

  

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

shindeaa15
Contributor
Contributor

Thank you for your response, I will try steps mentioned in above links.

0 Likes

shindeaa15
Contributor
Contributor

I have tried with above method as below, but it will also return 0 (Zero) constraints in List.

ElementId targetElement = selectTopRef.ElementId;
IList<RebarConstraint> rCon = oRebar.GetRebarConstraintsManager().GetConstraintCandidatesForHandle(handle, targetElement);

0 Likes

jeremy_tammik
Autodesk
Autodesk

Oh dear, sorry to hear that. Well, then we will probably need a complete minimal reproducible case for analysis in order to be able to say anything more:

   

  

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

shindeaa15
Contributor
Contributor

Okay.

Let me create one test case and I will share with you...

 

Thank you...

0 Likes

jeremy_tammik
Autodesk
Autodesk

It may be correct to return 0 candidates. To join a segment to a structural face, the segment plane should be parallel to that surface. I would like to see a model and to demo movie of how this can be achieved from the UI. Where do you  want to constraint that segment? In the image I see a warning that is telling that the segment doesn’t have any constraints.

   

If you want to place the segment in a “generic plane” that doesn’t react to any changes of the structural, you can use the function RebarConstraint .CreateConstraintToSurface(RebarConstrainedHandle handle, Surface surface),  where the surface should be the plane that you want to contain the segment. This method is available since Revit 2025.

   

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

schnierer.gabor
Advocate
Advocate

I would say it is 100% correct to return 0 candidates, because of the very reason @jeremy_tammik mentioned. The handle and the constraint target should be parallel, and there are no parallel targets available in the model.

 

I also wanted to say thanks for the info describing the purpose of the CreateConstraintToSurface method. I guess this is the way we can disable rebar constraints, a feature introduced in version 2025. The Revit Platform API Changes and Additions.docx in the SDK provides no context on its usage, but now I have a clue. 

https://help.autodesk.com/view/RVT/2025/ENU/?guid=GUID-696F54DF-C6E0-46EA-8549-D7DCE944CF3F

schnierergabor_0-1741865244136.png

 

 

0 Likes

Type a product name