Error when loading openstudio model using python after v3.7 [closed]

asked Jun 5

updated Jun 6

Recently updated to OpenStudio 3.7, but since then, I'm not able to load models in python the same way as before. This is the way I loaded models in python in version 3.5.1:

# Set filenames
filename = "../test.osm"
modelfilepath = openstudio.path(filename)

# Load openstudio model
optional_model = openstudio.openstudiomodel.Model.load(modelfilepath)

# # Load openstudio model using VersionTranslator
# vs = openstudio.osversion.VersionTranslator()
# optional_model = vs.loadModel(modelfilepath)

# Get optional model
if optional_model.is_initialized():
    model = optional_model.get()

But the same code in version 3.7 causes the following error:

TypeError: Wrong number or type of arguments for overloaded function 'Model_load'.
  Possible C/C++ prototypes are:
    openstudio::model::Model::load(openstudio::path const &)
    openstudio::model::Model::load(openstudio::path const &,openstudio::path const &)

I get the same results regardless of the openstudio version of the osm file I am trying to load. I did see that #4923 changed the Model::load API and was wondering if there's a different way to load models now.

Preview: (hide)

Closed for the following reason duplicate question by Ken Takahashi
close date 2024-06-06 11:14:03.166401

Comments

1

I think this is the same issue as this?

shorowit's avatar shorowit  ( Jun 6 )

Oh yes that most certainly was the issue! Did not think to check if the path object was not working. Thank you very much!

Ken Takahashi's avatar Ken Takahashi  ( Jun 6 )

Fixed in 3.8.0 FYI.

Julien Marrec's avatar Julien Marrec  ( Jun 7 )