Please check below my .dyn file and Revit Model
rebar_test.DYN (27.5 KB)
beam_rebar.rvt (2.3 MB)
Thanks.
Please check below my .dyn file and Revit Model
rebar_test.DYN (27.5 KB)
beam_rebar.rvt (2.3 MB)
Thanks.
Looks to be based on how you’re drawing the original lines. Putting a Curve.Reverse in here caused the hooks to return into the geometry instead of outside of it.
My gut says that you’re going to have both UX and reliability issues with the 'select N different edges. My first run I selected edges on the opposite face and all the rebar was placed outside the beam. Perhaps a pick face node would be better suited? Or better yet work with the location curve and parameters of the beam itself.
I didn’t finalzed my script yet (I know I’m gonna have an issue with rebar location if the wrong edges are selected )…as you suggested, a pik face node is better indicated to be sure of what will happen.
for the moment, the thing that’s making me confused is that I indicated above (in posts 4 and 9) which edges I selected to be sure of my result and I get my Hooks opposed !!.. in the same time @christian.stan used my script with the same edges selection and that worked for him!?
I had the same issue in my thread Wrong rebar hook orientation…the question is: in my case is there a conflicting or something (related to UX) that doesn’t works well while running the script from dynamo to Revit ?..if so how can I fix it?
Thanks.
Hello, have you tried as mentioned in one of the posts (disregarding the 135° hooks) to change the HookRebarOrientation.Left of the beginning of the bar to HookRebarOrientation.Right
to see if your phase opposition (which I don’t have even trying your attached support file and script)
Cordially
christian.stan
I’ll try it and see how it goes
Thanks
The direction of selected edges will vary based on the modifiers present. So if your model generated the beam one way, and then extra content was purged or an edge was modified, @christian.stan could have had his edges drawn in the reverse.
Testing the direction of the top/bottom curve relative to each other may help here.
As Mr. Jacob said, starting from the element get line support (in your code) and working from it is a better option, less potential input errors (it becomes your fault if it bugs that says lol )
cordially
christian.stan
@christian.stan has tested my script with his own beam creation in two opposed direction (increasing and decreasing direction X) and that worked for him
Yes it’s a good idea…otherwise why I had the same issue in the thread I indicated in my previous post? …I’m a bit confused
Thanks.
It’s not going to reproduce reliably. The simplest beams might not have the issue, while something with a slight modification over it’s history, or with a modification to the shape, or even just a different beam type could cause the geometry to draw differently. Hence why I think selecting by a different means is going to be a must.
I puted HookRebarOrientation.Right
at the beggining as shown below and no thing happen!!
Btm_rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, Btm_bar_type, bar_Hook_type, bar_Hook_type, host, vect, curv1, RebarHookOrientation.Right, RebarHookOrientation.Left, True, False)
How can I get information about the rebar Hook orientation inside rebar creation transaction and put a "conditional if " to change his direction?
Thanks.
Hello,
after some test here is an approach by selecting a face, I could not explain everything because the structure is really out of my area of expertise, and this part of the API seems really very complex to understand
import sys
import clr
import math
from System.Collections.Generic import IList, List
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
Btm_bar_type = UnwrapElement(IN[0])
Top_bar_type = UnwrapElement(IN[1])
bar_Hook_type = UnwrapElement(IN[2])
cover = IN[3]/0.3048
spacing = 0.10/0.3048
TaskDialog.Show("Selection", "Pick a Face")
ref = uidoc.Selection.PickObject(ObjectType.Face, "Pick a Face")
# get Face Geometry
sel_elem = doc.GetElement(ref)
tf1 = sel_elem.GetTotalTransform()
face = sel_elem.GetGeometryObjectFromReference(ref)
# get the instance of Face Normal (Transformed)
faceNormal = tf1.OfVector(face.FaceNormal)
#beam_width
width = doc.GetElement(sel_elem.GetTypeId()).LookupParameter("b").AsDouble()
# get beam direction
beam_direction = sel_elem.Location.Curve.Direction
#
# create an transfrom for onternal offset
tf2 = DB.Transform.CreateTranslation(face.FaceNormal.Negate() * 0.1)
curveLoop = face.GetEdgesAsCurveLoops()[0]
# move curveloop inside the beam
# compute a transformation translation
offset_curvloop = DB.CurveLoop.CreateViaOffset(curveLoop, -0.1, face.FaceNormal)
# apply the fully transform to get the instance of Geometry
offset_curvloop = DB.CurveLoop.CreateViaTransform(offset_curvloop, tf1.Multiply(tf2))
# get top and bottom curves
curvesorted = sorted(offset_curvloop, key = lambda x : x.Length)
bottomLine, topLine = sorted(curvesorted[2:], key = lambda x : x.GetEndPoint(0))
TransactionManager.Instance.ForceCloseTransaction()
t = Transaction(doc, "Script Rebar")
t.Start()
# compute the normal for Rebar
if faceNormal.CrossProduct(beam_direction).IsAlmostEqualTo(XYZ(0,0,-1)):
normT = topLine.Direction.CrossProduct(XYZ.BasisZ)
normB = topLine.Direction.CrossProduct(XYZ.BasisZ)
else:
normT = topLine.Direction.CrossProduct(XYZ.BasisZ).Negate()
normB = topLine.Direction.CrossProduct(XYZ.BasisZ).Negate()
Top_rebar = Rebar.CreateFromCurves(doc,
RebarStyle.Standard,
Btm_bar_type,
bar_Hook_type,
bar_Hook_type,
sel_elem,
normT,
List[DB.Curve]([topLine]),
RebarHookOrientation.Left,
RebarHookOrientation.Right,
True,
True)
Top_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
Btm_rebar = Rebar.CreateFromCurves(doc,
RebarStyle.Standard,
Btm_bar_type,
bar_Hook_type,
bar_Hook_type,
sel_elem,
normB,
List[DB.Curve]([bottomLine]),
RebarHookOrientation.Left,
RebarHookOrientation.Right,
True,
True)
Btm_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
t.Commit()
t.Dispose()
OUT = sel_elem, face, bottomLine.ToProtoType(), topLine.ToProtoType()
Thanks a lot! …as usual, your help is very helpful and you always give the right thought solution
As you said, The structure part of Revit API is complex to understand!..I basically understood the principle of your script and I’ll study it step by step to well understand it’s logic.
Thanks again.
Pfffff…this beam make me crazy !!!
it doesn’t wont works for me !!?
I always have issue with Hook at 90° (see image below)
Remark: I used rebar proprities from Structural Design Package
Thanks.
I had some problems with this package
I removed Structural design package then installed dynamo for rebar and got the same issue for Hook at 90°
Here my rebar parameters (actualy with dynamo for rebar)
Thanks.
I know I’ve bothered you with my questions and I know you are busy and you are replying me on your own time, but I’m stuck in an endless loop and I’m sick of this issue!! … this is not due to an issue I have in either Dynamo or Revit settings?
As I’m not yet mastering Revit API, and for a temporary solution, can you put in your script a condititional “IF” that’s check hook direction and reverse it if it’s wrong?
Thanks.
Hi,
as I said in my previous message I am not a structural engineer, my code is based on multiple tests, it would be better to ask a structural engineer who knows the API
Hi everyone,
My issue is solved just by doing the same thing on this particular one Wrong rebar Hook direction for angle 90°
Thanks.