First time here? Check out the Help page!

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

Python errors with openstudio::path

asked 1 year ago

jrmuller's avatar

updated 1 year ago

I am trying to learn the python bindings for OpenStudio, but I am getting an error whenever I try to use an openstudio::path variable. The function openstudio.path is returning an object of type <class 'openstudio.openstudioutilitiescore.path'="">. When I pass that object to function that requires openstudio::path const &, it throws an error saying type error, e.g.,

TypeError: Wrong number or type of arguments for overloaded function 'Workspace_save'.
 Possible C/C++ prototypes are:
  openstudio::Workspace::save(openstudio::path const &,bool)
  openstudio::Workspace::save(openstudio::path const &)

Thanks

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 1 year ago

updated 1 year ago

That's my fault, sorry, I slightly messed up the SWIG typemaps when I added support for automatic conversions to/from C++ openstudio::path and python's pathlib.path...

I've filed https://github.com/NREL/OpenStudio/is... to track it. Either pass a str or a pathlib.Path and it'll work.

from pathlib import Path
m.save(Path("model.osm"), True)
m.save("model.osm", True)
Preview: (hide)
link

Comments

Thank you so much!

jrmuller's avatar jrmuller  ( 1 year ago )
Julien Marrec's avatar Julien Marrec  ( Jun 7 )

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 1 year ago

Seen: 155 times

Last updated: Jun 07 '24