OpenStudio Measures - download directly from BCL?

Hi everyone,

Is there a way to load an OpenStudio measure directly from the Building Component Library (or somewhere else online) to avoid having to load it from a local file?


We do not support this right now and we probably don’t want to add one since it can be against the licensing and copyright (the pop-up window to agree with terms, …). But you can write your own component to do so. Something like this should work:

Use a GHPython component with a single input and change the input name to url and set the type to string. Rename output to measure_file.

This code download the files to c:\ladybug\measures you can change that to your custom folder.

import System
import zipfile
import shutil
import os
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12

def unzip_file(zip_file, target_folder):
    with zipfile.ZipFile(zip_file) as zf:
        for f in zf.namelist():
            if f.endswith('/'):
                zf.extract(f, target_folder)

    return f.split('/')[0].split('\\')[0]

def main(url, target_folder):
    path, name = os.path.split(url)
    name = name.split('?')[0]
    temp_folder = os.path.join(target_folder, 'temp')
    if not os.path.isdir(temp_folder):
    zip_file = os.path.join(temp_folder, '' % name)
    if not os.path.isfile(zip_file):
        # download file
        client = System.Net.WebClient()
        client.DownloadFile(url, zip_file)
    # unzip file
    measure_folder = unzip_file(zip_file, target_folder)
    # return path to measure
    return '"%s"' % os.path.join(target_folder, measure_folder, 'measure.rb')

target_folder = r'c:\ladybug\measures'
measure_file = main(url, target_folder)