forked from tazjel/declaracad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.enaml
148 lines (134 loc) · 3.7 KB
/
house.enaml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import math
from enaml.core.api import Looper, Conditional
from declaracad.occ.api (
Box, Prism, Face, Segment, Arc, Wire, Point, Part,
Cut, Fuse, Offset, Fillet, Transform, ThickSolid, Pipe,
)
from OCC.gp import gp_Dir, gp_Ax1, gp_Pnt
from OCC.gce import gce_MakeDir
def inch(ft):
return ft/12.0
def distance(p0,p1):
# Returns distance between two points
return math.sqrt((p1[0]-p0[0])**2+(p1[1]-p0[1])**2)
def center(a,b,c):
return (a/2.0, b/2.0,c/2.0)
def angle(p0,p1):
# Returns angle vector of two x,y points
dx,dy = p1[0]-p0[0],p1[1]-p0[1]
a = math.atan2(dy, dx)
return a
#d = gce_MakeDir(gp_Pnt(p0[0],p0[1],0),gp_Pnt(p1[0],p1[1],0)).Value()
#d2 = gce_MakeDir(gp_Pnt(p1[0],p1[1],0),gp_Pnt(p0[0],p0[1],0)).Value()
#
ax = gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1))
d = gp_Dir(0,0,1)
d.Rotate(ax,a)
p = (d.X(),d.Y(),d.Z())
print(dx,dy,a,p)
#print dx,dy
#dmax = max(dx,dy)
#d = d.Crossed(gp_Dir(abs(dy),abs(dx),0))
return (d.X(),d.Y(),d.Z())
enamldef Wall(Fuse):
attr R = 13 # R value
attr thickness = inch(4) # ft
attr floor = 0 # Start of floor
attr height = 8 # ft
attr points = []
attr ax = 1.0
attr ay = 0.0
attr az = 0.0
# #: First child is the spline
# Wire:
# Segment:
# Looper:
# iterable << points
# Point:
# position << (loop_item[0],loop_item[1],0)
#
# #: Second is the profile
# Wire:
# Segment:
# Point:
# position << (0,0,0)
# Point:
# position << (0,thickness,0)
# Point:
# position << (0,thickness,height)
# Point:
# position << (0,0,height)
# Point:
# position << (0,0,0)
#
# #ThickSolid:
# # offset << thickness
# Prism:
# vector << (0,0,height)
# Wire: wire:
# Segment: segment:
# Looper:
# iterable << points
# Point:
# position << (loop_item[0],loop_item[1],0)
# Wire:
# Offset:
# offset = -thickness
# Wire:
# Transform:
# shape = wire
#
Looper:
iterable << points
Conditional:
condition = loop_index > 0
Transform:
attr pos << (points[loop_index-1][0],points[loop_index-1][1],floor)
rotate << (pos,(0,0,1),angle(points[loop_index-1],points[loop_index]))
Box:
position << pos
dx << distance(points[loop_index-1],points[loop_index])#+thickness
dy << thickness
dz << height
enamldef Assembly(Part):
name = "House"
Looper:
iterable << [
(0,0),
(0,25),
(45,25),
(45,0),
(0,0)
]
Point:
position << (loop_item[0],loop_item[1],0)
Wall:
# Ext
points = [
(0,0),
(0,25),
(45,25),
(45,0),
(0,0)
]
Wall:
# Master BR
points = [
(12,0),
(12,12),
(0,12),
]
Wall:
#: Closet
points = [
(0,15),
(8,15),
]
Wall:
#: BR 2
points = [
(8,12),
(8,15),
(11,18),
(11,25),
]