5
5
from ladybug_geometry .geometry3d import Point3D
6
6
from ladybug .datatype .generic import GenericType
7
7
from ladybug .color import Color
8
- from ladybug_display .geometry3d import DisplayLineSegment3D , DisplayFace3D , \
9
- DisplayMesh3D
8
+ from ladybug_display .geometry3d import DisplayPoint3D , DisplayLineSegment3D , \
9
+ DisplayFace3D , DisplayMesh3D
10
10
from ladybug_display .visualization import VisualizationSet , ContextGeometry , \
11
11
AnalysisGeometry , VisualizationData , VisualizationMetaData
12
12
from honeybee .boundarycondition import Outdoors , Ground , Surface
@@ -44,12 +44,13 @@ def model_to_vis_set(
44
44
hide_color_by = False , room_attr = None , face_attr = None ,
45
45
room_text_labels = False , face_text_labels = False ,
46
46
room_legend_par = None , face_legend_par = None ,
47
- grid_data_path = None , grid_display_mode = 'Surface' ):
47
+ grid_display_mode = 'Default' , hide_grid = True ,
48
+ grid_data_path = None , grid_data_display_mode = 'Surface' ):
48
49
"""Translate a Honeybee Model to a VisualizationSet.
49
50
50
51
Args:
51
52
model: A Honeybee Model object to be converted to a VisualizationSet.
52
- color_by: Text for the property that dictates the colors of the Model geometry.
53
+ color_by: Text that dictates the colors of the Model geometry.
53
54
If none, only a wireframe of the Model will be generated, assuming
54
55
include_wireframe is True. This is useful when the primary purpose of
55
56
the visualization is to display results in relation to the Model
@@ -103,6 +104,21 @@ def model_to_vis_set(
103
104
face_legend_par: An optional LegendParameter object to customize the display
104
105
of the face_attr. When face_text_labels is True, only the text_height
105
106
and font will be used to customize the text.
107
+ grid_display_mode: Text that dictates how the ContextGeometry for Model
108
+ SensorGrids should display in the resulting visualization. The Default
109
+ option will draw sensor points whenever there is no grid_data_path and
110
+ won't draw them at all when grid data is provided, assuming the
111
+ AnalysisGeometry of the grids is sufficient. Choose from the following:
112
+
113
+ * Default
114
+ * Points
115
+ * Wireframe
116
+ * Surface
117
+ * SurfaceWithEdges
118
+ * None
119
+
120
+ hide_grid: Boolean to note whether the SensorGrid ContextGeometry should be
121
+ hidden or shown by default. (Default: True).
106
122
grid_data_path: An optional path to a folder containing data that aligns
107
123
with the SensorGrids in the model. Any sub folder within this path
108
124
that contains a grids_into.json (and associated CSV files) will be
@@ -113,9 +129,9 @@ def model_to_vis_set(
113
129
grids_info.json exist in the root of this grid_data_path. Also
114
130
note that this argument has no impact if honeybee-radiance is not
115
131
installed and SensorGrids cannot be decoded. (Default: None).
116
- grid_display_mode : Optional text to set the display_mode of the AnalysisGeometry
117
- that is is generated from the grid_data_path above. Note that this
118
- has no effect if there are no meshes associated with the model
132
+ grid_data_display_mode : Optional text to set the display_mode of the
133
+ AnalysisGeometry that is is generated from the grid_data_path above. Note
134
+ that this has no effect if there are no meshes associated with the model
119
135
SensorGrids. (Default: Surface). Choose from the following:
120
136
121
137
* Surface
@@ -284,6 +300,40 @@ def model_to_vis_set(
284
300
geo_obj .add_data_set (ra_a_geo [0 ])
285
301
geo_objs .append (geo_obj )
286
302
303
+ # add the sensor grid geometry if requested
304
+ gdm = grid_display_mode .lower ()
305
+ default_exclude = gdm == 'default' and grid_data_path is not None and \
306
+ os .path .isdir (grid_data_path )
307
+ if gdm != 'none' and not default_exclude :
308
+ # get the sensor grids and evaluate whether they have meshes
309
+ try :
310
+ grid_objs = model .properties .radiance .sensor_grids
311
+ except AttributeError : # honeybee-radiance is not installed
312
+ grid_objs = []
313
+ if len (grid_objs ) != 0 :
314
+ grid_meshes = [g .mesh for g in grid_objs ]
315
+ g_meshes_avail = all (m is not None for m in grid_meshes )
316
+ # create the context geometry for the sensor grids
317
+ dis_geos = []
318
+ if gdm in ('default' , 'points' ) or not g_meshes_avail :
319
+ for grid in grid_objs :
320
+ for p in grid .positions :
321
+ dis_geos .append (DisplayPoint3D (Point3D (* p )))
322
+ elif gdm == 'wireframe' :
323
+ for mesh in grid_meshes :
324
+ dis_geos .append (DisplayMesh3D (mesh , display_mode = 'Wireframe' ))
325
+ elif gdm in ('surface' , 'surfacewithedges' ):
326
+ for mesh in grid_meshes :
327
+ grey = Color (100 , 100 , 100 )
328
+ d_mesh = DisplayMesh3D (
329
+ mesh , color = grey , display_mode = grid_display_mode )
330
+ dis_geos .append (d_mesh )
331
+ con_geo = ContextGeometry ('Sensor_Grids' , dis_geos )
332
+ if hide_grid :
333
+ con_geo .hidden = True
334
+ con_geo .display_name = 'Sensor Grids'
335
+ geo_objs .append (con_geo )
336
+
287
337
# add grid data if requested
288
338
if grid_data_path is not None and os .path .isdir (grid_data_path ):
289
339
# first try to get all of the Model sensor grids
@@ -334,7 +384,7 @@ def model_to_vis_set(
334
384
gr_pts = [Point3D (* pos ) for gr in grid_objs for pos in gr .positions ]
335
385
a_geo = AnalysisGeometry ('Grid_Data' , gr_pts , data_sets )
336
386
a_geo .display_name = 'Grid Data'
337
- a_geo .display_mode = grid_display_mode
387
+ a_geo .display_mode = grid_data_display_mode
338
388
geo_objs .append (a_geo )
339
389
340
390
# add the wireframe if requested
0 commit comments