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

Delete existing OS:FuelFactors

asked 2025-01-29 08:28:10 -0600

updated 2025-01-29 09:12:31 -0600

I am writing a script to create new OpenStudio::Model::FuelFactors

Everything works fine but it does not delete the existing FuelFactor for that fuel.

How can I delete all the existing FuelFactors? I have tried some thing like:

model.getFuelFactors

but this method requires a Handle argument that I dont know.

Any ideas?

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2025-01-30 04:16:13 -0600

updated 2025-02-03 07:20:05 -0600

TL;DR: Getters follow the convention of being called get<ClassName>s().

The class is called FuelFactors. Note the existing s.

So logically, the getter is getFuelFactorss() (double s).

The same goes for getLightss().


If you want an explanation you didn't ask for, this is because we're using a C++ template: https://github.com/NREL/OpenStudio/bl...

template <typename T>
std::vector<T> getModelObjects(bool sorted = false);

This exposed to the target language via SWIG bindings, and we transform that to a method called get<T>s() automatically.

The same is true for the ruby IdfObject.to_ClassName(). The C++ equivalent is template<typename T> boost::optional<T> IdfObject::cast()


Here are all of the similar std::vector<T> get<T>s() that end with at least a double s, from python

import openstudio
import re
import inspect


RE_GET = re.compile(r'^get.+ss$')
getters = []
model = openstudio.model.Model()

for method_name in dir(model):
    method = getattr(model, method_name)
    if not inspect.ismethod(method):
        continue
    if not RE_GET.match(method_name):
        continue

    # Keep only those that take zero params
    if len(inspect.signature(method).parameters) != 0:
        continue
    getters.append(method_name)



['getAdditionalPropertiess',
 'getAirLoopHVACUnitaryHeatCoolVAVChangeoverBypasss',
 'getAirflowNetworkDuctViewFactorss',
 'getAirflowNetworkReferenceCrackConditionss',
 'getCoilHeatingGass',
 'getCoolingTowerPerformanceCoolToolss',
 'getDefaultSubSurfaceConstructionss',
 'getDefaultSurfaceConstructionss',
 'getElectricLoadCenterInverterPVWattss',
 'getExteriorLightss',
 'getFuelFactorss',
 'getGass',
 'getGeneratorPVWattss',
 'getHumidifierSteamGass',
 'getInternalMasss',
 'getLightss',
 'getMaterialPropertyMoisturePenetrationDepthSettingss',
 'getMaterialPropertyPhaseChangeHysteresiss',
 'getOutputEnvironmentalImpactFactorss',
 'getRefrigerationDefrostCycleParameterss',
 'getRunPeriodControlSpecialDayss',
 'getScheduleTypeLimitss',
 'getSurfacePropertyConvectionCoefficientss',
 'getSurfacePropertyGroundSurfacess',
 'getSurfacePropertyOtherSideCoefficientss',
 'getSurfacePropertySurroundingSurfacess',
 'getWaterUseConnectionss',
 'getWeatherFileDayss'
edit flag offensive delete link more

Comments

1

Thank you for your reply. Once again you are a lifesaver. I also appreciate the extra explanation. I'm not familiariced with C++, but I was a bit confused because I searched the github repository for a getFuelFactors method but didn't find anything helpful.

mapascual's avatar mapascual  ( 2025-01-30 04:32:53 -0600 )edit

Yeah, the template makes it a bit harder to search in the github code, as well as the sdk documentation: https://s3.amazonaws.com/openstudio-s...

One thing that can help is in irb is to search for method names:

 m.methods.grep(/getFuel.*s$/).sort
  => [:getFuelFactors, :getFuelFactorss]
Julien Marrec's avatar Julien Marrec  ( 2025-02-03 07:04:07 -0600 )edit

A rough python equivalent: model = openstudio.model.Model(); [m for m in dir(model) if callable(getattr(model, m)) and 'FuelFactor' in m]

Julien Marrec's avatar Julien Marrec  ( 2025-02-03 07:06:40 -0600 )edit

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: 2025-01-29 08:28:10 -0600

Seen: 65 times

Last updated: Feb 03