Skip to content

Commit

Permalink
fix(ladybug visualization set): add to_html method to LBVisualizationSet
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Dec 27, 2022
1 parent 879ed44 commit fe04e37
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ladybug_vtk/_extend_visualization_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This extension makes it easier for developers to get started with using this feature
for developing apps.
"""

from pathlib import Path
from ladybug_display.visualization import VisualizationSet as LBVisualizationSet
from .visualization_set import VisualizationSet as VTKVisualizationSet, DisplayPolyData
Expand Down Expand Up @@ -31,4 +32,30 @@ def vs_to_vtkjs(
return Path(path)


def vs_to_html(
self: LBVisualizationSet, output_folder: str,
file_name: str = 'visualization_set',
open: bool = False
):
"""
Export Visualization set to a HTML file.
Args:
output_folder: Path to the target folder to write the HTML file.
file_name: Output file name. Defaults to visualization_set.
open: A boolean to open the HTML file once created. Default is set to False.
Returns:
A pathlib Path object to the HTML file.
"""
data_sets = [
DisplayPolyData.from_visualization_geometry(geometry)
for geometry in self.geometry
]
vs = VTKVisualizationSet(datasets=data_sets)
path = vs.to_html(folder=output_folder, name=file_name, open=open)
return Path(path)


LBVisualizationSet.to_vtkjs = vs_to_vtkjs
LBVisualizationSet.to_html = vs_to_html

0 comments on commit fe04e37

Please sign in to comment.