Wrong rebar Hook orientation REVIT API

Hi everyone,

I tried to create beam’s rebar using Revit API, but I get Hook orientation opposed only when shoosing 90° value!!?..can anyone explain me the reason for that?

here my graph

Hook orientation
import sys
import clr
import math
from System.Collections.Generic import IList, List

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

curve = IN[0].ToRevitType()
bar_type = UnwrapElement(IN[1])
ber_Hook_type = UnwrapElement(IN[6])
host = UnwrapElement(IN[3])
vect = IN[2].ToRevitType()
beam_width = IN[4].ToRevitType()
width = beam_width.Length
cover = IN[5]/0.3048
spacing = 0.10/0.3048

curv = List[Curve]()
curv.Add(curve)
TransactionManager.Instance.EnsureInTransaction(doc)
rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, bar_type, ber_Hook_type, ber_Hook_type, host, vect, curv, RebarHookOrientation.Left, RebarHookOrientation.Right, True, False)
rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
TransactionManager.Instance.TransactionTaskDone()

OUT= rebar

Thanks.

Hi,
I don’t have the same conclusion
copy paste your code
I simply oriented the vector at the entrance I had a (0,0,1) with my edge bar support

edit

Cordially
christian.stan

1 Like

@christian.stan

it’s strange…does not work for me!!
I’ve not posted the first script where I created rebar curve (in your example you selected the beam edge without offseting it with the cover value)

I made change in my script where I create also the top rebar (with the same error)

below my graph and my two script (curves script, rebars script)

curves script
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *



btm_beam_edge = IN[0]
Top_beam_edge = IN[1]
beam_width = IN[2]
cover = IN[3]

Subtract_vector = btm_beam_edge.Direction.Normalized().Scale(cover)
Pt1 = btm_beam_edge.StartPoint.Subtract(Subtract_vector.Reverse())
Pt2 = btm_beam_edge.EndPoint.Subtract(Subtract_vector)
Pt3 = Top_beam_edge.StartPoint.Subtract(Subtract_vector.Reverse())
Pt4 = Top_beam_edge.EndPoint.Subtract(Subtract_vector)

Bottom_rebar = Line.ByStartPointEndPoint(Pt1, Pt2)
Bottom_rebar = Bottom_rebar.Offset(-cover)
Bottom_rebar = Bottom_rebar.Translate(Vector.ByCoordinates(0,0,1).Scale(cover))

Top_rebar = Line.ByStartPointEndPoint(Pt3, Pt4)
Top_rebar = Top_rebar.Offset(-cover)
Top_rebar = Top_rebar.Translate(Vector.ByCoordinates(0,0,-1).Scale(cover))

OUT = Bottom_rebar, Top_rebar

rebars script
import sys
import clr
import math
from System.Collections.Generic import IList, List

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

curve1 = IN[0].ToRevitType()
curve2 = IN[1].ToRevitType()
vect = IN[2].ToRevitType()
host = UnwrapElement(IN[3])
beam_width = IN[4].ToRevitType()
width = beam_width.Length
cover = IN[5]/0.3048
spacing = 0.10/0.3048
Btm_bar_type = UnwrapElement(IN[6])
Top_bar_type = UnwrapElement(IN[7])
ber_Hook_type = UnwrapElement(IN[8])


curv1 = List[Curve]()
curv1.Add(curve1)

curv2 = List[Curve]()
curv2.Add(curve2)

TransactionManager.Instance.EnsureInTransaction(doc)

Btm_rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, Btm_bar_type, ber_Hook_type, ber_Hook_type, host, vect, curv1, RebarHookOrientation.Left, RebarHookOrientation.Right, True, False)

Top_rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, Top_bar_type, ber_Hook_type, ber_Hook_type, host, vect, curv2, RebarHookOrientation.Left, RebarHookOrientation.Right, True, False)

Btm_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)

Top_rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)

TransactionManager.Instance.TransactionTaskDone()

OUT= Btm_rebar, Top_rebar

Thanks.

I used the script of your 1st message with two beams oriented in a different way (without taking into account the covers, I know that they exist… normally)
Could be a lead

Cordially
christian.stan

3 Likes

@christian.stan

I dont know where I was wrong??? (see my selction in the image below)

Thanks.

1 Like

Why don’t you try at first to base yourself on the edges of your elements to see if you have a good orientation of your hooks.
like that you will see if it comes from your 1st script or not.

Cordially
christian.stan

1 Like

@christian.stan
Of course I tested my first script and my edges are correctely seted (inside the beam)
My selection is correst like your’s?

Thanks.

I tried to be as clear as possible
I only tried for the lower part.
here is result with your scripts

With your scripts

script 1

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
btm_beam_edge = IN[0]
beam_width = IN[1]
cover = IN[2]

Subtract_vector = btm_beam_edge.Direction.Normalized().Scale(cover)
Pt1 = btm_beam_edge.StartPoint.Subtract(Subtract_vector.Reverse())
Pt2 = btm_beam_edge.EndPoint.Subtract(Subtract_vector)

Bottom_rebar = Line.ByStartPointEndPoint(Pt1, Pt2)
Bottom_rebar = Bottom_rebar.Offset(-cover)
Bottom_rebar = Bottom_rebar.Translate(Vector.ByCoordinates(0,0,1).Scale(cover))


OUT = Bottom_rebar

Script 2

import sys
import clr
import math
from System.Collections.Generic import IList, List

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument

curve = IN[0].ToRevitType()
bar_type = UnwrapElement(IN[1])
ber_Hook_type = UnwrapElement(IN[6])
host = UnwrapElement(IN[3])
vect = IN[2].ToRevitType()
beam_width = IN[4].ToRevitType()
width = beam_width.Length
cover = IN[5]/0.3048
spacing = 0.10/0.3048

curv = List[Curve]()
curv.Add(curve)
TransactionManager.Instance.EnsureInTransaction(doc)
rebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, bar_type, ber_Hook_type, ber_Hook_type, host, vect, curv, RebarHookOrientation.Left, RebarHookOrientation.Right, True, False)
rebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(math.ceil((width-2*cover)/spacing), width-2*cover, True, True, True)
TransactionManager.Instance.TransactionTaskDone()

OUT= rebar

Cordially
christian.stan

2 Likes

@christian.stan

this issue makes me crazy !!

You used my scripts without any changes and that’s works for you , but for me that not works!! :roll_eyes:

here my last test:

Is that related to my Dynamo or Revit settings or Something else?? (I’m using Revit 2022)

@jacob.small @c.poupin any idea to fix this issue?

Thanks.

Hello, try to see by adding in your 2nd script
import System
Before
from.System.Collections.Generic import List,Ilist

Cordially
christian.stan

1 Like

@christian.stan

I tried what you suggested me without result

Why that’s happen only with Hook at 90°, is there a bug in structural design package?

Which structural package you use?

Thanks.

Here
image
edit: I just tried installing the IronPython2 package and changing the engine
(Brackets are the right way round)
You wouldn’t have another pack or there would be a rebarHookType
if you right click on the node then help you will have the source of the node

Cordially
christian.stan

1 Like

@christian.stan

Thanks for thoses informations

So you tested with IronPython2 and that’s works!!!..Pffff I’m completely lost!!

I’m using the following package but as you said it won’t change anything

Thanks.

1 Like

You have a Dynamo for rebar maybe you have a conflict with it
edit:
With Ironpython3 is good too



edit2:
the package i am using is from december 15
you use the one of August 28

cordially
christian.stan

1 Like

@christian.stan

I’ve romove Dynamo for rebar and tested again without result ( I also tested CPython3 without result)

Thanks.

1 Like

sorry for not being able to do better, the update of the package either (edit 2) at worst you put a conditional if (with the Id of the rebarhookType which changes your hookOrientation.Left to hookOrientation.Right) wobbly, I grant you that but hey it should work… .
Cordially
christian.stan

1 Like

@c.poupin @jacob.small @Daan

Any idea how to fix this issue?

Thanks.

@REDO10 graph as it currently stands and an RVT to run it on?

1 Like

@jacob.small

Sorry I didn’t catch what you are trying to say…and which graph are you referencing to?

Thanks.

The graph you have built (your .dyn as it currently stands) and a sample rvt on which to run it (reproducing the problem you are having).