& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
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
I asked the development team for you.
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.
Thank you for your response, I will try steps mentioned in above links.
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);
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:
Okay.
Let me create one test case and I will share with you...
Thank you...
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.
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
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name