Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rebar to rebar constraint target positive direction

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
schnierer.gabor
376 Views, 2 Replies

Rebar to rebar constraint target positive direction

Hi,

Do you have any advice on how to determine the direction for positive offset values in case of segment to segment rebar constraints using the Revit API? This is conveniently available in the UI, and indicated by the arrow shown on the constraint target. Here is a link to the documentation. Can I query this from the database somehow? 

GUID-41F637B0-D321-4586-A8B2-6CDF65A59554

I figured it could be based on the direction of the curves driving the rebar shape. Maybe the cross product of the the segment line direction and the rebar shape normal. But the attached example proves me wrong. Both of the S-shape bars are of the same shape id (M_20), have the same normal (0, 0, 1), both start at the south side and end on north. But their positive offset direction is opposite. Probably one of them is flipped in a way, but I couldn’t get this information from the API.

 

Then I figured to read it from the rebar shape family. The cross product of the segment direction and the Basis Z (0, 0, 1) looks promising, though I have no idea how to apply this rule to the rebar instance generated by the shape, the rebar parameters and the global location and a possible flip.

2 REPLIES 2
Message 2 of 3

Here is the answer I got from ADN support:

 

"I checked with the Revit Engineering team for you.

 

Unfortunately, there is no API function that gives you this direction. 

 

There is a workaround but is very ugly. You can compute this direction on your own. For the child rebar, you have the RebarConstrainedHandle which is of type RebarHandleType.Edge and you can obtain the edge number. For this rebar you can compute centerline curves and using the edge number you will find where the segment is exactly. The same can be done for the “source” rebar.  From RebarConstaraint you can obtain the source rebar and the edge number to where the constraint is. Centerlines can be computed for source rebar and get the segment based on the edge number. Now that you have the “source” and “child” segments, going from “Source” to “Child” is the exact sign of the offset value from the constraint."

Message 3 of 3

Here is some more background information, and the way I solved this in my project.

 

While the positive direction for constraints targeting faces is obvious, their rebar targeting counterparts are confusing indeed.

 

When you have a rebar you want to constrain, and you get the constraint candidates using RebarConstraintsManager.GetConstraintCandidatesForHandle(), filter for the types targeting rebar, you will find the reported distance to the target doesn't reflect the actual distance between the handle and the target.

 

For example, independently of how far your rebar edges are from each other, edge-to-edge constraint candidates always return IsUsingClearBarSpacing = true and RebarConstraint.GetDistanceToTargetRebar() returns zero by default. This is similar to the UI behavior: selecting a rebar target will cause the handle to move / snap in contact instantly, opposed to selecting a face target which will leave the handle in place.

 

This behaviour can be expoited to determine the rebar to rebar constraint target positive direction.

If you temporary change the constraint to use distance between centers (set IsUsingClearBarSpacing to false), the sign of the value returned by GetDistanceToTargetRebar() will indicate wheter the orignal geometry laid on the positive side or not.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report