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

Revision history [back]

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

  unused_flag_counter = 0
  model.getCurves.sort.each do |resource|
    if resource.directUseCount == 0
      unused_flag_counter += 1
      resource.remove
    end
  end

@david-goldwasser or I can probably add curves to the Remove Orphan Objects and Unused Resources BCL measure.

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

  unused_flag_counter = 0
  model.getCurves.sort.each do |resource|
    if resource.directUseCount == 0
      unused_flag_counter += 1
      resource.remove
    end
  end

@david-goldwasser or I can probably add I've added curves to the Remove Orphan Objects and Unused Resources measure. The updated version should be on BCL measure.in the next week or so, or you can grab it from GitHub here.

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

  unused_flag_counter = 0
  model.getCurves.sort.each do |resource|
    if resource.directUseCount == 0
      unused_flag_counter += 1
      resource.remove
    end
  end

I've added curves to the Remove Orphan Objects and Unused Resources measure. The updated version should be on BCL in the next week or so, or you can grab it from GitHub here.

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

  unused_flag_counter = 0
  model.getCurves.sort.each do |resource|
|curve|
    if resource.directUseCount curve.directUseCount == 0
      unused_flag_counter += 1
      resource.remove
model.removeObject(curve.handle)
    end
  end

I've added curves to the Remove Orphan Objects and Unused Resources measure. The updated version should be on BCL in the next week or so, or you can grab it from GitHub here.

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

  unused_flag_counter = 0
  model.getCurves.sort.each do |curve|
    if curve.directUseCount == 0
      unused_flag_counter += 1
      model.removeObject(curve.handle)
    end
  end

I've added curves to the Remove Orphan Objects and Unused Resources measure. The updated version should be on BCL in the next week or so, or you can grab it from GitHub here.

EDIT: use model.removeObject instead of curve.remove because of this issue. Thanks to @Eric Ringold for the workaround.

Take a look at the Remove Orphan Objects and Unused Resources measure on BCL for an example.

OpenStudio::Model::Curve objects are a child of OpenStudio::Model::ResourceObject [link to documentation], which has a directUseCount method.

So your code could look as simple as:

 unused_flag_counter = 0
  model.getCurves.sort.each do |curve|
    if curve.directUseCount == 0
      unused_flag_counter += 1
      model.removeObject(curve.handle)
    end
  end

I've added curves to the Remove Orphan Objects and Unused Resources measure. The updated version should be on BCL in the next week or so, or you can grab it from GitHub here.

EDIT: use model.removeObject instead of curve.remove because of this issue. Thanks to @Eric Ringold for the workaround.