honeybee-core 1.64.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- honeybee/__init__.py +23 -0
- honeybee/__main__.py +4 -0
- honeybee/_base.py +331 -0
- honeybee/_basewithshade.py +310 -0
- honeybee/_lockable.py +99 -0
- honeybee/altnumber.py +47 -0
- honeybee/aperture.py +997 -0
- honeybee/boundarycondition.py +358 -0
- honeybee/checkdup.py +173 -0
- honeybee/cli/__init__.py +118 -0
- honeybee/cli/compare.py +132 -0
- honeybee/cli/create.py +265 -0
- honeybee/cli/edit.py +559 -0
- honeybee/cli/lib.py +103 -0
- honeybee/cli/setconfig.py +43 -0
- honeybee/cli/validate.py +224 -0
- honeybee/colorobj.py +363 -0
- honeybee/config.json +5 -0
- honeybee/config.py +347 -0
- honeybee/dictutil.py +54 -0
- honeybee/door.py +746 -0
- honeybee/extensionutil.py +208 -0
- honeybee/face.py +2360 -0
- honeybee/facetype.py +153 -0
- honeybee/logutil.py +79 -0
- honeybee/model.py +4272 -0
- honeybee/orientation.py +132 -0
- honeybee/properties.py +845 -0
- honeybee/room.py +3485 -0
- honeybee/search.py +107 -0
- honeybee/shade.py +514 -0
- honeybee/shademesh.py +362 -0
- honeybee/typing.py +498 -0
- honeybee/units.py +88 -0
- honeybee/writer/__init__.py +7 -0
- honeybee/writer/aperture.py +6 -0
- honeybee/writer/door.py +6 -0
- honeybee/writer/face.py +6 -0
- honeybee/writer/model.py +6 -0
- honeybee/writer/room.py +6 -0
- honeybee/writer/shade.py +6 -0
- honeybee/writer/shademesh.py +6 -0
- honeybee_core-1.64.12.dist-info/METADATA +94 -0
- honeybee_core-1.64.12.dist-info/RECORD +48 -0
- honeybee_core-1.64.12.dist-info/WHEEL +5 -0
- honeybee_core-1.64.12.dist-info/entry_points.txt +2 -0
- honeybee_core-1.64.12.dist-info/licenses/LICENSE +661 -0
- honeybee_core-1.64.12.dist-info/top_level.txt +1 -0
honeybee/aperture.py
ADDED
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
"""Honeybee Aperture."""
|
|
3
|
+
from __future__ import division
|
|
4
|
+
import math
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from ladybug_geometry.geometry2d import Vector2D
|
|
8
|
+
from ladybug_geometry.geometry3d import Point3D, Face3D
|
|
9
|
+
from ladybug.color import Color
|
|
10
|
+
|
|
11
|
+
from ._basewithshade import _BaseWithShade
|
|
12
|
+
from .typing import clean_string
|
|
13
|
+
from .search import get_attr_nested
|
|
14
|
+
from .properties import ApertureProperties
|
|
15
|
+
from .boundarycondition import boundary_conditions, Outdoors, Surface
|
|
16
|
+
from .facetype import RoofCeiling
|
|
17
|
+
from .shade import Shade
|
|
18
|
+
import honeybee.writer.aperture as writer
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Aperture(_BaseWithShade):
|
|
22
|
+
"""A single planar Aperture in a Face.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
identifier: Text string for a unique Aperture ID. Must be < 100 characters and
|
|
26
|
+
not contain any spaces or special characters.
|
|
27
|
+
geometry: A ladybug-geometry Face3D.
|
|
28
|
+
boundary_condition: Boundary condition object (Outdoors, Surface).
|
|
29
|
+
Default: Outdoors.
|
|
30
|
+
is_operable: Boolean to note whether the Aperture can be opened for
|
|
31
|
+
ventilation. (Default: False).
|
|
32
|
+
|
|
33
|
+
Properties:
|
|
34
|
+
* identifier
|
|
35
|
+
* display_name
|
|
36
|
+
* boundary_condition
|
|
37
|
+
* is_operable
|
|
38
|
+
* indoor_shades
|
|
39
|
+
* outdoor_shades
|
|
40
|
+
* parent
|
|
41
|
+
* top_level_parent
|
|
42
|
+
* has_parent
|
|
43
|
+
* geometry
|
|
44
|
+
* vertices
|
|
45
|
+
* upper_left_vertices
|
|
46
|
+
* triangulated_mesh3d
|
|
47
|
+
* normal
|
|
48
|
+
* center
|
|
49
|
+
* area
|
|
50
|
+
* perimeter
|
|
51
|
+
* min
|
|
52
|
+
* max
|
|
53
|
+
* tilt
|
|
54
|
+
* altitude
|
|
55
|
+
* azimuth
|
|
56
|
+
* is_exterior
|
|
57
|
+
* type_color
|
|
58
|
+
* bc_color
|
|
59
|
+
* user_data
|
|
60
|
+
"""
|
|
61
|
+
__slots__ = ('_geometry', '_parent', '_boundary_condition', '_is_operable')
|
|
62
|
+
TYPE_COLOR = Color(64, 180, 255, 100)
|
|
63
|
+
BC_COLORS = {
|
|
64
|
+
'Outdoors': Color(128, 204, 255, 100),
|
|
65
|
+
'Surface': Color(0, 190, 0, 100)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
def __init__(self, identifier, geometry, boundary_condition=None, is_operable=False):
|
|
69
|
+
"""A single planar aperture in a face."""
|
|
70
|
+
_BaseWithShade.__init__(self, identifier) # process the identifier
|
|
71
|
+
|
|
72
|
+
# process the geometry
|
|
73
|
+
assert isinstance(geometry, Face3D), \
|
|
74
|
+
'Expected ladybug_geometry Face3D. Got {}'.format(type(geometry))
|
|
75
|
+
self._geometry = geometry
|
|
76
|
+
self._parent = None # _parent will be set when the Aperture is added to a Face
|
|
77
|
+
|
|
78
|
+
# process the boundary condition and type
|
|
79
|
+
self.boundary_condition = boundary_condition or boundary_conditions.outdoors
|
|
80
|
+
self.is_operable = is_operable
|
|
81
|
+
|
|
82
|
+
# initialize properties for extensions
|
|
83
|
+
self._properties = ApertureProperties(self)
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def from_dict(cls, data):
|
|
87
|
+
"""Initialize an Aperture from a dictionary.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
data: A dictionary representation of an Aperture object.
|
|
91
|
+
"""
|
|
92
|
+
try:
|
|
93
|
+
# check the type of dictionary
|
|
94
|
+
assert data['type'] == 'Aperture', 'Expected Aperture dictionary. ' \
|
|
95
|
+
'Got {}.'.format(data['type'])
|
|
96
|
+
|
|
97
|
+
# serialize the aperture
|
|
98
|
+
is_operable = data['is_operable'] if 'is_operable' in data else False
|
|
99
|
+
if data['boundary_condition']['type'] == 'Outdoors':
|
|
100
|
+
boundary_condition = Outdoors.from_dict(data['boundary_condition'])
|
|
101
|
+
elif data['boundary_condition']['type'] == 'Surface':
|
|
102
|
+
boundary_condition = Surface.from_dict(data['boundary_condition'], True)
|
|
103
|
+
else:
|
|
104
|
+
raise ValueError(
|
|
105
|
+
'Boundary condition "{}" is not supported for Apertures.'.format(
|
|
106
|
+
data['boundary_condition']['type']))
|
|
107
|
+
aperture = cls(data['identifier'], Face3D.from_dict(data['geometry']),
|
|
108
|
+
boundary_condition, is_operable)
|
|
109
|
+
if 'display_name' in data and data['display_name'] is not None:
|
|
110
|
+
aperture.display_name = data['display_name']
|
|
111
|
+
if 'user_data' in data and data['user_data'] is not None:
|
|
112
|
+
aperture.user_data = data['user_data']
|
|
113
|
+
aperture._recover_shades_from_dict(data)
|
|
114
|
+
|
|
115
|
+
# assign extension properties
|
|
116
|
+
if data['properties']['type'] == 'ApertureProperties':
|
|
117
|
+
aperture.properties._load_extension_attr_from_dict(data['properties'])
|
|
118
|
+
return aperture
|
|
119
|
+
except Exception as e:
|
|
120
|
+
cls._from_dict_error_message(data, e)
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def from_vertices(cls, identifier, vertices, boundary_condition=None,
|
|
124
|
+
is_operable=False):
|
|
125
|
+
"""Create an Aperture from vertices with each vertex as an iterable of 3 floats.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
identifier: Text string for a unique Aperture ID. Must be < 100 characters
|
|
129
|
+
and not contain any spaces or special characters.
|
|
130
|
+
vertices: A flattened list of 3 or more vertices as (x, y, z).
|
|
131
|
+
boundary_condition: Boundary condition object (eg. Outdoors, Surface).
|
|
132
|
+
Default: Outdoors.
|
|
133
|
+
is_operable: Boolean to note whether the Aperture can be opened for
|
|
134
|
+
natural ventilation. Default: False
|
|
135
|
+
"""
|
|
136
|
+
geometry = Face3D(tuple(Point3D(*v) for v in vertices))
|
|
137
|
+
return cls(identifier, geometry, boundary_condition, is_operable)
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def boundary_condition(self):
|
|
141
|
+
"""Get or set the boundary condition of this aperture."""
|
|
142
|
+
return self._boundary_condition
|
|
143
|
+
|
|
144
|
+
@boundary_condition.setter
|
|
145
|
+
def boundary_condition(self, value):
|
|
146
|
+
if not isinstance(value, Outdoors):
|
|
147
|
+
if isinstance(value, Surface):
|
|
148
|
+
assert len(value.boundary_condition_objects) == 3, 'Surface boundary ' \
|
|
149
|
+
'condition for Aperture must have 3 boundary_condition_objects.'
|
|
150
|
+
else:
|
|
151
|
+
raise ValueError('Aperture only supports Outdoor or Surface boundary '
|
|
152
|
+
'condition. Got {}'.format(type(value)))
|
|
153
|
+
self._boundary_condition = value
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def is_operable(self):
|
|
157
|
+
"""Get or set a boolean for whether the Aperture can be opened for ventilation.
|
|
158
|
+
"""
|
|
159
|
+
return self._is_operable
|
|
160
|
+
|
|
161
|
+
@is_operable.setter
|
|
162
|
+
def is_operable(self, value):
|
|
163
|
+
try:
|
|
164
|
+
self._is_operable = bool(value)
|
|
165
|
+
except TypeError:
|
|
166
|
+
raise TypeError(
|
|
167
|
+
'Expected boolean for Aperture.is_operable. Got {}.'.format(value))
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def parent(self):
|
|
171
|
+
"""Get the parent Face if assigned. None if not assigned."""
|
|
172
|
+
return self._parent
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def top_level_parent(self):
|
|
176
|
+
"""Get the top-level parent object if assigned.
|
|
177
|
+
|
|
178
|
+
This will be a Room if there is a parent Face that has a parent Room and
|
|
179
|
+
will be a Face if the parent Face is orphaned. Will be None if no parent
|
|
180
|
+
is assigned.
|
|
181
|
+
"""
|
|
182
|
+
if self.has_parent:
|
|
183
|
+
if self._parent.has_parent:
|
|
184
|
+
return self._parent._parent
|
|
185
|
+
return self._parent
|
|
186
|
+
return None
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def has_parent(self):
|
|
190
|
+
"""Get a boolean noting whether this Aperture has a parent Face."""
|
|
191
|
+
return self._parent is not None
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def geometry(self):
|
|
195
|
+
"""Get a ladybug_geometry Face3D object representing the aperture."""
|
|
196
|
+
return self._geometry
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def vertices(self):
|
|
200
|
+
"""Get a list of vertices for the aperture (in counter-clockwise order)."""
|
|
201
|
+
return self._geometry.vertices
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def upper_left_vertices(self):
|
|
205
|
+
"""Get a list of vertices starting from the upper-left corner.
|
|
206
|
+
|
|
207
|
+
This property should be used when exporting to EnergyPlus / OpenStudio.
|
|
208
|
+
"""
|
|
209
|
+
return self._geometry.upper_left_counter_clockwise_vertices
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def triangulated_mesh3d(self):
|
|
213
|
+
"""Get a ladybug_geometry Mesh3D of the aperture geometry composed of triangles.
|
|
214
|
+
|
|
215
|
+
In EnergyPlus / OpenStudio workflows, this property is used to subdivide
|
|
216
|
+
the aperture when it has more than 4 vertices. This is necessary since
|
|
217
|
+
EnergyPlus cannot accept sub-faces with more than 4 vertices.
|
|
218
|
+
"""
|
|
219
|
+
return self._geometry.triangulated_mesh3d
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def normal(self):
|
|
223
|
+
"""Get a ladybug_geometry Vector3D for the direction the aperture is pointing.
|
|
224
|
+
"""
|
|
225
|
+
return self._geometry.normal
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def center(self):
|
|
229
|
+
"""Get a ladybug_geometry Point3D for the center of the aperture.
|
|
230
|
+
|
|
231
|
+
Note that this is the center of the bounding rectangle around this geometry
|
|
232
|
+
and not the area centroid.
|
|
233
|
+
"""
|
|
234
|
+
return self._geometry.center
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def area(self):
|
|
238
|
+
"""Get the area of the aperture."""
|
|
239
|
+
return self._geometry.area
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def perimeter(self):
|
|
243
|
+
"""Get the perimeter of the aperture."""
|
|
244
|
+
return self._geometry.perimeter
|
|
245
|
+
|
|
246
|
+
@property
|
|
247
|
+
def min(self):
|
|
248
|
+
"""Get a Point3D for the minimum of the bounding box around the object."""
|
|
249
|
+
return self._min_with_shades(self._geometry)
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def max(self):
|
|
253
|
+
"""Get a Point3D for the maximum of the bounding box around the object."""
|
|
254
|
+
return self._max_with_shades(self._geometry)
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def tilt(self):
|
|
258
|
+
"""Get the tilt of the geometry between 0 (up) and 180 (down)."""
|
|
259
|
+
return math.degrees(self._geometry.tilt)
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def altitude(self):
|
|
263
|
+
"""Get the altitude of the geometry between +90 (up) and -90 (down)."""
|
|
264
|
+
return math.degrees(self._geometry.altitude)
|
|
265
|
+
|
|
266
|
+
@property
|
|
267
|
+
def azimuth(self):
|
|
268
|
+
"""Get the azimuth of the geometry, between 0 and 360.
|
|
269
|
+
|
|
270
|
+
Given Y-axis as North, 0 = North, 90 = East, 180 = South, 270 = West
|
|
271
|
+
This will be zero if the Face3D is perfectly horizontal.
|
|
272
|
+
"""
|
|
273
|
+
return math.degrees(self._geometry.azimuth)
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def is_exterior(self):
|
|
277
|
+
"""Get a boolean for whether this object has an Outdoors boundary condition.
|
|
278
|
+
"""
|
|
279
|
+
return isinstance(self.boundary_condition, Outdoors)
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def gbxml_type(self):
|
|
283
|
+
"""Get text for the type of object this is in gbXML schema.
|
|
284
|
+
|
|
285
|
+
This will always be one of the following.
|
|
286
|
+
|
|
287
|
+
* FixedWindow
|
|
288
|
+
* OperableWindow
|
|
289
|
+
* FixedSkylight
|
|
290
|
+
* OperableSkylight
|
|
291
|
+
"""
|
|
292
|
+
base_type = 'Window'
|
|
293
|
+
if self.has_parent and isinstance(self.parent.type, RoofCeiling):
|
|
294
|
+
base_type = 'Skylight'
|
|
295
|
+
win_type = 'Fixed' if not self.is_operable else 'Operable'
|
|
296
|
+
return win_type + base_type
|
|
297
|
+
|
|
298
|
+
@property
|
|
299
|
+
def type_color(self):
|
|
300
|
+
"""Get a Color to be used in visualizations by type."""
|
|
301
|
+
return self.TYPE_COLOR
|
|
302
|
+
|
|
303
|
+
@property
|
|
304
|
+
def bc_color(self):
|
|
305
|
+
"""Get a Color to be used in visualizations by boundary condition."""
|
|
306
|
+
return self.BC_COLORS[self.boundary_condition.name]
|
|
307
|
+
|
|
308
|
+
def horizontal_orientation(self, north_vector=Vector2D(0, 1)):
|
|
309
|
+
"""Get a number between 0 and 360 for the orientation of the aperture in degrees.
|
|
310
|
+
|
|
311
|
+
0 = North, 90 = East, 180 = South, 270 = West
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
north_vector: A ladybug_geometry Vector2D for the north direction.
|
|
315
|
+
Default is the Y-axis (0, 1).
|
|
316
|
+
"""
|
|
317
|
+
return math.degrees(
|
|
318
|
+
north_vector.angle_clockwise(Vector2D(self.normal.x, self.normal.y)))
|
|
319
|
+
|
|
320
|
+
def cardinal_direction(self, north_vector=Vector2D(0, 1), angle_tolerance=1):
|
|
321
|
+
"""Get text description for the cardinal direction that the aperture is pointing.
|
|
322
|
+
|
|
323
|
+
Will be one of the following: ('North', 'NorthEast', 'East', 'SouthEast',
|
|
324
|
+
'South', 'SouthWest', 'West', 'NorthWest', 'Up', 'Down').
|
|
325
|
+
|
|
326
|
+
Args:
|
|
327
|
+
north_vector: A ladybug_geometry Vector2D for the north direction.
|
|
328
|
+
Default is the Y-axis (0, 1).
|
|
329
|
+
angle_tolerance: The angle tolerance in degrees used to determine if
|
|
330
|
+
the geometry is perfectly Up or Down. (Default: 1).
|
|
331
|
+
"""
|
|
332
|
+
tilt = self.tilt
|
|
333
|
+
if tilt < angle_tolerance:
|
|
334
|
+
return 'Up'
|
|
335
|
+
elif tilt > 180 - angle_tolerance:
|
|
336
|
+
return 'Down'
|
|
337
|
+
orient = self.horizontal_orientation(north_vector)
|
|
338
|
+
orient_text = ('North', 'NorthEast', 'East', 'SouthEast', 'South',
|
|
339
|
+
'SouthWest', 'West', 'NorthWest')
|
|
340
|
+
angles = (22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5)
|
|
341
|
+
for i, ang in enumerate(angles):
|
|
342
|
+
if orient < ang:
|
|
343
|
+
return orient_text[i]
|
|
344
|
+
return orient_text[0]
|
|
345
|
+
|
|
346
|
+
def cardinal_abbrev(self, north_vector=Vector2D(0, 1), angle_tolerance=1):
|
|
347
|
+
"""Get text abbreviation for the cardinal direction that the aperture is pointing.
|
|
348
|
+
|
|
349
|
+
Will be one of the following: ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW',
|
|
350
|
+
'Up', 'Down').
|
|
351
|
+
|
|
352
|
+
Args:
|
|
353
|
+
north_vector: A ladybug_geometry Vector2D for the north direction.
|
|
354
|
+
Default is the Y-axis (0, 1).
|
|
355
|
+
angle_tolerance: The angle tolerance in degrees used to determine if
|
|
356
|
+
the aperture is perfectly Up or Down. (Default: 1).
|
|
357
|
+
"""
|
|
358
|
+
tilt = self.tilt
|
|
359
|
+
if tilt < angle_tolerance:
|
|
360
|
+
return 'Up'
|
|
361
|
+
elif tilt > 180 - angle_tolerance:
|
|
362
|
+
return 'Down'
|
|
363
|
+
orient = self.horizontal_orientation(north_vector)
|
|
364
|
+
orient_text = ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW')
|
|
365
|
+
angles = (22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5)
|
|
366
|
+
for i, ang in enumerate(angles):
|
|
367
|
+
if orient < ang:
|
|
368
|
+
return orient_text[i]
|
|
369
|
+
return orient_text[0]
|
|
370
|
+
|
|
371
|
+
def add_prefix(self, prefix):
|
|
372
|
+
"""Change the identifier of this object and child objects by inserting a prefix.
|
|
373
|
+
|
|
374
|
+
This is particularly useful in workflows where you duplicate and edit
|
|
375
|
+
a starting object and then want to combine it with the original object
|
|
376
|
+
into one Model (like making a model of repeated rooms) since all objects
|
|
377
|
+
within a Model must have unique identifiers.
|
|
378
|
+
|
|
379
|
+
Args:
|
|
380
|
+
prefix: Text that will be inserted at the start of this object's
|
|
381
|
+
(and child objects') identifier and display_name. It is recommended
|
|
382
|
+
that this prefix be short to avoid maxing out the 100 allowable
|
|
383
|
+
characters for honeybee identifiers.
|
|
384
|
+
"""
|
|
385
|
+
self._identifier = clean_string('{}_{}'.format(prefix, self.identifier))
|
|
386
|
+
self.display_name = '{}_{}'.format(prefix, self.display_name)
|
|
387
|
+
self.properties.add_prefix(prefix)
|
|
388
|
+
self._add_prefix_shades(prefix)
|
|
389
|
+
if isinstance(self._boundary_condition, Surface):
|
|
390
|
+
new_bc_objs = (clean_string('{}_{}'.format(prefix, adj_name)) for adj_name
|
|
391
|
+
in self._boundary_condition._boundary_condition_objects)
|
|
392
|
+
self._boundary_condition = Surface(new_bc_objs, True)
|
|
393
|
+
|
|
394
|
+
def rename_by_attribute(
|
|
395
|
+
self,
|
|
396
|
+
format_str='{parent.parent.display_name} - {gbxml_type} - {cardinal_direction}'
|
|
397
|
+
):
|
|
398
|
+
"""Set the display name of this Aperture using a format string with attributes.
|
|
399
|
+
|
|
400
|
+
Args:
|
|
401
|
+
format_str: Text string for the pattern with which the Aperture will be
|
|
402
|
+
renamed. Any property on this class may be used (eg. gbxml_str)
|
|
403
|
+
and each property should be put in curly brackets. Nested
|
|
404
|
+
properties can be specified by using "." to denote nesting levels
|
|
405
|
+
(eg. properties.energy.construction.display_name). Functions that
|
|
406
|
+
return string outputs can also be passed here as long as these
|
|
407
|
+
functions defaults specified for all arguments.
|
|
408
|
+
"""
|
|
409
|
+
matches = re.findall(r'{([^}]*)}', format_str)
|
|
410
|
+
attributes = [get_attr_nested(self, m, decimal_count=2) for m in matches]
|
|
411
|
+
for attr_name, attr_val in zip(matches, attributes):
|
|
412
|
+
format_str = format_str.replace('{{{}}}'.format(attr_name), attr_val)
|
|
413
|
+
self.display_name = format_str
|
|
414
|
+
return format_str
|
|
415
|
+
|
|
416
|
+
def set_adjacency(self, other_aperture):
|
|
417
|
+
"""Set this aperture to be adjacent to another.
|
|
418
|
+
|
|
419
|
+
Note that this method does not verify whether the other_aperture geometry is
|
|
420
|
+
co-planar or compatible with this one so it is recommended that a test
|
|
421
|
+
be performed before using this method in order to verify these criteria.
|
|
422
|
+
The Face3D.is_centered_adjacent() or the Face3D.is_geometrically_equivalent()
|
|
423
|
+
methods are both suitable for this purpose.
|
|
424
|
+
|
|
425
|
+
Args:
|
|
426
|
+
other_aperture: Another Aperture object to be set adjacent to this one.
|
|
427
|
+
"""
|
|
428
|
+
assert isinstance(other_aperture, Aperture), \
|
|
429
|
+
'Expected Aperture. Got {}.'.format(type(other_aperture))
|
|
430
|
+
assert other_aperture.is_operable is self.is_operable, \
|
|
431
|
+
'Adjacent apertures must have matching is_operable properties.'
|
|
432
|
+
self._boundary_condition = boundary_conditions.surface(other_aperture, True)
|
|
433
|
+
other_aperture._boundary_condition = boundary_conditions.surface(self, True)
|
|
434
|
+
|
|
435
|
+
def overhang(self, depth, angle=0, indoor=False, tolerance=0.01, base_name=None):
|
|
436
|
+
"""Add a single overhang for this Aperture.
|
|
437
|
+
|
|
438
|
+
Args:
|
|
439
|
+
depth: A number for the overhang depth.
|
|
440
|
+
angle: A number for the for an angle to rotate the overhang in degrees.
|
|
441
|
+
Positive numbers indicate a downward rotation while negative numbers
|
|
442
|
+
indicate an upward rotation. Default is 0 for no rotation.
|
|
443
|
+
indoor: Boolean for whether the overhang should be generated facing the
|
|
444
|
+
opposite direction of the aperture normal (typically meaning
|
|
445
|
+
indoor geometry). Default: False.
|
|
446
|
+
tolerance: An optional value to return None if the overhang has a length less
|
|
447
|
+
than the tolerance. Default: 0.01, suitable for objects in meters.
|
|
448
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
449
|
+
is InOverhang or OutOverhang depending on whether indoor is True.
|
|
450
|
+
|
|
451
|
+
Returns:
|
|
452
|
+
A list of the new Shade objects that have been generated.
|
|
453
|
+
"""
|
|
454
|
+
if base_name is None:
|
|
455
|
+
base_name = 'InOverhang' if indoor else 'OutOverhang'
|
|
456
|
+
return self.louvers_by_count(1, depth, angle=angle, indoor=indoor,
|
|
457
|
+
tolerance=tolerance, base_name=base_name)
|
|
458
|
+
|
|
459
|
+
def right_fin(self, depth, angle=0, indoor=False, tolerance=0.01, base_name=None):
|
|
460
|
+
"""Add a single vertical fin on the right side of this Aperture.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
depth: A number for the fin depth.
|
|
464
|
+
angle: A number for the for an angle to rotate the fin in degrees.
|
|
465
|
+
Default is 0 for no rotation.
|
|
466
|
+
indoor: Boolean for whether the fin should be generated facing the
|
|
467
|
+
opposite direction of the aperture normal (typically meaning
|
|
468
|
+
indoor geometry). Default: False.
|
|
469
|
+
tolerance: An optional value to return None if the fin has a length less
|
|
470
|
+
than the tolerance. Default: 0.01, suitable for objects in meters.
|
|
471
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
472
|
+
is InRightFin or OutRightFin depending on whether indoor is True.
|
|
473
|
+
|
|
474
|
+
Returns:
|
|
475
|
+
A list of the new Shade objects that have been generated.
|
|
476
|
+
"""
|
|
477
|
+
if base_name is None:
|
|
478
|
+
base_name = 'InRightFin' if indoor else 'OutRightFin'
|
|
479
|
+
return self.louvers_by_count(
|
|
480
|
+
1, depth, angle=angle, contour_vector=Vector2D(1, 0),
|
|
481
|
+
indoor=indoor, tolerance=tolerance, base_name=base_name)
|
|
482
|
+
|
|
483
|
+
def left_fin(self, depth, angle=0, indoor=False, tolerance=0.01, base_name=None):
|
|
484
|
+
"""Add a single vertical fin on the left side of this Aperture.
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
depth: A number for the fin depth.
|
|
488
|
+
angle: A number for the for an angle to rotate the fin in degrees.
|
|
489
|
+
Default is 0 for no rotation.
|
|
490
|
+
indoor: Boolean for whether the fin should be generated facing the
|
|
491
|
+
opposite direction of the aperture normal (typically meaning
|
|
492
|
+
indoor geometry). Default: False.
|
|
493
|
+
tolerance: An optional value to return None if the fin has a length less
|
|
494
|
+
than the tolerance. Default: 0.01, suitable for objects in meters.
|
|
495
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
496
|
+
is InLeftFin or OutLeftFin depending on whether indoor is True.
|
|
497
|
+
|
|
498
|
+
Returns:
|
|
499
|
+
A list of the new Shade objects that have been generated.
|
|
500
|
+
"""
|
|
501
|
+
if base_name is None:
|
|
502
|
+
base_name = 'InLeftFin' if indoor else 'OutLeftFin'
|
|
503
|
+
return self.louvers_by_count(
|
|
504
|
+
1, depth, angle=angle, contour_vector=Vector2D(1, 0),
|
|
505
|
+
flip_start_side=True, indoor=indoor, tolerance=tolerance,
|
|
506
|
+
base_name=base_name)
|
|
507
|
+
|
|
508
|
+
def extruded_border(self, depth, indoor=False, base_name=None):
|
|
509
|
+
"""Add a series of Shade objects to this Aperture that form an extruded border.
|
|
510
|
+
|
|
511
|
+
Args:
|
|
512
|
+
depth: A number for the extrusion depth.
|
|
513
|
+
indoor: Boolean for whether the extrusion should be generated facing the
|
|
514
|
+
opposite direction of the aperture normal and added to the Aperture's
|
|
515
|
+
indoor_shades instead of outdoor_shades. Default: False.
|
|
516
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
517
|
+
is InBorder or OutBorder depending on whether indoor is True.
|
|
518
|
+
|
|
519
|
+
Returns:
|
|
520
|
+
A list of the new Shade objects that have been generated.
|
|
521
|
+
"""
|
|
522
|
+
extru_vec = self.normal if indoor is False else self.normal.reverse()
|
|
523
|
+
extru_vec = extru_vec * depth
|
|
524
|
+
extrusion = []
|
|
525
|
+
shd_count = 0
|
|
526
|
+
if base_name is None:
|
|
527
|
+
shd_name_base = '{}_InBorder{}' if indoor else '{}_OutBorder{}'
|
|
528
|
+
else:
|
|
529
|
+
shd_name_base = '{}_' + str(base_name) + '{}'
|
|
530
|
+
for seg in self.geometry.boundary_segments:
|
|
531
|
+
shade_geo = Face3D.from_extrusion(seg, extru_vec)
|
|
532
|
+
extrusion.append(
|
|
533
|
+
Shade(shd_name_base.format(self.identifier, shd_count), shade_geo))
|
|
534
|
+
shd_count += 1
|
|
535
|
+
if self.geometry.has_holes:
|
|
536
|
+
for hole in self.geometry.hole_segments:
|
|
537
|
+
for seg in hole:
|
|
538
|
+
shade_geo = Face3D.from_extrusion(seg, extru_vec)
|
|
539
|
+
extrusion.append(
|
|
540
|
+
Shade(shd_name_base.format(self.identifier, shd_count),
|
|
541
|
+
shade_geo))
|
|
542
|
+
shd_count += 1
|
|
543
|
+
if indoor:
|
|
544
|
+
self.add_indoor_shades(extrusion)
|
|
545
|
+
else:
|
|
546
|
+
self.add_outdoor_shades(extrusion)
|
|
547
|
+
return extrusion
|
|
548
|
+
|
|
549
|
+
def louvers(self, depth, louver_count=None, distance=None, offset=0, angle=0,
|
|
550
|
+
contour_vector=Vector2D(0, 1), flip_start_side=False,
|
|
551
|
+
indoor=False, tolerance=0.01, base_name=None):
|
|
552
|
+
"""Add a series of louvered Shade objects over this Aperture.
|
|
553
|
+
|
|
554
|
+
If both louver_count and distance are None, this method will add a
|
|
555
|
+
single louver shade following the other criteria.
|
|
556
|
+
|
|
557
|
+
Args:
|
|
558
|
+
depth: A number for the depth to extrude the louvers.
|
|
559
|
+
louver_count: A positive integer for the number of louvers to generate.
|
|
560
|
+
If None, louvers will be generated to fill the Aperture at the
|
|
561
|
+
specified distance. (Default: None).
|
|
562
|
+
distance: A number for the approximate distance between each louver.
|
|
563
|
+
If None, louvers will be generated to fill the Aperture at the
|
|
564
|
+
specified louver_count. (Default: None).
|
|
565
|
+
offset: A number for the distance to louvers from this Aperture.
|
|
566
|
+
Default is 0 for no offset.
|
|
567
|
+
angle: A number for the for an angle to rotate the louvers in degrees.
|
|
568
|
+
Positive numbers indicate a downward rotation while negative numbers
|
|
569
|
+
indicate an upward rotation. Default is 0 for no rotation.
|
|
570
|
+
contour_vector: A Vector2D for the direction along which contours
|
|
571
|
+
are generated. This 2D vector will be interpreted into a 3D vector
|
|
572
|
+
within the plane of this Aperture. (0, 1) will usually generate
|
|
573
|
+
horizontal contours in 3D space, (1, 0) will generate vertical
|
|
574
|
+
contours, and (1, 1) will generate diagonal contours. Default: (0, 1).
|
|
575
|
+
flip_start_side: Boolean to note whether the side the louvers start from
|
|
576
|
+
should be flipped. Default is False to have louvers on top or right.
|
|
577
|
+
Setting to True will start contours on the bottom or left.
|
|
578
|
+
indoor: Boolean for whether louvers should be generated facing the
|
|
579
|
+
opposite direction of the Aperture normal (typically meaning
|
|
580
|
+
indoor geometry). Default: False.
|
|
581
|
+
tolerance: An optional value to remove any louvers with a length less
|
|
582
|
+
than the tolerance. Default: 0.01, suitable for objects in meters.
|
|
583
|
+
base_name: Optional base identifier for the shade objects. If None,
|
|
584
|
+
the default is InShd or OutShd depending on whether indoor is True.
|
|
585
|
+
|
|
586
|
+
Returns:
|
|
587
|
+
A list of the new Shade objects that have been generated.
|
|
588
|
+
"""
|
|
589
|
+
if depth == 0 or louver_count == 0:
|
|
590
|
+
return []
|
|
591
|
+
elif louver_count is None and distance is None:
|
|
592
|
+
return self.louvers_by_count(
|
|
593
|
+
1, depth, offset, angle, contour_vector, flip_start_side, indoor,
|
|
594
|
+
tolerance=tolerance, base_name=base_name)
|
|
595
|
+
elif distance is None:
|
|
596
|
+
return self.louvers_by_count(
|
|
597
|
+
louver_count, depth, offset, angle, contour_vector,
|
|
598
|
+
flip_start_side, indoor, tolerance=tolerance, base_name=base_name)
|
|
599
|
+
else:
|
|
600
|
+
return self.louvers_by_distance_between(
|
|
601
|
+
distance, depth, offset, angle, contour_vector, flip_start_side, indoor,
|
|
602
|
+
tolerance=tolerance, max_count=louver_count, base_name=base_name)
|
|
603
|
+
|
|
604
|
+
def louvers_by_count(self, louver_count, depth, offset=0, angle=0,
|
|
605
|
+
contour_vector=Vector2D(0, 1), flip_start_side=False,
|
|
606
|
+
indoor=False, tolerance=0.01, base_name=None):
|
|
607
|
+
"""Add louvered Shade objects over this Aperture to hit a target louver_count.
|
|
608
|
+
|
|
609
|
+
Args:
|
|
610
|
+
louver_count: A positive integer for the number of louvers to generate.
|
|
611
|
+
depth: A number for the depth to extrude the louvers.
|
|
612
|
+
offset: A number for the distance to louvers from this aperture.
|
|
613
|
+
Default is 0 for no offset.
|
|
614
|
+
angle: A number for the for an angle to rotate the louvers in degrees.
|
|
615
|
+
Positive numbers indicate a downward rotation while negative numbers
|
|
616
|
+
indicate an upward rotation. Default is 0 for no rotation.
|
|
617
|
+
contour_vector: A Vector2D for the direction along which contours
|
|
618
|
+
are generated. This 2D vector will be interpreted into a 3D vector
|
|
619
|
+
within the plane of this Aperture. (0, 1) will usually generate
|
|
620
|
+
horizontal contours in 3D space, (1, 0) will generate vertical
|
|
621
|
+
contours, and (1, 1) will generate diagonal contours. Default: (0, 1).
|
|
622
|
+
flip_start_side: Boolean to note whether the side the louvers start from
|
|
623
|
+
should be flipped. Default is False to have louvers on top or right.
|
|
624
|
+
Setting to True will start contours on the bottom or left.
|
|
625
|
+
indoor: Boolean for whether louvers should be generated facing the
|
|
626
|
+
opposite direction of the aperture normal (typically meaning
|
|
627
|
+
indoor geometry). Default: False.
|
|
628
|
+
tolerance: An optional value to remove any louvers with a length less
|
|
629
|
+
than the tolerance. Default: 0.01, suitable for objects in meters.
|
|
630
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
631
|
+
is InShd or OutShd depending on whether indoor is True.
|
|
632
|
+
|
|
633
|
+
Returns:
|
|
634
|
+
A list of the new Shade objects that have been generated.
|
|
635
|
+
"""
|
|
636
|
+
assert louver_count > 0, 'louver_count must be greater than 0.'
|
|
637
|
+
angle = math.radians(angle)
|
|
638
|
+
louvers = []
|
|
639
|
+
ap_geo = self.geometry if indoor is False else self.geometry.flip()
|
|
640
|
+
shade_faces = ap_geo.contour_fins_by_number(
|
|
641
|
+
louver_count, depth, offset, angle,
|
|
642
|
+
contour_vector, flip_start_side, tolerance)
|
|
643
|
+
if base_name is None:
|
|
644
|
+
shd_name_base = '{}_InShd{}' if indoor else '{}_OutShd{}'
|
|
645
|
+
else:
|
|
646
|
+
shd_name_base = '{}_' + str(base_name) + '{}'
|
|
647
|
+
for i, shade_geo in enumerate(shade_faces):
|
|
648
|
+
louvers.append(Shade(shd_name_base.format(self.identifier, i), shade_geo))
|
|
649
|
+
if indoor:
|
|
650
|
+
self.add_indoor_shades(louvers)
|
|
651
|
+
else:
|
|
652
|
+
self.add_outdoor_shades(louvers)
|
|
653
|
+
return louvers
|
|
654
|
+
|
|
655
|
+
def louvers_by_distance_between(
|
|
656
|
+
self, distance, depth, offset=0, angle=0, contour_vector=Vector2D(0, 1),
|
|
657
|
+
flip_start_side=False, indoor=False, tolerance=0.01, max_count=None,
|
|
658
|
+
base_name=None):
|
|
659
|
+
"""Add louvered Shades over this Aperture to hit a target distance between.
|
|
660
|
+
|
|
661
|
+
Args:
|
|
662
|
+
distance: A number for the approximate distance between each louver.
|
|
663
|
+
depth: A number for the depth to extrude the louvers.
|
|
664
|
+
offset: A number for the distance to louvers from this aperture.
|
|
665
|
+
Default is 0 for no offset.
|
|
666
|
+
angle: A number for the for an angle to rotate the louvers in degrees.
|
|
667
|
+
Positive numbers indicate a downward rotation while negative numbers
|
|
668
|
+
indicate an upward rotation. Default is 0 for no rotation.
|
|
669
|
+
contour_vector: A Vector2D for the direction along which contours
|
|
670
|
+
are generated. This 2D vector will be interpreted into a 3D vector
|
|
671
|
+
within the plane of this Aperture. (0, 1) will usually generate
|
|
672
|
+
horizontal contours in 3D space, (1, 0) will generate vertical
|
|
673
|
+
contours, and (1, 1) will generate diagonal contours. Default: (0, 1).
|
|
674
|
+
flip_start_side: Boolean to note whether the side the louvers start from
|
|
675
|
+
should be flipped. Default is False to have contours on top or right.
|
|
676
|
+
Setting to True will start contours on the bottom or left.
|
|
677
|
+
indoor: Boolean for whether louvers should be generated facing the
|
|
678
|
+
opposite direction of the aperture normal (typically meaning
|
|
679
|
+
indoor geometry). Default: 0.01, suitable for objects in meters.
|
|
680
|
+
tolerance: An optional value to remove any louvers with a length less
|
|
681
|
+
than the tolerance. Default is 0, which will include all louvers
|
|
682
|
+
no matter how small.
|
|
683
|
+
max_count: Optional integer to set the maximum number of louvers that
|
|
684
|
+
will be generated. If None, louvers will cover the entire aperture.
|
|
685
|
+
base_name: Optional base name for the shade objects. If None, the default
|
|
686
|
+
is InShd or OutShd depending on whether indoor is True.
|
|
687
|
+
|
|
688
|
+
Returns:
|
|
689
|
+
A list of the new Shade objects that have been generated.
|
|
690
|
+
"""
|
|
691
|
+
# set defaults
|
|
692
|
+
angle = math.radians(angle)
|
|
693
|
+
ap_geo = self.geometry if indoor is False else self.geometry.flip()
|
|
694
|
+
if base_name is None:
|
|
695
|
+
shd_name_base = '{}_InShd{}' if indoor else '{}_OutShd{}'
|
|
696
|
+
else:
|
|
697
|
+
shd_name_base = '{}_' + str(base_name) + '{}'
|
|
698
|
+
|
|
699
|
+
# generate shade geometries
|
|
700
|
+
shade_faces = ap_geo.contour_fins_by_distance_between(
|
|
701
|
+
distance, depth, offset, angle,
|
|
702
|
+
contour_vector, flip_start_side, tolerance)
|
|
703
|
+
if max_count:
|
|
704
|
+
try:
|
|
705
|
+
shade_faces = shade_faces[:max_count]
|
|
706
|
+
except IndexError: # fewer shades were generated than the max count
|
|
707
|
+
pass
|
|
708
|
+
|
|
709
|
+
# create the shade objects
|
|
710
|
+
louvers = []
|
|
711
|
+
for i, shade_geo in enumerate(shade_faces):
|
|
712
|
+
louvers.append(Shade(shd_name_base.format(self.identifier, i), shade_geo))
|
|
713
|
+
if indoor:
|
|
714
|
+
self.add_indoor_shades(louvers)
|
|
715
|
+
else:
|
|
716
|
+
self.add_outdoor_shades(louvers)
|
|
717
|
+
return louvers
|
|
718
|
+
|
|
719
|
+
def move(self, moving_vec):
|
|
720
|
+
"""Move this Aperture along a vector.
|
|
721
|
+
|
|
722
|
+
Args:
|
|
723
|
+
moving_vec: A ladybug_geometry Vector3D with the direction and distance
|
|
724
|
+
to move the face.
|
|
725
|
+
"""
|
|
726
|
+
self._geometry = self.geometry.move(moving_vec)
|
|
727
|
+
self.move_shades(moving_vec)
|
|
728
|
+
self.properties.move(moving_vec)
|
|
729
|
+
self._reset_parent_geometry()
|
|
730
|
+
|
|
731
|
+
def rotate(self, axis, angle, origin):
|
|
732
|
+
"""Rotate this Aperture by a certain angle around an axis and origin.
|
|
733
|
+
|
|
734
|
+
Args:
|
|
735
|
+
axis: A ladybug_geometry Vector3D axis representing the axis of rotation.
|
|
736
|
+
angle: An angle for rotation in degrees.
|
|
737
|
+
origin: A ladybug_geometry Point3D for the origin around which the
|
|
738
|
+
object will be rotated.
|
|
739
|
+
"""
|
|
740
|
+
self._geometry = self.geometry.rotate(axis, math.radians(angle), origin)
|
|
741
|
+
self.rotate_shades(axis, angle, origin)
|
|
742
|
+
self.properties.rotate(axis, angle, origin)
|
|
743
|
+
self._reset_parent_geometry()
|
|
744
|
+
|
|
745
|
+
def rotate_xy(self, angle, origin):
|
|
746
|
+
"""Rotate this Aperture counterclockwise in the world XY plane by an angle.
|
|
747
|
+
|
|
748
|
+
Args:
|
|
749
|
+
angle: An angle in degrees.
|
|
750
|
+
origin: A ladybug_geometry Point3D for the origin around which the
|
|
751
|
+
object will be rotated.
|
|
752
|
+
"""
|
|
753
|
+
self._geometry = self.geometry.rotate_xy(math.radians(angle), origin)
|
|
754
|
+
self.rotate_xy_shades(angle, origin)
|
|
755
|
+
self.properties.rotate_xy(angle, origin)
|
|
756
|
+
self._reset_parent_geometry()
|
|
757
|
+
|
|
758
|
+
def reflect(self, plane):
|
|
759
|
+
"""Reflect this Aperture across a plane.
|
|
760
|
+
|
|
761
|
+
Args:
|
|
762
|
+
plane: A ladybug_geometry Plane across which the object will
|
|
763
|
+
be reflected.
|
|
764
|
+
"""
|
|
765
|
+
self._geometry = self.geometry.reflect(plane.n, plane.o)
|
|
766
|
+
self.reflect_shades(plane)
|
|
767
|
+
self.properties.reflect(plane)
|
|
768
|
+
self._reset_parent_geometry()
|
|
769
|
+
|
|
770
|
+
def scale(self, factor, origin=None):
|
|
771
|
+
"""Scale this Aperture by a factor from an origin point.
|
|
772
|
+
|
|
773
|
+
Args:
|
|
774
|
+
factor: A number representing how much the object should be scaled.
|
|
775
|
+
origin: A ladybug_geometry Point3D representing the origin from which
|
|
776
|
+
to scale. If None, it will be scaled from the World origin (0, 0, 0).
|
|
777
|
+
"""
|
|
778
|
+
self._geometry = self.geometry.scale(factor, origin)
|
|
779
|
+
self.scale_shades(factor, origin)
|
|
780
|
+
self.properties.scale(factor, origin)
|
|
781
|
+
self._reset_parent_geometry()
|
|
782
|
+
|
|
783
|
+
def remove_colinear_vertices(self, tolerance=0.01):
|
|
784
|
+
"""Remove all colinear and duplicate vertices from this object's geometry.
|
|
785
|
+
|
|
786
|
+
Note that this does not affect any assigned Shades.
|
|
787
|
+
|
|
788
|
+
Args:
|
|
789
|
+
tolerance: The minimum distance between a vertex and the boundary segments
|
|
790
|
+
at which point the vertex is considered colinear. Default: 0.01,
|
|
791
|
+
suitable for objects in meters.
|
|
792
|
+
"""
|
|
793
|
+
try:
|
|
794
|
+
self._geometry = self.geometry.remove_colinear_vertices(tolerance)
|
|
795
|
+
except AssertionError as e: # usually a sliver face of some kind
|
|
796
|
+
raise ValueError(
|
|
797
|
+
'Aperture "{}" is invalid with dimensions less than the '
|
|
798
|
+
'tolerance.\n{}'.format(self.full_id, e))
|
|
799
|
+
|
|
800
|
+
def is_geo_equivalent(self, aperture, tolerance=0.01):
|
|
801
|
+
"""Get a boolean for whether this object is geometrically equivalent to another.
|
|
802
|
+
|
|
803
|
+
The total number of vertices and the ordering of these vertices can be
|
|
804
|
+
different but the geometries must share the same center point and be
|
|
805
|
+
next to one another to within the tolerance.
|
|
806
|
+
|
|
807
|
+
Args:
|
|
808
|
+
aperture: Another Aperture for which geometric equivalency will be tested.
|
|
809
|
+
tolerance: The minimum difference between the coordinate values of two
|
|
810
|
+
vertices at which they can be considered geometrically equivalent.
|
|
811
|
+
|
|
812
|
+
Returns:
|
|
813
|
+
True if geometrically equivalent. False if not geometrically equivalent.
|
|
814
|
+
"""
|
|
815
|
+
meta_1 = (self.display_name, self.is_operable, self.boundary_condition)
|
|
816
|
+
meta_2 = (aperture.display_name, aperture.is_operable,
|
|
817
|
+
aperture.boundary_condition)
|
|
818
|
+
if meta_1 != meta_2:
|
|
819
|
+
return False
|
|
820
|
+
if abs(self.area - aperture.area) > tolerance * self.area:
|
|
821
|
+
return False
|
|
822
|
+
if not self.geometry.is_centered_adjacent(aperture.geometry, tolerance):
|
|
823
|
+
return False
|
|
824
|
+
if not self._are_shades_equivalent(aperture, tolerance):
|
|
825
|
+
return False
|
|
826
|
+
return True
|
|
827
|
+
|
|
828
|
+
def check_planar(self, tolerance=0.01, raise_exception=True, detailed=False):
|
|
829
|
+
"""Check whether all of the Aperture's vertices lie within the same plane.
|
|
830
|
+
|
|
831
|
+
Args:
|
|
832
|
+
tolerance: The minimum distance between a given vertex and a the
|
|
833
|
+
object's plane at which the vertex is said to lie in the plane.
|
|
834
|
+
Default: 0.01, suitable for objects in meters.
|
|
835
|
+
raise_exception: Boolean to note whether an ValueError should be
|
|
836
|
+
raised if a vertex does not lie within the object's plane.
|
|
837
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
838
|
+
dicts with error info or a string with a message. (Default: False).
|
|
839
|
+
|
|
840
|
+
Returns:
|
|
841
|
+
A string with the message or a list with a dictionary if detailed is True.
|
|
842
|
+
"""
|
|
843
|
+
try:
|
|
844
|
+
self.geometry.check_planar(tolerance, raise_exception=True)
|
|
845
|
+
except ValueError as e:
|
|
846
|
+
msg = 'Aperture "{}" is not planar.\n{}'.format(self.full_id, e)
|
|
847
|
+
full_msg = self._validation_message(
|
|
848
|
+
msg, raise_exception, detailed, '000101',
|
|
849
|
+
error_type='Non-Planar Geometry')
|
|
850
|
+
if detailed: # add the out-of-plane points to helper_geometry
|
|
851
|
+
help_pts = [
|
|
852
|
+
p.to_dict() for p in self.geometry.non_planar_vertices(tolerance)
|
|
853
|
+
]
|
|
854
|
+
full_msg[0]['helper_geometry'] = help_pts
|
|
855
|
+
return full_msg
|
|
856
|
+
return [] if detailed else ''
|
|
857
|
+
|
|
858
|
+
def check_self_intersecting(self, tolerance=0.01, raise_exception=True,
|
|
859
|
+
detailed=False):
|
|
860
|
+
"""Check whether the edges of the Aperture intersect one another (like a bowtie).
|
|
861
|
+
|
|
862
|
+
Note that objects that have duplicate vertices will not be considered
|
|
863
|
+
self-intersecting and are valid in honeybee.
|
|
864
|
+
|
|
865
|
+
Args:
|
|
866
|
+
tolerance: The minimum difference between the coordinate values of two
|
|
867
|
+
vertices at which they can be considered equivalent. Default: 0.01,
|
|
868
|
+
suitable for objects in meters.
|
|
869
|
+
raise_exception: If True, a ValueError will be raised if the object
|
|
870
|
+
intersects with itself. Default: True.
|
|
871
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
872
|
+
dicts with error info or a string with a message. (Default: False).
|
|
873
|
+
|
|
874
|
+
Returns:
|
|
875
|
+
A string with the message or a list with a dictionary if detailed is True.
|
|
876
|
+
"""
|
|
877
|
+
if self.geometry.is_self_intersecting:
|
|
878
|
+
msg = 'Aperture "{}" has self-intersecting edges.'.format(self.full_id)
|
|
879
|
+
try: # see if it is self-intersecting because of a duplicate vertex
|
|
880
|
+
new_geo = self.geometry.remove_duplicate_vertices(tolerance)
|
|
881
|
+
if not new_geo.is_self_intersecting:
|
|
882
|
+
return [] if detailed else '' # valid with removed dup vertex
|
|
883
|
+
except AssertionError:
|
|
884
|
+
return [] if detailed else '' # degenerate geometry
|
|
885
|
+
full_msg = self._validation_message(
|
|
886
|
+
msg, raise_exception, detailed, '000102',
|
|
887
|
+
error_type='Self-Intersecting Geometry')
|
|
888
|
+
if detailed: # add the self-intersection points to helper_geometry
|
|
889
|
+
help_pts = [p.to_dict() for p in self.geometry.self_intersection_points]
|
|
890
|
+
full_msg[0]['helper_geometry'] = help_pts
|
|
891
|
+
return full_msg
|
|
892
|
+
return [] if detailed else ''
|
|
893
|
+
|
|
894
|
+
def check_degenerate(self, tolerance=0.01, raise_exception=True, detailed=False):
|
|
895
|
+
"""Check whether the Aperture is degenerate with effectively zero area.
|
|
896
|
+
|
|
897
|
+
Note that, while the Aperture may have an area larger than the tolerance,
|
|
898
|
+
removing colinear vertices within the tolerance would create a geometry
|
|
899
|
+
smaller than the tolerance.
|
|
900
|
+
|
|
901
|
+
Args:
|
|
902
|
+
tolerance: The minimum difference between the coordinate values of two
|
|
903
|
+
vertices at which they can be considered equivalent. Default: 0.01,
|
|
904
|
+
suitable for objects in meters.
|
|
905
|
+
raise_exception: If True, a ValueError will be raised if the object
|
|
906
|
+
intersects with itself. Default: True.
|
|
907
|
+
detailed: Boolean for whether the returned object is a detailed list of
|
|
908
|
+
dicts with error info or a string with a message. (Default: False).
|
|
909
|
+
|
|
910
|
+
Returns:
|
|
911
|
+
A string with the message or a list with a dictionary if detailed is True.
|
|
912
|
+
"""
|
|
913
|
+
msg = 'Aperture "{}" is degenerate and should be deleted.'.format(
|
|
914
|
+
self.full_id)
|
|
915
|
+
try: # see if it is self-intersecting because of a duplicate vertex
|
|
916
|
+
new_geo = self.geometry.remove_colinear_vertices(tolerance)
|
|
917
|
+
if new_geo.area > tolerance:
|
|
918
|
+
return [] if detailed else '' # valid
|
|
919
|
+
except AssertionError:
|
|
920
|
+
pass # degenerate subface; treat it as degenerate
|
|
921
|
+
full_msg = self._validation_message(
|
|
922
|
+
msg, raise_exception, detailed, '000103',
|
|
923
|
+
error_type='Zero-Area Geometry')
|
|
924
|
+
return full_msg
|
|
925
|
+
return [] if detailed else ''
|
|
926
|
+
|
|
927
|
+
def display_dict(self):
|
|
928
|
+
"""Get a list of DisplayFace3D dictionaries for visualizing the object."""
|
|
929
|
+
base = [self._display_face(self.geometry, self.type_color)]
|
|
930
|
+
for shd in self.shades:
|
|
931
|
+
base.extend(shd.display_dict())
|
|
932
|
+
return base
|
|
933
|
+
|
|
934
|
+
@property
|
|
935
|
+
def to(self):
|
|
936
|
+
"""Aperture writer object.
|
|
937
|
+
|
|
938
|
+
Use this method to access Writer class to write the aperture in other formats.
|
|
939
|
+
|
|
940
|
+
Usage:
|
|
941
|
+
|
|
942
|
+
.. code-block:: python
|
|
943
|
+
|
|
944
|
+
aperture.to.idf(aperture) -> idf string.
|
|
945
|
+
aperture.to.radiance(aperture) -> Radiance string.
|
|
946
|
+
"""
|
|
947
|
+
return writer
|
|
948
|
+
|
|
949
|
+
def to_dict(self, abridged=False, included_prop=None, include_plane=True):
|
|
950
|
+
"""Return Aperture as a dictionary.
|
|
951
|
+
|
|
952
|
+
Args:
|
|
953
|
+
abridged: Boolean to note whether the extension properties of the
|
|
954
|
+
object (ie. materials, constructions) should be included in detail
|
|
955
|
+
(False) or just referenced by identifier (True). (Default: False).
|
|
956
|
+
included_prop: List of properties to filter keys that must be included in
|
|
957
|
+
output dictionary. For example ['energy'] will include 'energy' key if
|
|
958
|
+
available in properties to_dict. By default all the keys will be
|
|
959
|
+
included. To exclude all the keys from extensions use an empty list.
|
|
960
|
+
include_plane: Boolean to note wether the plane of the Face3D should be
|
|
961
|
+
included in the output. This can preserve the orientation of the
|
|
962
|
+
X/Y axes of the plane but is not required and can be removed to
|
|
963
|
+
keep the dictionary smaller. (Default: True).
|
|
964
|
+
"""
|
|
965
|
+
base = {'type': 'Aperture'}
|
|
966
|
+
base['identifier'] = self.identifier
|
|
967
|
+
base['display_name'] = self.display_name
|
|
968
|
+
base['properties'] = self.properties.to_dict(abridged, included_prop)
|
|
969
|
+
enforce_upper_left = True if 'energy' in base['properties'] else False
|
|
970
|
+
base['geometry'] = self._geometry.to_dict(include_plane, enforce_upper_left)
|
|
971
|
+
base['is_operable'] = self.is_operable
|
|
972
|
+
if isinstance(self.boundary_condition, Outdoors) and \
|
|
973
|
+
'energy' in base['properties']:
|
|
974
|
+
base['boundary_condition'] = self.boundary_condition.to_dict(full=True)
|
|
975
|
+
else:
|
|
976
|
+
base['boundary_condition'] = self.boundary_condition.to_dict()
|
|
977
|
+
self._add_shades_to_dict(base, abridged, included_prop, include_plane)
|
|
978
|
+
if self.user_data is not None:
|
|
979
|
+
base['user_data'] = self.user_data
|
|
980
|
+
return base
|
|
981
|
+
|
|
982
|
+
def _reset_parent_geometry(self):
|
|
983
|
+
"""Reset parent punched_geometry in the case that the object is transformed."""
|
|
984
|
+
if self.has_parent:
|
|
985
|
+
self._parent._punched_geometry = None
|
|
986
|
+
|
|
987
|
+
def __copy__(self):
|
|
988
|
+
new_ap = Aperture(self.identifier, self.geometry, self.boundary_condition,
|
|
989
|
+
self.is_operable)
|
|
990
|
+
new_ap._display_name = self._display_name
|
|
991
|
+
new_ap._user_data = None if self.user_data is None else self.user_data.copy()
|
|
992
|
+
self._duplicate_child_shades(new_ap)
|
|
993
|
+
new_ap._properties._duplicate_extension_attr(self._properties)
|
|
994
|
+
return new_ap
|
|
995
|
+
|
|
996
|
+
def __repr__(self):
|
|
997
|
+
return 'Aperture: %s' % self.display_name
|