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 2023-12-19 10:12:01 -0500

jrmuller's avatar

updated 2023-12-19 10:37:26 -0500

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-12-20 03:00:50 -0500

updated 2023-12-20 09:20:42 -0500

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)
edit flag offensive delete link more

Comments

Thank you so much!

jrmuller's avatar jrmuller  ( 2023-12-20 07:41:11 -0500 )edit
Julien Marrec's avatar Julien Marrec  ( 2024-06-07 02:36:38 -0500 )edit

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: 2023-12-19 10:12:01 -0500

Seen: 112 times

Last updated: Jun 07