Openstudio complains about argument to Workspace.addObjects() but all objects are successfully added [closed]
I have a measure that injects all the objects in an IDF file into the main idf file. It has been working on every file except one, the 5ZoneFanCoilDOAS_ERVOnAirLoopMainBranch.idf example file. Here are all the files.
#load the idf file
source_idf = OpenStudio::IdfFile::load(OpenStudio::Path.new(source_idf_path)).get
#add everything from the file
workspace.addObjects(source_idf.objects)
As far as I can tell, all the objects are successfully added, but Openstudio complains about Workspace.addObjects() being given an incompatible argument.
[15:31:30.476167 ERROR] Found error in state 'preprocess' with message ["Wrong arguments for overloaded method 'Workspace.addObjects'.
Possible C/C++ prototypes are:
std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > Workspace.addObjects(std::vector< openstudio::IdfObject,std::allocator< openstudio::IdfObject > > const &idfObjects, bool checkNames)
std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > Workspace.addObjects(std::vector< openstudio::IdfObject,std::allocator< openstudio::IdfObject > > const &idfObjects)
std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > Workspace.addObjects(std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > const &objects, bool checkNames)
std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > Workspace.addObjects(std::vector< openstudio::WorkspaceObject,std::allocator< openstudio::WorkspaceObject > > const &objects)
::/ruby/2.2.0/gems/openstudio-workflow-1.3.3/lib/openstudio/workflow/util/energyplus.rb:194:in `addObjects'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.3/lib/openstudio/workflow/util/energyplus.rb:194:in `energyplus_preprocess'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.3/lib/openstudio/workflow/jobs/run_preprocess.rb:58:in `perform'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.3/lib/openstudio/workflow/run.rb:269:in `step'
:/ruby/2.2.0/gems/openstudio-workflow-1.3.3/lib/openstudio/workflow/run.rb:216:in `run'
:/openstudio_cli.rb:848:in `execute'
:/openstudio_cli.rb:639:in `execute'
:/openstudio_cli.rb:1614:in `<main>'
eval:107:in `eval'
eval:107:in `require_embedded_absolute'
eval:92:in `block in require'
eval:86:in `each'
eval:86:in `require'
eval:2:in `<main>'"]}
Post Script in response to @mdahlhausen's comment.
However, the in.idf was never generated and there is a new "run" error file referencing 'Workspace.addObjects' which doesn't exist in my measure any more since I replaced it with @mdahlhausen's code, not even as a comment.
how are you initializing your workspace object?
@mdahlhausen Invoking super to whatever parent class that goes to.
super(workspace, runner, user_arguments)
try something like:
and see which object it is failing at.
@mdahlhausen I tried the code, and it outputted all the objects to the very last Output:Diagnostics object. The Openstudio run says the measure was applied successfully (see the images I added to post), but the in.idf was not created. There is still a new created "run" file listing an error with 'Workspace.addObjects' and that line no longer exists in the code, not even as a comment. I replaced the addObjects() function call with your code above.
Strangely, the code you gave me is outputting the commented !- == OBJECT TYPE == lines in the idf text file.
Here are the slightly updated files. Google Drive link