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 2018-01-31 14:06:09 -0600

mldichter's avatar

updated 2018-01-31 15:02:21 -0600

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

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2018-01-31 17:31:23 -0600

updated 2021-07-21 10:27:29 -0600

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.

edit flag offensive delete link more

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.

mldichter's avatar mldichter  ( 2018-01-31 17:44:18 -0600 )edit

That's strange, it's right here.

ericringold's avatar ericringold  ( 2018-02-01 09:33:18 -0600 )edit

Also WorkspaceObject has the methodremove that works just fine.

ericringold's avatar ericringold  ( 2018-02-01 09:55:19 -0600 )edit

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

mldichter's avatar mldichter  ( 2018-02-01 09:57:24 -0600 )edit

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

mldichter's avatar mldichter  ( 2018-02-01 09:59:03 -0600 )edit
2

answered 2021-07-20 11:52:05 -0600

For example, removing all EMS sensor objects:

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

ems_sensors.each do |obj|
  obj.remove
end
edit flag offensive delete link more

Comments

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

sashadf1's avatar sashadf1  ( 2021-07-20 16:40:37 -0600 )edit
0

answered 2021-07-21 16:00:31 -0600

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

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: 2018-01-31 14:06:09 -0600

Seen: 529 times

Last updated: Jul 21 '21