Exporting .hbjson for pollination using honeybee libs in python

Hey Pollination! I have been messing around with the pollination rest-api and have been getting quite abit confused.

My goal:
Be able to define say 100 honeybee models → create .hbjson files from them → use rest-api to load those artifacts and run on pollination

Current Status
I have managed to go through the guides listed here:

I have managed to run the two sample models in the repo on pollination and was able to see the models on the web-app which is super cool

So my natural next step was to see if instead of using the given .hbjson files in the guide files, i wanted to create my own .hbjson files from a parametric model…directly in vscode. This then led me down the rabit hole to this repo with the sample code here:
Here I managed to run my simulation in a venv and print the Lux results to cmd for each analysis points.

How would I even start using this workflow to output .hbjson files for this to be able to run on pollination instead of locally in a venv

Maybe I am not even thinking about this correctly and there is a more logical way to do this but im stuck here.

Any guidance would be very appreciated

Hi @karimdaw - great to see you here! :wave:

Here is an app that creates a room, adds apertures to it, and runs a daylight factor simulation:

You can play with the live version here.

:memo: The app might timeout before the simulation is finished! This is because of how we are deploying the apps at this point. They are not production-ready but it should help you get a better idea of the overall workflow.

An here is a sample code for creating the room and saving it as an HBJSON file as you asked for!

This script shows how to:

    1. create a room from a box
    2. add a single aperture to the south wall
    3. add the room to a model
    4. create a sensor grid and add it to the room
    5. save the room as an HBJSON file


from honeybee.room import Room, Vector3D
from honeybee.model import Model

from honeybee_radiance.sensorgrid import SensorGrid

width = 4
height = 3.6
depth = 6

wwr = 0.6

grid_size = 0.5  # every half a meter
grid_offset = 0.8  # 80 cms from the floor

# initiate a room
room = Room.from_box(identifier='single_room', width=width, depth=depth, height=height)

# get south facing wall using wall face normal angle.
south_vector = Vector3D(0, -1, 0)
south_face = [face for face in room.faces if south_vector.angle(face.normal) <= 0.01][0]
# create an aperture by ratio
# alternatively one can use other methods like `aperture_by_width_height`
# see here for docs: https://www.ladybug.tools/honeybee-core/docs/honeybee.face.html#honeybee.face.Face.aperture_by_width_height

# create a model and add the room to it
model = Model('sample-model', rooms=[room], units='Meters')

# create a sensor grid - this is only required if you want to run grid-based studies
# use generate_grid method to create a sensor grid from room floor
grid_mesh = room.generate_grid(x_dim=grid_size, y_dim=grid_size, offset=grid_offset)
# create a sensor grid using the generated mesh
sensor_grid = SensorGrid.from_mesh3d(identifier='room', mesh=grid_mesh)


model.to_hbjson(name=model.identifier, folder='.')

Here is the HBJSON file that is generated from this script: sample-model.hbjson (13.9 KB) - You can see it live here: Pollination Cloud App - Finally, here is the code in a python file: create_a_room.py (1.6 KB)


Let me know if you have any follow-up questions.

1 Like

Also, I just realized that you are using the older version of honeybee (AKA Honeybee[+]). The most updated libraries are listed here:

For running the above script you should install honeybee-radiance which you can do by running this command:

python -m pip install honeybee-radiance -U

Another good source for getting yourself up to speed with using the LBT SDK is checking the code inside the Grasshopper component. This is the same as the Python code but inside Grasshopper and you can see I basically used the same line of the code in my script.

1 Like

Hey @mostapha, thanks :slight_smile: finally made it!

This is a great start and answers my questions perfectly, thank you. I managed to use your .py file, and it created the .hbjson as expected, now it’s time for the fun stuff! I’ll let you know on my progress and if I have any further questions. Also, great tip with peaking into the gh components source code.