LogoLogo
HomeWeb PlatformForum
  • User Manual
  • Get Started
    • Create a Pollination Account
    • Setting up an Organization
      • 1. Create an Organization
      • 2. Add Organization Seats
      • 3. Add Team Members
      • 4. Purchase and Manage CAD Licenses
      • 5. Manage License Pools
      • 6. Add Additional Computing Resources
    • Setting up Rhino, Grasshopper and Revit Plugins
      • Download CAD Plugins
      • Install CAD Plugins
      • Purchase and Manage CAD Plugins
      • The Difference between CAD Licenses and Organization Seats
  • REVIT PLUGIN
    • Getting Started in Revit
    • Exporting Energy Models from Revit
      • Understanding the Export Process
      • Managing Pollination Revit License
      • Setting Up Linked Models
      • Creating Snapshots
      • Editing and Exporting Snapshots
    • Modeling Best Practices
  • Model Editor
    • What is Pollination Model Editor
    • Getting Started
    • Workflows
    • Commands
      • By Use Case
        • Room Commands
          • Edit
          • Windows
          • New
          • Adjacency
          • Line
          • Visualize
        • Line Commands
        • Roof Commands
        • Model Commands
      • Alphabetically
        • 3D preview
        • Align
        • Auto align
        • Auto top ground
        • Change units
        • Convert to room2D
        • Create boundary
        • Create rooms
        • Explode polyline
        • Export roofs
        • Fill holes
        • Find adjacency gaps
        • Find roof gaps
        • Find roof intersection
        • Floor area change
        • Generate alignment axes
        • Import roofs
        • Join coplanar faces
        • Join segments
        • Merge Small Rooms
        • Merge rooms
        • Multipliers to geometry
        • Offset
        • Offset windows
        • Preview roofs
        • Pull to room
        • Remove colinear vertices
        • Remove holes
        • Remove short segments
        • Repair windows
        • Resolve roof overlaps
        • Roof to shade
        • Separate plenums
        • Set air boundaries
        • Show tilt
        • Simplify Curved Edges
        • Simplify windows
        • Snap to grid
        • Solve adjacency
        • Split
        • Split core and perimeter
        • Subtract roofs
        • Subtract rooms
        • Validate model
        • Vertically split
    • Supported File Formats
      • Export
      • Import
    • Python Script Editor
      • Your First Python Script
      • Editor Class API Documentation
      • Available Python Libraries
    • FAQ
    • Changelog
  • Rhino Plugin
    • Getting Started in Rhino
    • Modeling Best Practices
      • Create Rooms
      • Create Apertures
      • Create Doors
      • Solve Adjacency
      • Create Shade or Context
      • Editing your Model
      • Using Room Selection Mode
    • Energy Modeling
      • Assign Program Types
      • Assign Construction Sets
      • Assign HVAC Systems
      • Energy Settings and Parameters
      • Run Simulation and Load Results
    • Daylight Modeling
      • Assign Modifier Sets
      • Assign Modifiers
      • Add Sensor Grid
      • Add View
      • Run Simulation and Visualize Daylighting Results
    • Interoperability
      • Ladybug Tools Grasshopper Plugins
        • Entity components
      • Import
        • Import HBJSON
        • Import gbXML
        • Import OSM
        • Import IDF
      • Export
        • Export HBJSON
        • Export gbXML
        • Export OSM and IDF
    • Troubleshooting
      • Rhino Plugin Errors
      • Validation Error Codes
    • Pollination Commands
      • By Use Case
        • General
        • Geometry Setup
        • Model Alignment & Updates
        • Setup & Run Simulation
        • Load, Visualize, and Export Results
      • Alphabetically
        • PO_AddApertureShades
        • PO_AddApertures
        • PO_AddAperturesByWWR
        • PO_AddBuildingShades
        • PO_AddDoors
        • PO_AddOpaqueFaces
        • PO_AddRadialGrid
        • PO_AddRooms
        • PO_AddRoomsByLayer
        • PO_AddSensorGrid
        • PO_AddShades
        • PO_AddSiteContext
        • PO_AddSkylightsByRatio
        • PO_AddView
        • PO_Align2DPlans
        • PO_AlignInElevation
        • PO_AlignInPlan
        • PO_AlignInPlan2D
        • PO_Check2DOrtho
        • PO_CheckAdjacency
        • PO_CheckPlanarity
        • PO_CheckUpdates
        • PO_ColorByBoundaryCondition
        • PO_ColorByFaceNormal
        • PO_ColorByFaceType
        • PO_ConstructionSetManager
        • PO_ConstructionManager
        • PO_DownloadModel
        • PO_DrawApertures
        • PO_DrawDoors
        • PO_DrawPlanarSurface
        • PO_DrawRoom
        • PO_DupAperturesDoors
        • PO_EditApertureProperties
        • PO_EditDoorProperties
        • PO_EditFaceProperties
        • PO_EditInPlace
        • PO_EditProperties
        • PO_EditRoomProperties
        • PO_EditSensorGridProperties
        • PO_EditShadeProperties
        • PO_EditViewProperties
        • PO_EmbedUserLibrary
        • PO_Extrude2DPlans
        • PO_FixRoomChildrenLinks
        • PO_GenAlignGrids
        • PO_GenRoomPerimeters
        • PO_HVACManager
        • PO_IsolateAdjacencies
        • PO_LicenseManager
        • PO_LoadResults
        • PO_MaterialManager
        • PO_MatchChildGeometry
        • PO_MatchRoomProperties
        • PO_MergeRooms
        • PO_ModifierSetManager
        • PO_ModifierManager
        • PO_OffsetChildObjects
        • PO_PluginInfo
        • PO_Pollination
        • PO_ProgramTypeManager
        • PO_ProjectChildToHost
        • PO_ProjectSrf
        • PO_PurgeUserLibrary
        • PO_RebuildRooms
        • PO_RemoveProperties
        • PO_RemoveShortSegments
        • PO_RebuildAperturesDoors
        • PO_ResetBoundaryCondition
        • PO_ResetDisplayName
        • PO_ResetIdentifier
        • PO_ResetLegendLocation
        • PO_ResetResourceIDs
        • PO_RunSimulation
        • PO_SaveToUserLibrary
        • PO_SelApertures
        • PO_SelDoors
        • PO_SelOpaqueFaces
        • PO_SelRooms
        • PO_SelSensorGrids
        • PO_SelShades
        • PO_SelSiteContexts
        • PO_SelViews
        • PO_SetAirBoundariesByGuides
        • PO_SetRoomStoryByElevation
        • PO_ShowObjectNotes
        • PO_SHWManager
        • PO_ScheduleManager
        • PO_SimulationParameter
        • PO_SolveAdjacency
        • PO_SplitRooms
        • PO_SyncModel
        • PO_TestLocalAppEnvironment
        • PO_UnitsSetting
        • PO_UploadModel
        • PO_UserManual
        • PO_ValidateModel
  • Grasshopper Plugin
    • Download and Install the Grasshopper Plugin
    • Grasshopper User Interface
      • 1:Primitives
        • PO_Aperture
        • PO_Door
        • PO_Face
        • PO_Model
        • PO_Room
        • PO_SensorGrid
        • PO_Shade
        • PO_View
        • PO_VisualizationSet
        • PO_Construction
        • PO_ConstructionSet
        • PO_Material
        • PO_Modifier
        • PO_ModifierSet
        • PO_ProgramType
        • PO_Schedule
      • 2:Pollination
        • Check_Run_Inputs
        • Check_Run_Results
        • List_Run_Assets
        • Setup_Runs
        • User_Data
        • Pollinate
        • Check_Study_Status
        • List_Studies
        • Add_a_project
        • Get_a_project
        • List_Project_Assets
        • Load_Assets
        • Upload_Assets
        • Login
      • 3:Parametric
        • Fly
        • Fly_ID
      • 4:Serialization
        • PO_Dump_GEM
        • PO_Dump_IDM
        • PO_Dump_INP
        • PO_Dump_SDD
    • Your First Simulation
    • Create a Parametric Run
    • Visualize Results
  • Web Platform
    • Create a New Project
    • Manage Access to a Project
    • Create a New Study
    • Create Teams
  • Developers
    • Create an API Key
    • API
      • Add Members to an Organization
      • Create a New Project
      • Schedule a Study on Pollination
    • Apps
      • Create a Simple Chart
      • Create a Filtered Chart
      • Create a Study
      • Check Study Status
      • Download an Output
      • Visualize Results on the Web
      • Integrate the Pollination Viewer
      • Visualize Results in Rhino
      • Prepare an App folder
      • Deploy an App using the Command Line
      • Deploy an App using Github
      • Automate the App Deployment
      • Update an App
  • Legal
    • Terms of Service
    • Privacy Policy
    • Subprocessors
    • Data Processing Addendum
    • Service Level Agreement
Powered by GitBook
On this page
  • Data needed for this visualization
  • App
  • Testing the App inside Rhino
  • Running the App
  • Running the App inside Rhino
  • Visualization in Rhino

Was this helpful?

  1. Developers
  2. Apps

Visualize Results in Rhino

PreviousIntegrate the Pollination ViewerNextPrepare an App folder

Last updated 3 months ago

Was this helpful?

In section, we downloaded the "visualization" output of a daylight-factor study in the web app. Now, we will see how we can download the "result" output and visualize it in Rhino.

Data needed for this visualization

Using the steps mentioned , download the "results" output of the daylight-factor study instead of the "visualization" output.

This should give you a results folder with the following structure:

results
│   grids_info.json
│
├───room_1
│       TestRoom_1.res
│
└───room_2
        TestRoom_2.res

App

Installing necessary libraries

pip install pollination-streamlit-io lbt-honeybee

importing libraries

import json
import streamlit as st
from typing import List
from pathlib import Path
from honeybee.model import Model as HBModel
from pollination_streamlit_io import button, inputs, special

Helper function to send a Honeybee model to Rhino

def rhino_hbjson(hb_model: HBModel, label: str = 'Preview model',
                 key: str = 'model') -> None:
    """Visualize and bake HBJSON in rhino.

    args:
        hb_model: A honeybee model.
        label: Label of the button. Defaults to 'Preview model'.
        key: Key of the button. Defaults to 'model'.
    """

    if not st.session_state.host == 'rhino':
        return

    col1, col2 = st.columns(2)

    with col1:
        inputs.send(
            data=hb_model.to_dict(),
            unique_id='preview-model',
            default_checked=True,
            is_pollination_model=True,
            label=label,
            key=key,
        )

    with col2:
        button.send(
            action='BakePollinationModel',
            data=hb_model.to_dict(),
            unique_id='bake-model',
            options={
                "layer": "hbjson",
                "units": "Meters"
            },
            key=f'bake-{key}',
        )

Helper function to send results as a colored mesh in Rhino

def rhino_mesh(hb_model: HBModel, results_folder: Path, result_name: str) -> None:
    """Visualize and bake the mesh in Rhino

    Args:
        hb_model: A honeybee model.
        results_folder: Path to the folder where the results are stored.
        result_name: The name of the result to be loaded as mesh.
    """

    if not st.session_state.host == 'rhino':
        return

    grids_info_file = results_folder.joinpath('grids_info.json')
    info = json.loads(grids_info_file.read_text())
    model = hb_model.to_dict()

    grids = model['properties']['radiance']['sensor_grids']

    geometries = []
    merged_values = []
    for i, grid_info in enumerate(info):
        result_file = results_folder.joinpath(f"{grid_info['full_id']}.res")
        values = [float(v) for v in result_file.read_text().splitlines()]
        mesh = json.dumps(grids[i]['mesh'])
        merged_values += values
        geometries.append(json.loads(mesh))

    result_json = {
        "type": "AnalyticalMesh",
        "mesh": geometries,
        "values": merged_values
    }

    col1, col2 = st.columns(2)

    with col1:
        inputs.send(
            data=result_json,
            unique_id='preview-mesh',
            default_checked=True,
            label=result_name,
            delay=1000,
            key=result_name
        )

    with col2:
        button.send(
            action='BakeGeometry',
            data=result_json,
            unique_id=f'bake_{result_name}',
            key=result_name)

Helper function to send a Honeybee model and the results as a colored mesh in Rhino

def visualize_model_with_mesh(hbjson_path: Path,
                              result_folders: List[Path] = None,
                              result_names: List[str] = None,
                              show_rhino_mesh: bool = False):
    """Visualize the Honeybee model in Rhino with colored mesh.

    The result_folders and result_names accept a list of values. This is for the
    reason that you can mount multiple results on the same model. An example would
    be to mount the results of DA, sDA, and UDI on the same model.

    args:
        hbjson_path: Path to the HBJSON file.
        result_folders: List of paths to the folder where the result files are written.
            This is only used in creating colored mesh in Rhino.
        result_names: List of names of the result files. This is only used in creating
            colored mesh in Rhino. Defaults to None which means the names will be
            assigned based on the order of the result files.
        show_rhino_mesh: Boolean to show the mesh in Rhino or not. Defaults to False.
    """

    hb_model = HBModel.from_hbjson(hbjson_path.as_posix())
    rhino_hbjson(hb_model)

    if show_rhino_mesh:
        if not result_names:
            result_names = [f'result_{i}' for i in range(len(result_folders))]
        for count, result_folder in enumerate(result_folders):
            rhino_mesh(hb_model, result_folder, result_names[count])
st.session_state.host = special.get_host()

Finally, visualizing the model and the results as a mesh in Rhino

with st.form('visualize-rhino'):
    hbjson_path = Path(st.text_input('Path to HBJSON file'))
    results_path = Path(st.text_input('Path to results folder'))

    submit_button = st.form_submit_button(
        label='Submit')

    if submit_button:
        visualize_model_with_mesh(hbjson_path, [results_path], [
                                  'daylight-factor'], show_rhino_mesh=True)

Testing the App inside Rhino

First, run the pollination app. Here, were assuming that the name of the python file for the app is "app" and the file is in the current working directory.

Running the App

streamlit run app.py

This should run the app at the following location in your browser:

http://localhost:8501/

Running the App inside Rhino

Select the "Pollination" and "Pollination.Apps" on the menu that opens up

Next, click on the gear icon in Pollination.Apps. This will open up a new window.

In the panel, add the URL where the app is running and click on "Navigate to selection".

This should show the app inside Rhino.

Enter, the following values assuming the HBJSON file and the results are present in the current working directory. If not, provide full path to both.

Visualization in Rhino

Clicking the 'Submit" button should show the model and the mesh in Rhino that you can tun on and off and also bake as Rhino objects.

We will also need the original HBJSON file used for the daylight-factor study in step.

Getting the host and saving in . Here, the host is Rhino. We need this to make the Streamlit app aware of the context. In this case, the Rhino environment.

If you don't have already, download the Pollination Rhino plugin from . Once you install the Rhino plugin, you should see the tabs for "Pollination" and "Pollination.Apps" in the sidebar of Rhino. If you don't, click on the gear icon shown in the image below;

this
session state
here
this
here