tt-acm / DynamoForRebar

A Dynamo package for authoring geometrically complex rebar models in Revit 2016.
Other
39 stars 18 forks source link

Wish: Nodes for setting rebar layout/distribution #73

Closed eibre closed 5 years ago

eibre commented 8 years ago

It would be nice to have nodes for setting the distribution of rebars (make rebar sets). I currently use this python to achieve this, but it would be better to have everything in one package. (It's hardcoded to work with millimeters)

image

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

#Preparing input from dynamo to revit
rebarElement = UnwrapElement(IN[0])
spacing = IN[1]/304.8
arrayLength = IN[2]/304.8
barsOnNormalSide = IN[3]

#Change rebar in transaction
TransactionManager.Instance.EnsureInTransaction(doc)
rebarElement.SetLayoutAsMaximumSpacing(spacing,arrayLength,barsOnNormalSide,1,1)
TransactionManager.Instance.TransactionTaskDone()

OUT = rebarElement