Openstudio complains about argument to Workspace.addObjects() but all objects are successfully added [closed]

asked 2018-07-17 17:40:46 -0500

mldichter's avatar

updated 2018-07-18 15:44:04 -0500

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)

image description

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.

image description

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.

image description image description

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by David Goldwasser
close date 2019-02-06 13:38:44.760183

Comments

how are you initializing your workspace object?

mdahlhausen's avatar mdahlhausen  ( 2018-07-17 17:56:11 -0500 )edit

@mdahlhausen Invoking super to whatever parent class that goes to.
super(workspace, runner, user_arguments)

mldichter's avatar mldichter  ( 2018-07-17 18:00:59 -0500 )edit

try something like:

source.objects.each do |obj|
  runner.registerInfo("#{obj}"}
  workspace.addObject(obj)
end

and see which object it is failing at.

mdahlhausen's avatar mdahlhausen  ( 2018-07-17 22:24:34 -0500 )edit

@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.

mldichter's avatar mldichter  ( 2018-07-18 15:37:11 -0500 )edit

Here are the slightly updated files. Google Drive link

mldichter's avatar mldichter  ( 2018-07-18 15:50:33 -0500 )edit