3

openstudio savemodel python package

Hi, I'm learning to use openstudio package of python but found some problems to use the function "saveModel". When I use it, for example:

import openstudio
osm = openstudio.model.Model()
openstudio.model.saveModel(osm,"model.osm", "")

it throws the following error:

[saveModelTempDir] <1> Could not copy osm from '/path/to/file/model.osm' to 'model.osm' errorboost::filesystem::copy_file: File exists [system:17]: "/path/to/file/model.osm", "model.osm"

I've tried other ways like use the complete directory path, but keeps the error. And found this notebook(https://github.com/GFlechas/... and occurs the same error.

Any idea what's the problem?

efrainpuerto's avatar
175
efrainpuerto
asked 2024-02-10 23:08:32 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2024-02-12 07:25:15 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

4

openstudio::model::saveModel is a function that's more meant for the OpenStudio Application (somewhat of a leftover after separating the OpenStudio Application from the OpenStudio SDK). It will copy the model and the companion directory (if your model is named mymodel.osm, that's the directory mymodel/ next to it) to another location. The third parameter is a path to that temporary directory, it cannot be empty.

Anyways, you likely don't want to use it at all. You should use openstudio::model::Model.save(path, overwrite = false)

import openstudio
model = openstudio.model.Model()
model.save("model.osm", True)
# or
from pathlib import Path
model.save(Path('mymodel.osm'), True)

This method is inherited from Workspace: SDK docs

Julien Marrec's avatar
29.7k
Julien Marrec
answered 2024-02-12 02:12:05 -0500, updated 2024-02-12 02:39:01 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments