Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

I agree with @macumber, this seems like a path issue.

There are a few things you can do to try and get the bindings working.

First, I use PyCharm when working with Python in general and the OpenStudio bindings. It provides code completion and insights, even for the OpenStudio bindings, among other many other benefits. There is a free community version.

Next, I create an 'openstudio' package, basically a folder with an __init__.py file. This allows you to import openstudio and use it like m = openstudio.model.Model(). Within this package, I put all the .py and .pyd files from the /python and /python/Release folders.

Now a major caveat to this is that the .pyd files contain a dependency reference to the associated .dll (located in Products/Release/). This means that any time you recompile OpenStudio then you will need to put the new .pyd and .py files in your 'openstudio' package otherwise you will probably get errors in your python bindings.

One way around this issue is to create a package of OpenStudio using the BUILD_PACKAGE option in CMake. This will then create a 'python/openstudio' folder with all the .py, .pyd, and .dll files in it with the correct dependency references.

So the 'openstudio' package has the following (rough) contents..

  • openstudio
    • __ init __.py
    • openstudiomodel.py
    • etc...
    • _openstudiomodel.pyd
    • etc...
    • openstudio_model.dll (if using BUILD_PACKAGE)
    • etc...

The __ init __.py file looks like ...

import openstudiomodel as model
import openstudioenergyplus as energyplus
from openstudioutilitiescore import *
etc...

Then use it like the following import design day file example...

from openstudio import model, Workspace, path, energyplus
m = model.Model()
ddy_path = "/Applications/EnergyPlus-8-0-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.ddy"
os_ddy_path = path(ddy_path)
ddy_idf = IdfFile.load(os_ddy_path)
ddy_workspace = Workspace(ddy_idf.get())
reverse_translator = energyplus.ReverseTranslator()
ddy_model = reverse_translator.translateWorkspace(ddy_workspace)
ddy_objects = [ddy_object for ddy_object in model.getDesignDays(ddy_model) if (".4%" in ddy_object.name().get() or "99.6" in ddy_object.name().get())]
m.addObjects(ddy_objects)

Hopefully this helps (and makes sense). Also, these code snippets work for python 2.7 and probably should work in python 3 but that is untested.

I agree with @macumber, this seems like a path issue.

There are a few things you can do to try and get the bindings working.

First, I use PyCharm when working with Python in general and the OpenStudio bindings. It provides code completion and insights, even for the OpenStudio bindings, among other many other benefits. There is a free community version.

Next, I create an 'openstudio' package, basically a folder with an __init__.py file. This allows you to import openstudio and use it like m = openstudio.model.Model(). Within this package, I put all the .py and .pyd files from the /python and /python/Release folders.

Now a major caveat to this is that the .pyd files contain a dependency reference to the associated .dll (located in Products/Release/). This means that any time you recompile OpenStudio then you will need to put the new .pyd and .py files in your 'openstudio' package otherwise you will probably get errors in your python bindings.

One way around this issue is to create a package of OpenStudio using the BUILD_PACKAGE option in CMake. This will then create a 'python/openstudio' folder with all the .py, .pyd, and .dll files in it with the correct dependency references.

So the 'openstudio' package has the following (rough) contents..

  • openstudio
    • __ init __.py__ .py
    • openstudiomodel.py
    • etc...
    • _openstudiomodel.pyd_ openstudiomodel.pyd
    • etc...
    • openstudio_model.dll (if using BUILD_PACKAGE)
    • etc...

The __ init __.py file looks like ...

import openstudiomodel as model
import openstudioenergyplus as energyplus
from openstudioutilitiescore import *
etc...

Then use it like the following import design day file example...

from openstudio import model, Workspace, path, energyplus
m = model.Model()
ddy_path = "/Applications/EnergyPlus-8-0-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.ddy"
os_ddy_path = path(ddy_path)
ddy_idf = IdfFile.load(os_ddy_path)
ddy_workspace = Workspace(ddy_idf.get())
reverse_translator = energyplus.ReverseTranslator()
ddy_model = reverse_translator.translateWorkspace(ddy_workspace)
ddy_objects = [ddy_object for ddy_object in model.getDesignDays(ddy_model) if (".4%" in ddy_object.name().get() or "99.6" in ddy_object.name().get())]
m.addObjects(ddy_objects)

Hopefully this helps (and makes sense). Also, these code snippets work for python 2.7 and probably should work in python 3 but that is untested.

I agree with @macumber, this seems like a path issue.

There are a few things you can do to try and get the bindings working.

First, I use PyCharm when working with Python in general and the OpenStudio bindings. It provides code completion and insights, even for the OpenStudio bindings, among other many other benefits. There is a free community version.

Next, I create an 'openstudio' package, basically a folder with an __init__.py file. This allows you to import openstudio and use it like m = openstudio.model.Model(). Within this package, I put all the .py and .pyd files from the /python and /python/Release folders.

Now a major caveat to this is that the .pyd files contain a dependency reference to the associated .dll (located in Products/Release/). This means that any time you recompile OpenStudio then you will need to put the new .pyd and .py files in your 'openstudio' package otherwise you will probably get errors in your python bindings.

One way around this issue is to create a package of OpenStudio using the BUILD_PACKAGE option in CMake. This will then create a 'python/openstudio' folder with all the .py, .pyd, and .dll files in it with the correct dependency references.

So the 'openstudio' package has the following (rough) contents..

  • -- openstudio
    
    • __ init __ .py
    • openstudiomodel.py
    • etc...
    • _ openstudiomodel.pyd
    • etc...
    • - __init__.py - openstudiomodel.py - etc... - _openstudiomodel.pyd - etc... - openstudio_model.dll (if using BUILD_PACKAGE)
    • etc...
BUILD_PACKAGE) - etc...

The __ init __.py file looks like ...

import openstudiomodel as model
import openstudioenergyplus as energyplus
from openstudioutilitiescore import *
etc...

Then use it like the following import design day file example...

from openstudio import model, Workspace, path, energyplus
m = model.Model()
ddy_path = "/Applications/EnergyPlus-8-0-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.ddy"
os_ddy_path = path(ddy_path)
ddy_idf = IdfFile.load(os_ddy_path)
ddy_workspace = Workspace(ddy_idf.get())
reverse_translator = energyplus.ReverseTranslator()
ddy_model = reverse_translator.translateWorkspace(ddy_workspace)
ddy_objects = [ddy_object for ddy_object in model.getDesignDays(ddy_model) if (".4%" in ddy_object.name().get() or "99.6" in ddy_object.name().get())]
m.addObjects(ddy_objects)

Hopefully this helps (and makes sense). Also, these code snippets work for python 2.7 and probably should work in python 3 but that is untested.

I agree with @macumber, this seems like a path issue.

There are a few things you can do to try and get the bindings working.

First, I use PyCharm when working with Python in general and the OpenStudio bindings. It provides code completion and insights, even for the OpenStudio bindings, among other many other benefits. There is a free community version.

Next, I create an 'openstudio' package, basically a folder with an __init__.py file. This allows you to import openstudio and use it like m = openstudio.model.Model(). Within this package, I put all the .py and .pyd files from the /python and /python/Release folders.

Now a major caveat to this is that the .pyd files contain a dependency reference to the associated .dll (located in Products/Release/). This means that any time you recompile OpenStudio then you will need to put the new .pyd and .py files in your 'openstudio' package otherwise you will probably get errors in your python bindings.

One way around this issue is to create a package of OpenStudio using the BUILD_PACKAGE option in CMake. This will then create a 'python/openstudio' folder with all the .py, .pyd, and .dll files in it with the correct dependency references.

So the 'openstudio' package has the following (rough) contents..

-- openstudio
   -  __init__.py
   -  openstudiomodel.py
   -  etc...
   -  _openstudiomodel.pyd
   -  etc...
   -  openstudio_model.dll (if using BUILD_PACKAGE)
   -  etc...

The __ init __.py __init__.py file looks like ...

import openstudiomodel as model
import openstudioenergyplus as energyplus
from openstudioutilitiescore import *
etc...

Then use it like the following import design day file example...

from openstudio import model, Workspace, path, energyplus
m = model.Model()
ddy_path = "/Applications/EnergyPlus-8-0-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.ddy"
os_ddy_path = path(ddy_path)
ddy_idf = IdfFile.load(os_ddy_path)
ddy_workspace = Workspace(ddy_idf.get())
reverse_translator = energyplus.ReverseTranslator()
ddy_model = reverse_translator.translateWorkspace(ddy_workspace)
ddy_objects = [ddy_object for ddy_object in model.getDesignDays(ddy_model) if (".4%" in ddy_object.name().get() or "99.6" in ddy_object.name().get())]
m.addObjects(ddy_objects)

Hopefully this helps (and makes sense). Also, these code snippets work for python 2.7 and probably should work in python 3 but that is untested.

I agree with @macumber, this seems like a path issue.

There are a few things you can do to try and get the bindings working.

First, I use PyCharm when working with Python in general and the OpenStudio bindings. It provides code completion and insights, even for the OpenStudio bindings, among other many other benefits. There benefits and there is a free community version.

Next, I create an 'openstudio' package, basically a folder with an __init__.py file. This allows you to import openstudio and use it like m = openstudio.model.Model(). Within this package, I put all the .py and .pyd files from the /python and /python/Release folders.

Now a major caveat to this is that the .pyd files contain a dependency reference to the associated .dll (located in Products/Release/). This means that any time you recompile OpenStudio then you will need to put the new .pyd and .py files in your 'openstudio' package otherwise you will probably get errors in your python bindings.

One way around this issue is to create a package of OpenStudio using the BUILD_PACKAGE option in CMake. This will then create a 'python/openstudio' folder with all the .py, .pyd, and .dll files in it with the correct dependency references.

So the 'openstudio' package has the following (rough) contents..

-- openstudio
   -  __init__.py
   -  openstudiomodel.py
   -  etc...
   -  _openstudiomodel.pyd
   -  etc...
   -  openstudio_model.dll (if using BUILD_PACKAGE)
   -  etc...

The __init__.py file looks like ...

import openstudiomodel as model
import openstudioenergyplus as energyplus
from openstudioutilitiescore import *
etc...

Then use it like the following import design day file example...

from openstudio import model, Workspace, path, energyplus
m = model.Model()
ddy_path = "/Applications/EnergyPlus-8-0-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.ddy"
os_ddy_path = path(ddy_path)
ddy_idf = IdfFile.load(os_ddy_path)
ddy_workspace = Workspace(ddy_idf.get())
reverse_translator = energyplus.ReverseTranslator()
ddy_model = reverse_translator.translateWorkspace(ddy_workspace)
ddy_objects = [ddy_object for ddy_object in model.getDesignDays(ddy_model) if (".4%" in ddy_object.name().get() or "99.6" in ddy_object.name().get())]
m.addObjects(ddy_objects)

Hopefully this helps (and makes sense). Also, these code snippets work for python 2.7 and probably should work in python 3 but that is untested.