Git Product home page Git Product logo

hbyter_notebook's Introduction

Some example / samples of working HB objects via HBJSON in Jupyter Notebook

Will hopefully grow into 'turn HB model into multiple pandas dataframes for tabular review and also some kinda eppy/opyplus esque functionality'... becuase why not..


Big shout to EM: I leaned how to do this from him sooo I take 0 cred


the jist:

import json
import honeybee.dictutil as hb_dict_util
import honeybee_energy.dictutil as energy_dict_util
import honeybee_radiance.dictutil as radiance_dict_util
from honeybee.face import Face
from honeybee.room import Room
from honeybee.aperture import Aperture
from honeybee_energy.material.opaque import EnergyMaterial, EnergyMaterialNoMass
from honeybee_energy.hvac import *

"""
Crediting EM
"""


def build_hb_objs(_path):
    """ A function to take in a hbjson and rebuild hb_objs
        into 'py hb_objs'.
    ----------------------------------------------------------
    Args:
        * _path: path to hbjson
    Returns:
        * hb_objs
    """
    with open(_path) as json_file:
        data = json.load(json_file)

    try:
        hb_objs = hb_dict_util.dict_to_object(
            data, False)  # re-serialize as a core object
        if hb_objs is None:
            # try to re-serialize it as an energy object
            hb_objs = energy_dict_util.dict_to_object(data, False)
            if hb_objs is None:
                # try to re-serialize it as a radiance object
                hb_objs = radiance_dict_util.dict_to_object(data, False)
    except ValueError:
        # no 'type' key; assume that its a group of objects
        hb_objs = []
        for hb_dict in data.values():
            hb_obj = hb_dict_util.dict_to_object(
                hb_dict, False)    # re-serialize as a core object
            if hb_obj is None:
                # try to re-serialize it as an energy object
                hb_obj = energy_dict_util.dict_to_object(hb_dict, False)
                if hb_obj is None:
                    # try to re-serialize it as a radiance object
                    hb_obj = radiance_dict_util.dict_to_object(hb_dict, False)
            hb_objs.append(hb_obj)
    return hb_objs

### This is where the fun begins:

my_ipynb_hb_obj = build_hb_objs('path//to//hbjson')

And now:

my_ipynb_hb_obj is the same as any hbobj in Grasshopper ghpy!

hbyter_notebook's People

Contributors

tfedud avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.