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

Identifying un-used constructions

asked 2020-10-02 11:57:34 -0600

antonszilasi's avatar

updated 2021-06-04 08:23:31 -0600

I want to identify un-used constructions in my model, I shamelessly ripped code from this measure : https://bcl.nrel.gov/node/82267 the code makes sense except for this section for constructions:

  model.getConstructions.sort.each do |resource|
    if resource.directUseCount == 1 # still don't understand why this is 1 not 0
      unused_flag_counter += 1
      resource.remove
  end

Why is resource.directUseCount == 1 when a construction is un-used? Is this code really correct? For all other resources the directUseCount == 0 when a resource is un-used.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-10-02 12:24:58 -0600

That looks a bit suspect to me. The C++ purgeUnusedResourceObjects does not have that exception for constructions. I would think that the use count of 1 is possibly due to a StandardsInformationConstruction or some object like that. I would do something like below to figure out what that object is and then decide if you want to remove the construction or not:

  model.getConstructions.sort.each do |resource|
    if resource.directUseCount == 0 
      unused_flag_counter += 1
      resource.remove
    elsif resource.directUseCount == 1
      puts "WHAT IS THIS OBJECT?"
      puts resource.sources[0]
      unused_flag_counter += 1
      resource.remove
    end
  end
edit flag offensive delete link more
4

answered 2022-12-06 09:34:57 -0600

updated 2022-12-06 09:39:18 -0600

I know this is old but I came across a similar issue when trying to remove unused schedule rulesets and I was able to figure it out. When searching for unused objects with directUseCount, by setting excludeChilden=true it ignores any objects that are children of that object like the StandardsInformationConstruction in this instance, without deleting objects that are referenced by other non-children objects.

So modifying the measure to the following worked as expected:

model.getConstructions.sort.each do |resource|
if resource.directUseCount(excludeChildren=true) == 0 
  unused_flag_counter += 1
  resource.remove
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

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2020-10-02 11:57:34 -0600

Seen: 418 times

Last updated: Dec 06 '22