Using `legend_parameters` doesn't change the colors for `FaceAttribute` and `RoomAttribute`

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:

A post was merged into an existing topic: HTML model export of HBJSON and/or Visualization Set files

Hello @mostapha,

While doing some tests with honeybee_display and ladybug_display I noticed that legend_parameters for FaceAttribute, RoomAttribute and data of grid_data_path with VisualizationSet do not change colors and value limits.

Do you have an example of how to change these parameters in your code above?

Thank you!

Hi @rkleitzke, I will be happy to help. Can you provide a minimal example that showcases the issue? I don’t remember all the implementation details right now but I can start from an example that doesn’t work, and try to make it work! :slight_smile: Thanks.

from honeybee.model import Model, Aperture
from honeybee.boundarycondition import Outdoors
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
from ladybug.legend import LegendParameters
from ladybug.color import Colorset

fp = r"classroom_tagged_aperture.hbjson"

cs = Colorset()
color_1 = cs[12] 
color_2 = cs[13]
legend_params_1 = LegendParameters(title='Test 1', colors=color_1)
legend_params_2 = LegendParameters(title='Test 2', colors=color_2)

# Define the FaceAttributes with legend parameters
fa_1 = FaceAttribute(
    name='Aperture Tags',
    attrs=['user_data.tag'], color=True,
    face_types=[Aperture], boundary_conditions=[Outdoors],
    legend_par=legend_params_1
)

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

# Load the model
model = Model.from_hbjson(fp)

# Create the visualization set with the face attributes
print('creating the visualization set')
vs: VisualizationSet = model_to_vis_set(
    model=model, include_wireframe=True,
    face_attrs=[fa_1, fa_2],
    grid_data_path=
)

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

Thanks for the quick response, @mostapha !

I can’t upload files because I’m new here, but in summary, when I try to set a colorset(), for example, to change the colors in LegendParameters. The title (Test 1 or Test 2) works, but the colors do not.

In the same way, if I set some path to grid_data_path in model_to_vis_set(), how can I configure the LegendParameters of grids?

Thank you again!

1 Like

Thank you! Give me a couple of days and I’ll have a closer look. From what I see it should have worked. It is probably a bug.

Hi @rkleitzke, I had a closer look and this is most likely a bug in the viewer.

The colors are translated to the visualization set successfully.

They are also included in the VTKJS file that is being rendered in the HTML file.

But for some reason the viewer ignores them. We will need @antonellodinunzio’s help to fix this. He is on vacation this week and next but I assign this conversation to him so he can have a look once he is back.

Antonello, here is the vtkjs file for your reference.

custom_sample_model.vtkjs (34.4 KB)

Sorry that it is taking longer than usual to address this, @rkleitzke but you should continue with the rest of your work knowing that the colors will show up as expected once this issue is addressed.

1 Like

My understanding is that this is an issue with the viewer ignoring the metadata.legened_parameters field. It might still be reading the legends field which is deprecated.

Thank you, @Mostapha!

I’m getting on with my implementation, so if you (or @antonellodinunzio) have any news on this, please let me know.

1 Like

Hi @rkleitzke,

The issue should be fixed. Try [path-to-python] -m pip install -U honeybee-display[full]. This should install honeybee-display v0.4.0 and ladybug-vtk v0.14.4 which includes the fix. :point_down:

Let us know if you have any other questions.

1 Like

@mostapha, thank you very much, it is working just fine!

Just a suggestion for a future version: an option to set Legend Parameters Categorized for FaceAttribute and RoomAttribute.

Also, when I create a VisualizationSet with model_to_vis_set, can I set a list of paths to grid_data_path? And has any way to change the legend_par of them?

Hi @rkleitzke,

You can add a path in which there are subfolders. Each subfolder will be added as its own dataset with its own legend. You can see here that it will check if there is a JSON file with visualization metadata in the subfolders (must be named vis_metadata.json). This file will control the legend parameters but also the name of the data type which will be visible in the visualization, e.g., instead of the subfolder name “da” we will change the name to “Daylight Autonomy” in the metadata file.

I have attached an example showing the folder with subfolders. The metadata in the vis_metadata.json files in this example are generated with this function, and here they are written to separate files for each subfolder, but you can of course use an alternative workflow as long as the metadata files are in the subfolders before you run model_to_vis_data().

grid_data_path.zip (17.4 KB)

2 Likes

Hi @mikkel,

Thanks, I’m changing the model_to_visualization_set() to model_to_visualization_data() and it makes a lot of sense, especially when multiple meta-data need to be read.

In your example, I see alternatives to reading annual daylight outputs, but can I do the same with point-in-time outputs?

Hi @rkleitzke,

Don’t change the function name – that was just me making a mistake.

You can add any results that are represented as one value per sensor. Btw, here is the visualization metadata that we use for point-in-time daylight.

2 Likes