First time here? Check out the Help page!

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

How to delete an object from the idf file in an energyplus measure?

asked 7 years ago

Mitchal Dichter's avatar

updated 7 years ago

I know this is very easy in an openstudio measure, but how do I delete an object from the idf file using an energyplus measure?

Also, is there any documentation for writing energyplus measures similar to the openstudio documentation?

https://openstudio-sdk-documentation....

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
4

answered 7 years ago

updated 3 years ago

Per Eric's comment below, the best way to do this is using the remove call of a Workspace Object. API documentation for the Workspace object here. You can get an instance of an object in your Workspace with the getObjectByTypeAndName or related method call. Be careful about removing workspace objects - you may end up deleting an object needed by another object.

For a tutorial on writing EnergyPlus measures, see the EnergyPlus Measures section in the OpenStudio Measure Writer's Reference Guide provides an example.

Preview: (hide)
link

Comments

@mdahlhausen I wasn't able to find the string getObjectByTypeAndName anywhere on that webpage by using Ctrl-f on the webpage. There only appears to be instructions on creating new objects and modifying fields on existing objects in an energyplus model.

Ctrl-f on getObject does result in 6 found places on that webpage though, but all 6 instances are the front of getObjectsByType on the webpage.

Mitchal Dichter's avatar Mitchal Dichter  ( 7 years ago )

That's strange, it's right here.

ericringold's avatar ericringold  ( 7 years ago )

Also WorkspaceObject has the methodremove that works just fine.

ericringold's avatar ericringold  ( 7 years ago )

@Eric Ringold Yes. Your "here" link leads to a webpage with documentation on the workspace class. The "EnergyPlus Measures section" link from @mdahlhausen led to a short tutorial on writing measures, one section of which is writing energyplus measures. This is absolutely everything I need. Thanks!

Mitchal Dichter's avatar Mitchal Dichter  ( 7 years ago )

@mdahlhausen Please change your first sentence to reference @Eric Ringold's link, then I'll accept your answer.

Mitchal Dichter's avatar Mitchal Dichter  ( 7 years ago )
2

answered 3 years ago

For example, removing all EMS sensor objects:

ems_sensors = workspace.getObjectsByType("EnergyManagementSystem:Sensor".to_IddObjectType)

ems_sensors.each do |obj|
  obj.remove
end
Preview: (hide)
link

Comments

looks like this code snippet might be useful for our "Clean ResStock for Ideal Air Loads" measure @Eric

sashadf1's avatar sashadf1  ( 3 years ago )
0

answered 3 years ago

sashadf1's avatar

Additional methods for removing EMS objects:

model.getEnergyManagementSystemActuators(&:remove)
model.getEnergyManagementSystemConstructionIndexVariables(&:remove)
model.getEnergyManagementSystemCurveOrTableIndexVariables(&:remove)
model.getEnergyManagementSystemGlobalVariables(&:remove)
model.getEnergyManagementSystemInternalVariables(&:remove)
model.getEnergyManagementSystemMeteredOutputVariables(&:remove)
model.getEnergyManagementSystemOutputVariables(&:remove)
model.getEnergyManagementSystemPrograms(&:remove)
model.getEnergyManagementSystemProgramCallingManagers(&:remove)
model.getEnergyManagementSystemSensors(&:remove)
model.getEnergyManagementSystemSubroutines(&:remove)
model.getEnergyManagementSystemTrendVariables(&:remove)

Credit to @Scott Horowitz from NREL.

You could also extend the solution provided by @Eric Martin to multiple EMS objects.

# remove EMS objects model.getEnergyManagementSystemSensors.each do |ems_obj| ems_obj.remove end model.getEnergyManagementSystemActuators.each do |ems_obj| ems_obj.remove end model.getEnergyManagementSystemGlobalVariables.each do |ems_obj| ems_obj.remove end

etc... for other EMS objects

Preview: (hide)
link

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: 7 years ago

Seen: 566 times

Last updated: Jul 21 '21