Community
I am trying to create reinforcement in beam using python in revit. But it is giving me some error. i have tried everything but now i am clue less that what is causing the error. some help will be highly appreciated. Thanks in advance
# -*- coding: utf-8 -*-
import Autodesk
from Autodesk.Revit.DB import *
import clr
print("-------Generation of Beam Reinforcement-------")
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
active_view = doc.ActiveView
def new_point(p_1, x, y, z, x_dir, y_dir):
new_point_1 = p_1 + x*x_dir
new_point_2 = new_point_1 + y*y_dir
return(XYZ(new_point_2.X, new_point_2.Y, new_point_2.Z + z))
elements = [doc.GetElement( elId ) for elId in uidoc.Selection.GetElementIds()]
all_rebar_types = FilteredElementCollector(doc) \
.OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsElementType() \
.ToElements()
columns = []
beams = []
footings = []
rebar = []
for rebar_type in all_rebar_types:
rebar_name = rebar_type.get_Parameter(BuiltInParameter \
.SYMBOL_NAME_PARAM).AsString()
if rebar_name == ('#'+str(4)):
bar_type = rebar_type
break
for element in elements:
if element.Category.Name == 'Structural Columns':
columns.append(element)
elif element.Category.Name == 'Structural Framing':
beams.append(element)
elif element.Category.Name == 'Structural Foundations':
footings.append(element)
elif element.Category.Name == 'Structural Rebar':
rebar.append(element)
num_stirrups = 4 #Number of stirrups to add
stirrup_spacing = 1.0 #Spacing between stirrups in feet
stirrup_width = 0.5 #Width of the stirrup in feet
stirrup_height = 1.5 #Height of the stirrup in feet
for b in beams:
beam = b
beam_height = beam.get_BoundingBox(None).Max.Z - beam.get_BoundingBox(None).Min.Z
beam_width = beam.get_BoundingBox(None).Max.X - beam.get_BoundingBox(None).Min.X
beam_depth = beam.get_BoundingBox(None).Max.Y - beam.get_BoundingBox(None).Min.Y
print(beam.get_BoundingBox(None).Max)
print(beam.get_BoundingBox(None).Min)
p_1 = XYZ(beam.get_BoundingBox(None).Min.X, beam.get_BoundingBox(None).Min.Y, beam.get_BoundingBox(None).Min.X)
p_2 = XYZ(beam.get_BoundingBox(None).Max.X, beam.get_BoundingBox(None).Min.Y, beam.get_BoundingBox(None).Min.X)
lines = [[[Line.CreateBound(p_1, p_2)]]]
t = Transaction(doc, 'Reinforce')
t.Start()
rebar = Structure.Rebar.CreateFromCurves(doc, Structure.RebarStyle.Standard, bar_type, None, None, beam,
XYZ(0,1,0), lines, Structure.RebarHookOrientation.Right,
Structure.RebarHookOrientation.Left, True, True)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_LAYOUT_RULE).Set(0)
#rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_BAR_SPACING).Set(6)
# rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS).Set(lenght/8)
rebar.GetShapeDrivenAccessor().BarsOnNormalSide = True
t.Commit()
Solved! Go to Solution.
Solved by L.Maas. Go to Solution.
Better to post these questions in the Revit API forum.
Louis
Please mention Revit version, especially when uploading Revit files.
Can't find what you're looking for? Ask the community or share your knowledge.