-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathLesson 9. Create a Reinforcement. Working with geometry
72 lines (55 loc) · 2.48 KB
/
Lesson 9. Create a Reinforcement. Working with geometry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
import Autodesk
from Autodesk.Revit.DB import Transaction, Structure, FilteredElementCollector
from Autodesk.Revit.DB import BuiltInCategory, BuiltInParameter, Line, XYZ
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
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))
all_rebar_types = FilteredElementCollector(doc) \
.OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsElementType() \
.ToElements()
for rebar_type in all_rebar_types:
rebar_name = rebar_type.get_Parameter(BuiltInParameter \
.SYMBOL_NAME_PARAM).AsString()
if rebar_name == '10 A500':
bar_type = rebar_type
break
wall = [doc.GetElement( elId ) for elId in uidoc.Selection.GetElementIds()][0]
type_id = wall.GetTypeId()
type = doc.GetElement(type_id)
w_width = type.Width
w_height = wall.get_Parameter(BuiltInParameter \
.WALL_USER_HEIGHT_PARAM).AsDouble()
curve = wall.Location.Curve
p_1 = curve.GetEndPoint(0)
p_2 = curve.GetEndPoint(1)
cc_ext = doc.GetElement(wall.get_Parameter(BuiltInParameter \
.CLEAR_COVER_EXTERIOR).AsElementId()).CoverDistance
print(doc.GetElement(wall.get_Parameter(BuiltInParameter \
.CLEAR_COVER_EXTERIOR).AsElementId()))
cc_int = doc.GetElement(wall.get_Parameter(BuiltInParameter \
.CLEAR_COVER_INTERIOR).AsElementId()).CoverDistance
direction_y = curve.Direction
direction_x = direction_y.CrossProduct(XYZ.BasisZ).Normalize()
x_offset = w_width/2 - cc_ext - bar_type.BarDiameter / 2
y_offset = 50/304.8
rebar_p_1 = new_point(p_1, x_offset, y_offset , 0, direction_x, direction_y)
rebar_p_2 = new_point(rebar_p_1, 0, 0,w_height + 1000/304.8, direction_x, direction_y)
lines = [Line.CreateBound(rebar_p_1, rebar_p_2)]
step = 200/304.8
length = p_1.DistanceTo(p_2)
count = length / step
with Transaction(doc, "Reinforce") as t:
t.Start()
rebar = Structure.Rebar.CreateFromCurves(doc,
Structure.RebarStyle.Standard, bar_type, None, None, wall, direction_y,
lines, Structure.RebarHookOrientation.Right,
Structure.RebarHookOrientation.Left, True, True)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_LAYOUT_RULE).Set(3)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_BAR_SPACING).Set(step)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS).Set(count)
rebar.GetShapeDrivenAccessor().BarsOnNormalSide = True
t.Commit()