Skip to content

Commit df02634

Browse files
chriswmackeyChris Mackey
authored andcommitted
fix(cli): Add option to set active data
1 parent a7bfe53 commit df02634

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

honeybee_display/cli/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def display():
101101
'that this has no effect if there are no meshes associated with the model '
102102
'SensorGrids. Choose from: Surface, SurfaceWithEdges, Wireframe, Points',
103103
type=str, default='Surface', show_default=True)
104+
@click.option(
105+
'--active-grid-data', '-ad', help='Text to specify the active data in the '
106+
'AnalysisGeometry. This should match the name of the sub-folder '
107+
'within the grid_data_path that should be active. If unspecified, the '
108+
'first data set in the grid-data with be active.',
109+
type=str, default=None, show_default=True)
104110
@click.option(
105111
'--output-format', '-of', help='Text for the output format of the resulting '
106112
'VisualizationSet File (.vsf). Choose from: vsf, json, pkl, vtkjs, html. Note '
@@ -118,7 +124,7 @@ def display():
118124
def model_to_vis_set(
119125
model_file, color_by, wireframe, mesh, show_color_by,
120126
room_attr, face_attr, color_attr, grid_display_mode, hide_grid,
121-
grid_data, grid_data_display_mode, output_format, output_file):
127+
grid_data, grid_data_display_mode, active_grid_data, output_format, output_file):
122128
"""Translate a Honeybee Model file (.hbjson) to a VisualizationSet file (.vsf).
123129
124130
This command can also optionally translate the Honeybee Model to a .vtkjs file,
@@ -139,7 +145,8 @@ def model_to_vis_set(
139145
hide_color_by=hide_color_by, room_attr=room_attr, face_attr=face_attr,
140146
room_text_labels=text_labels, face_text_labels=text_labels,
141147
grid_display_mode=grid_display_mode, hide_grid=hide_grid,
142-
grid_data_path=grid_data, grid_data_display_mode=grid_data_display_mode)
148+
grid_data_path=grid_data, grid_data_display_mode=grid_data_display_mode,
149+
active_grid_data=active_grid_data)
143150
output_format = output_format.lower()
144151
if output_format in ('vsf', 'json'):
145152
output_file.write(json.dumps(vis_set.to_dict()))

honeybee_display/model.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def model_to_vis_set(
4545
room_text_labels=False, face_text_labels=False,
4646
room_legend_par=None, face_legend_par=None,
4747
grid_display_mode='Default', hide_grid=True,
48-
grid_data_path=None, grid_data_display_mode='Surface'):
48+
grid_data_path=None, grid_data_display_mode='Surface', active_grid_data=None):
4949
"""Translate a Honeybee Model to a VisualizationSet.
5050
5151
Args:
@@ -137,6 +137,11 @@ def model_to_vis_set(
137137
* Wireframe
138138
* Points
139139
140+
active_grid_data: Optional text to specify the active data in the
141+
AnalysisGeometry. This should match the name of the sub-folder
142+
within the grid_data_path that should be active. If None, the
143+
first data set in the grid_data_path with be active. (Default: None).
144+
140145
Returns:
141146
A VisualizationSet object that represents the model.
142147
"""
@@ -347,7 +352,7 @@ def model_to_vis_set(
347352
grids = {}
348353
if len(grids) != 0:
349354
# gather all of the directories with results
350-
gi_dirs, gi_file = [], 'grids_info.json'
355+
gi_dirs, gi_file, act_data, cur_data = [], 'grids_info.json', 0, 0
351356
root_gi_file = os.path.join(grid_data_path, gi_file)
352357
if os.path.isfile(root_gi_file):
353358
gi_dirs.append(grid_data_path)
@@ -357,6 +362,10 @@ def model_to_vis_set(
357362
sub_gi_file = os.path.join(sub_dir, gi_file)
358363
if os.path.isfile(sub_gi_file):
359364
gi_dirs.append(sub_dir)
365+
if active_grid_data is not None and \
366+
sub_f.lower() == active_grid_data.lower():
367+
act_data = cur_data
368+
cur_data += 1
360369
# loop through the result directories and load the results
361370
data_sets = []
362371
for g_dir in gi_dirs:
@@ -388,6 +397,7 @@ def model_to_vis_set(
388397
a_geo = AnalysisGeometry('Grid_Data', gr_pts, data_sets)
389398
a_geo.display_name = 'Grid Data'
390399
a_geo.display_mode = grid_data_display_mode
400+
a_geo.active_data = act_data
391401
geo_objs.append(a_geo)
392402

393403
# add the wireframe if requested

0 commit comments

Comments
 (0)