Setting rebar container dimensions in Dynamo (Dynamo for Rebar)

revit
dynamoforrebar

#1

I’m trying to create hair-pin bars in Dynamo for Revit.

When creating a bar with a 180 degree hook at one end, the Rebar.ByCurve node assumes the standard tangent hook/extension lengths (see image). I need to extend this end such that the length of bar on each side of the hook is of equal length (i.e. the 180 degree hook needs to be in the middle of the bar).

I’ve connected the rebar container to an Elements.Parameters node and tried altering the shape code from 32 to 39 and adding dimensions to the empty “B” and “C” parameters, but with no luck.

The hook dimensions, including the extension lengths, are parameters of the bar types and can be set in Revit through a pop up window, but I can’t figure out how to access them from Dynamo.

When you query the parameters of the bar type in Dynamo, you get this:

Is it possible to access the hook length parameters from within Dynamo?

Thanks


Error when creating rebar following PolyCurves
#3

You can make any rebar shape you like with the Rebar.CreateFromCurves method in the API

import clr

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

clr.AddReference("System")
from System.Collections.Generic import List

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

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

doc = DocumentManager.Instance.CurrentDBDocument

def hookOrient(dir):
	if dir=="Right":
		return RebarHookOrientation.Right
	elif dir=="Left":
		return RebarHookOrientation.Left
	else: return "Wrong input"

#Converting input from Dynamo to Revit
style = RebarStyle.Standard
barType = UnwrapElement(IN[0])
startHook = IN[1]
endHook = UnwrapElement(IN[2])
host = UnwrapElement(IN[3])
norm = IN[4].ToXyz()
curves=List[Curve]([c.ToRevitType(True) for c in IN[5]])
startHookOrient = hookOrient(IN[6])
endHookOrient = hookOrient(IN[7])
useExistingShapeIfPossible = 1
createNewShape = 0

#create rebar in  transaction
TransactionManager.Instance.EnsureInTransaction(doc)

rebar = Rebar.CreateFromCurves(doc,style,barType,startHook,endHook,host,norm,curves,startHookOrient,endHookOrient,useExistingShapeIfPossible,createNewShape)
TransactionManager.Instance.TransactionTaskDone()

#Wrapping rebar object, if set to True a new rebar element will be created each time
OUT = rebar.ToDSType(False)

To answer the hook length question: You can access the hook extension multiplier like this:

or you could look at the SetHookLength method in Revit API: http://revitapisearch.com/html/d8a83bf6-d0ad-4bb2-d5b2-c7b026a4d4de.htm


Error when creating rebar following PolyCurves (continued)
#4

Thank you very much Einar!

The extension multiplier will definitely come in handy. I’ll see if the Python script you provided behaves any differently to the Rebar.byCurve node in the Dynamo for Rebar package (it looks like it may be exactly the same).

Another shape I struggled creating with that node is a chair shape:


I tried creating the exact geometry as a polycurve, but Rebar.byCurve doesn’t like polycurves; I also tried a NURBS curve, but it then generates a circular bar which doesn’t match the shape at all (NURBS in blue, black circles are the rebars that are generated):

Also tried creating only the top ‘U’ as a NURBS curve and adding 90 degree bends at each end using the node, but that also made a circular shape with hooks at the ends (similar to above). I suspect it could be that the radii of the bends in NURBS curve does not exactly match the bar bend diameter, but I’m not sure. When you say you can create “any shape you like” using the API, does that include multi-planar curves with multiple 90 degree bends like this one? Any tips on how to achieve such a shape would be very much appreciated. I gave up and created a generic family with the necessary parameters (this is what is shown in the first image). I haven’t gotten around to creating bending schedules etc. yet and I suspect having these bars as generic models will complicate things.

I need to create a 3D model of the foundation with all the reinforcement, so creating 2D images to represent the chairs in reinforcement layouts isn’t a great option.

Thanks


#5

I haven’t tried to create multiplanar rebar shapes yet, the script above is limited to planar shapes.
Have you tried the Multi-planar tool in revit?

I havent tested the dynamo for rebar package much, but I think it creates one bar per curve segment. To create a hairpin you need three curve segments for each bar. I have used the above script to create hairpins in walls:
It only make one bar at a time.

(Warning: Revit seems to hang if the script is run i Automatic mode)


#6

If I understand you correctly, your haipins consist of 3 separate curves and are therefore 3 separate rebar segments. Do you then somehow merge these three so that Revit recognises it as a single rebar entity, or do you just leave it as 3 separate entities (I imagine that complicates your bending schedules)?

I’ve considered creating the chairs using the multiplanar tool, but I have to place all my reinforcement in 3D using Dynamo (no work to be done in Revit) and the host element is a circular foundation. I therefore need to place each chair using a reference base point and adjust the parameters to achieve the desired shapes (they get taller and narrower towards the center, generic families used in the image):


I’ve not figured out how to use the ‘shape code families’ (this is what you’d create using the multi-planar tool you referenced) in Dynamo to place reinforcement elements in 3D space, I’ve only generated them by curves, however it’s probably possible. This is why I resorted to generic models for the chairs. I suppose you just need to know how to access and combine the various parameters (split across a few families/types) to define the required bars:

I’m quite new to Dynamo so I still have much to figure out. Thanks for your responses, they’ve been very helpful.


How to get the information of rebar hook type
#7

No, with my script you can make one hairpin rebar element from three curves created in dynamo, but i don’t think that’s the case with dynamo for rebar package.


#8

Okay cool, I’ll give your script a go, it sounds promising.

Thanks again


#9

Here’s a simple example for you. How to make U-shaped bar from detail line: ( I also wrapped the python in a custom node, .dyf is attached.


Rebar.CreateFromCurves.dyf (9.1 KB)


Rebar Container
#10

Awesome, your time is much appreciated! I’ll report back if I discover any useful tricks.


#11

I just tested the Dynamo for Rebar package again. Looks like you can make hairpins if you feed it polycurves instead of curves.


#12

Hi Einar

Sorry for my delay in providing feedback, I’m getting side tracked by other work. I have followed that exact methodology when I attempted to create my hairpins, but with a small and evidently significant difference. I was using the Curve.NormalAtParameter node (with parameter value = 0) instead of the Curve.Normal node.

With the NormalAtParameter node I get an internal error warning for the Rebar.ByCurve node (Warning: Rebar.ByCurve operation failed. An internal error has occurred.). I assumed I was getting the error because I was feeding it PolyCurves, as I get no errors when I feed it a regular curve and use the NormalAtParameter node.

So it seems Polycurves and Curve.Normal work together. I think this makes sense, I suppose the Curve.NormalAtParam could be generating a multi-planar rebar which the Rebar.ByCurve can’t handle, or something like that?

Thanks again!


#13

Yes, that’s an important difference. The normal must be in one of the directions you would expand a rebar into a rebar set with maximum spacing or similar.


#14

Hi @Einar_Raknes, could you please explain a bit which vector is using for the normal vector?

I’m getting this error:

import clr

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

clr.AddReference("System")
from System.Collections.Generic import List

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

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

doc = DocumentManager.Instance.CurrentDBDocument

def hookOrient(dir):
	if dir=="Right":
		return RebarHookOrientation.Right
	elif dir=="Left":
		return RebarHookOrientation.Left
	else: return "Wrong input"

#Converting input from Dynamo to Revit
style = RebarStyle.Standard
barType = UnwrapElement(IN[0])
startHook = IN[1]
endHook = UnwrapElement(IN[2])
host = UnwrapElement(IN[3])
norm = IN[4].ToXyz()
curves=List[Curve]([c.ToRevitType(True) for c in IN[5]])
startHookOrient = hookOrient(IN[6])
endHookOrient = hookOrient(IN[7])
useExistingShapeIfPossible = 1
createNewShape = 0

#create rebar in  transaction
TransactionManager.Instance.EnsureInTransaction(doc)

rebar = Rebar.CreateFromCurves(doc,style,barType,startHook,endHook,host,norm,curves,startHookOrient,endHookOrient,useExistingShapeIfPossible,createNewShape)
TransactionManager.Instance.TransactionTaskDone()

#Wrapping rebar object, if set to True a new rebar element will be created each time
OUT = rebar.ToDSType(False)

Dynamo for Rebar - Rebar Type deleted
#15

The vector must be perpendicular to the plane that the rebar shape defines


#16

Hi @Einar_Raknes. Thanks for the response. I fixed the vector but now my problem is this:

What does the “The input PolyCurve must be closed” mean? I thought that my policurves had some gaps that the Polycurve.ByJoinedCurves missed, so I created the same polycurve using Polycurve.ByPoints and got the same result:

Any ideas?


#17

It probably means that you should set connectLastToFirst to true when you are creating the polycurve.


#18

Tried that, but it turns the polycurve into a loop.


#19

I’m sorry about the time disparity, but I also am trying to set hook length within dynamo. I looked in this topic but I didn’t manage to understand the solution to hook length edition :confounded: