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

openstudio savemodel python package

asked 2024-02-10 23:08:32 -0600

efrainpuerto's avatar

updated 2024-02-12 07:25:15 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2024-02-12 02:12:05 -0600

updated 2024-02-12 02:39:01 -0600

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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2024-02-10 23:08:32 -0600

Seen: 46 times

Last updated: Feb 12