Skip to content

Commit 9ab722d

Browse files
chriswmackeyChris Mackey
authored andcommitted
fix(cli): Add option to export to HTML
1 parent 64fae2f commit 9ab722d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

extras-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
honeybee-energy>=1.95.19
22
honeybee-radiance>=1.64.105
3-
ladybug-vtk>=0.11.1
3+
ladybug-vtk>=0.13.5

honeybee_display/cli/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ def display():
103103
type=str, default='Surface', show_default=True)
104104
@click.option(
105105
'--output-format', '-of', help='Text for the output format of the resulting '
106-
'VisualizationSet File (.vsf). Choose from: vsf, pkl, vtkjs. Note that vsf .'
107-
'refers to the JSON version of the VisualizationSet file. Also not that '
108-
'ladybug-vtk must be installed in order for the vtkjs option to be usable. '
109-
'The vtkjs option also requires an explicit --output-file to be specified.',
106+
'VisualizationSet File (.vsf). Choose from: vsf, json, pkl, vtkjs, html. Note '
107+
'that both vsf and json refer to the the JSON version of the VisualizationSet '
108+
'file and the distinction between the two is only for help in coordinating file '
109+
'extensions (since both .vsf and .json can be acceptable). Also note that '
110+
'ladybug-vtk must be installed in order for the vtkjs or html options to be usable '
111+
'and the html format refers to a web page with the vtkjs file embedded within it. '
112+
'The vtkjs and html options also require an explicit --output-file to be specified.',
110113
type=str, default='vsf', show_default=True)
111114
@click.option(
112115
'--output-file', help='Optional file to output the JSON string of '
@@ -146,14 +149,19 @@ def model_to_vis_set(
146149
vis_set.to_pkl(out_file, out_folder)
147150
else:
148151
output_file.write(pickle.dumps(vis_set.to_dict()))
149-
elif output_format == 'vtkjs':
152+
elif output_format in ('vtkjs', 'html'):
150153
assert output_file.name != '<stdout>', \
151154
'Must specify an --output-file to use --output-format vtkjs.'
152155
out_folder, out_file = os.path.split(output_file.name)
153156
try:
154157
if out_file.endswith('.vtkjs'):
155158
out_file = out_file[:-6]
156-
vis_set.to_vtkjs(output_folder=out_folder, file_name=out_file)
159+
elif out_file.endswith('.html'):
160+
out_file = out_file[:-5]
161+
if output_format == 'vtkjs':
162+
vis_set.to_vtkjs(output_folder=out_folder, file_name=out_file)
163+
if output_format == 'html':
164+
vis_set.to_html(output_folder=out_folder, file_name=out_file)
157165
except AttributeError as ae:
158166
raise AttributeError(
159167
'Ladybug-vtk must be installed in order to use --output-format '

0 commit comments

Comments
 (0)