HTML model export of HBJSON and/or Visualization Set files

Hi community,

I was exploring the Model Viewer capabilities and was interested in learning more about the potential workflows of this feature. thus I have the following questions:

  1. I was wondering if there’s a direct, and local :grimacing:, way to export a HBJSON models (or Visualization Set objects generally) into HTML similar to the already implemented functionality in Pollination Outputs option highlighted here:

  2. Within the generated HTML viewer file, if one needs to add more features: for instance a user ability to interact and/or investigate parts of visualized result meshes, have custom data callouts (EUIs or face energy for example) while hovering over HB model rooms/elements, or just maybe flip the false-colours that are provided; what would be the appropriate approach to such customization? or where one can start looking at if there is a documentation available?

Thanks a lot! :grinning:

Hi @irihan, apologies for the late response. I assigned it to myself but then I forgot about answering it.

Yes. It is a bit different for HBJSON files because you have to translate them to a visualization-set first, and then translate them to a VTK/HTML visualization.

Make sure that you have honeybee-display[full] installed on your machine.

pip install honeybee-display[full]

from honeybee.model import Model
from honeybee_display.model import model_to_vis_set
from ladybug_display.visualization import VisualizationSet
from ladybug_vtk.visualization_set import VisualizationSet as VTKVS

fp = r"classroom_tagged_aperture.hbjson"
model = Model.from_hbjson(fp)

print('creating the visualization set')
vs: VisualizationSet = model_to_vis_set(model=model, include_wireframe=False)

print('creating the HTML file')
vvs = VTKVS.from_visualization_set(vs)
vvs.to_html(name='sample_model')

This is currently not easy to do. The viewer is hackable but we don’t have the bandwidth to support feature requests or customization. For some of the items that you mentioned above, it is easier to create the visualization set to have the data that you are looking for.

Here is an example of creating some face attribute objects and using them to color the faces or add the name to the face in the visualization.


from honeybee.model import Model, Aperture
from honeybee.boundarycondition import Outdoors, Surface
from honeybee_display.attr import FaceAttribute
from honeybee_display.model import model_to_vis_set
from ladybug_display.visualization import VisualizationSet
from ladybug_vtk.visualization_set import VisualizationSet as VTKVS

fp = r"classroom_tagged_aperture.hbjson"

fa_1 = FaceAttribute(
    name='Aperture Tags',
    attrs=['user_data.tag'], color=True,
    face_types=[Aperture], boundary_conditions=[Outdoors]
)

fa_2 = FaceAttribute(
    name='Aperture Layers',
    attrs=['user_data.__layer__'], color=False, text=True,
    face_types=[Aperture], boundary_conditions=[Outdoors]
)

model = Model.from_hbjson(fp)
print('creating the visualization set')
vs: VisualizationSet = model_to_vis_set(
    model=model, include_wireframe=True,
    face_attrs=[fa_1, fa_2]
)

print('creating HTML file')
vvs = VTKVS.from_visualization_set(vs)
vvs.to_html(name='custom_sample_model')

We have some functionalities for changing the colors in the UI but are limited to the pre-existing colorsets.

Here are the input file and the output files.

classroom_tagged_aperture.hbjson (60.1 KB)

html-files.zip (1.6 MB)

1 Like