Constraints system is a powerful Revit instrument, that allows user adding important dependencies between elements and create special behavior on changing one of them. Constraints can affect rebar shape, for example, stirrup constraints set to beam cover will make stirrup shape match this cover. Rebar constraints can be set not only to Host element face or cover, but to other rebars too. These constraints are very useful in terms of creating Beam Reinforcements. Revit API also provide functions to manage constraints.
In Smart Rebar System during stirrups creating process constraints are set to Host cover to follow its shape. Rebar constraints operations in Revit API are controlled by RebarConstraintsManager
class. The instance of this class can be get by GetRebarConstraintsManager()
method of Rebar instance.
var rebarConstraintsManager = stirrup.GetRebarConstraintsManager();
With this manager we can find, set and remove any constraints related to this stirrup. However, to apply any constraint we need handle, that represent part of rebar/stirrup, such as Bar Start, Bar End, Bar Segment, Bar Edge, etc. To find these handles we can use GetAllHandles()
method of RebarConstraintsManager
instance to get list on handles for this stirrup.
var handles = rebarConstraintsManager.GetAllHandles();
Each handle has some basic parameters, such as name and type, that can be used to find specific handles. However, for Stirrup cover constraints it’s not necessary and we can move to the next step.
Next, we will get RebarConstraint
list using GetConstraintCandidatesForHandle
method of RebarConstraintsManager
. Parameters for this method are handle and Element Id, that in our case is Beam Id. RebarConstraint
has a lot of parameters, that can be used to filter and get specific constraints. For example, IsToCover()
method will filter and return only Cover type constraints.
var toCoverConstraints = rebarConstraintsManager.GetConstraintCandidatesForHandle(handle, HostElement.Id).Where(x => x.IsToCover()).ToList();
After previous step we have list of matched constraints. However, constraint for handle can be only one. Since after creating stirrup, its shape follows Beam Face, to find the most matched constraint we will check the distance between handle and constraint and take closest one.
var closestToCoverConstraint = toCoverConstraints.OrderBy(x => Math.Abs(x.GetDistanceToTargetCover())).FirstOrDefault();
And at the next step we will set distance to zero to follow Beam Cover.
closestToCoverConstraint.SetDistanceToTargetCover(0);
The final step will be setting this constraint to handle using SetPreferredConstraintForHandle
method of RebarConstraintsManager
.
rebarConstraintsManager.SetPreferredConstraintForHandle(handle, closestToCoverConstraint);
For 1st Layer bars skyACE Smart Rebar System use either Cover Constraints in case when there are no stirrups, or Rebar to Stirrups Constraints in case if we have stirrups. Steps until getting cover constraints are similar to Stirrups Cover Constraints.
Since we need to make constraints to other rebar, IsToCover()
method won’t be suitable for us. Instead, we will search for angle of stirrup Hook/Bend using GetTargetRebarAngleOnBarOrHookBend()
method of RebarConstraint
instance. This value is representing angular location of around hook (detailed explanation from API Docs), and using it we can find specific point – midpoint in our case – with what we need to create constraints.
The final step is equal to Cover Constraints – set this constraint to handle using SetPreferredConstraintForHandle
method of RebarConstraintsManager
.
rebarConstraintsManager.SetPreferredConstraintForHandle(handle, closestToCoverConstraint);
One more case, that using Rebar Constraints is to make dependencies between layers of different layers. This type of constraints is required more changes comparing with previous ones. First, we will use handle type value from GetHandleType()
method of RebarConstrainedHandle instance. Using this type, we will search for RebarConstraint with TargetRebarConstraintType
– Edge
, RebarPlane
or OutOfPlaneExtent
corresponding to handle type. Depending on TargetRebarConstraintType
.
Same as for Stirrups Cover Constraints, we will take into account DistanceToTargetRebar
and find closest constraint. Distance between rebars can be either as spacing between their centers or as a clear distance offset. This parameter can be controlled by SetToUseClearBarSpacing()
method of RebarConstraint type. For RebarPlane
and OutOfPlaneExtent
types distance should between bar centers and – in our case – set to zero. As for Edge, distance required to be as a clear space. Final step is similar to other cases.
Revit Rebar Constraints have multiple use cases and posibilites. Implementations above – just a few practical examples, that show a potential of using it through Revit API.