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

Reporting Measure sql file manipulation

asked 2019-01-07 08:59:02 -0500

ParticleSwarm's avatar

updated 2019-01-07 09:04:22 -0500

Hello Unmet,

I am currently writing a reporting measure script to output information from a models sql file. I ran into a specific road block when trying to use the execAndReturnVectorOfDouble method. I need to now loop through this vector and grab the data from the column %Grand Total, however whenever I try to use common vector methods like .length() or .size(), I get an error saying ":

Peak Sensible Load section failed and was skipped because: undefined method `size' for OpenStudio::OptionalDoubleVector:0x0001a263305ac8

Here Is a screenshot of my sql statement.

image description

Any help would be greatly appreciated!

thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-01-07 12:09:59 -0500

Here is an example with similar method but with strings.

row_names = sqlFile.execAndReturnVectorOfString(rows_name_query).get
rows = []
row_names.each do |row_name|
  rows << row_name
end

rows is now a standard ruby array and you can use methods like rows.size. In my use case I then loop through rows array and perform additional tabular sql queries on each header entry for each row.

edit flag offensive delete link more
2

answered 2019-01-07 12:46:32 -0500

As you indicated, your query returned an OptionalDoubleVEctor object, not a DoubleVector object. See the "OpenStudio Measures and the boost::optional Type" section in the Measure Writer's Reference Guide for background information on how to deal with these types of optional objects.

edit flag offensive delete link more

Your Answer

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

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2019-01-07 08:59:02 -0500

Seen: 226 times

Last updated: Jan 07 '19