2

Python errors with openstudio::path

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

jrmuller's avatar
41
jrmuller
asked 2023-12-19 10:12:01 -0500
Aaron Boranian's avatar
14.1k
Aaron Boranian
updated 2023-12-19 10:37:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

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)
Julien Marrec's avatar
29.7k
Julien Marrec
answered 2023-12-20 03:00:50 -0500, updated 2023-12-20 09:20:42 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank you so much!

jrmuller's avatar jrmuller (2023-12-20 07:41:11 -0500) edit

Fixed in OS SDK 3.8.0 via https://github.com/NREL/OpenStudio/pu...

Julien Marrec's avatar Julien Marrec (2024-06-07 02:36:38 -0500) edit
add a comment see more comments