Here is some code borrowed from the Office and K12 AEDG envelope measures.
# make new material
exposedMaterialNew = OpenStudio::Model::StandardOpaqueMaterial.new(construction.model)
exposedMaterialNew.setName(options['name'])
# set requested material properties
if !options['roughness'].nil? then exposedMaterialNew.setRoughness(options['roughness']) end
if !options['thickness'].nil? then exposedMaterialNew.setThickness(options['thickness']) end
if !options['conductivity'].nil? then exposedMaterialNew.setConductivity(options['conductivity']) end
if !options['density'].nil? then exposedMaterialNew.setDensity(options['density']) end
if !options['specificHeat'].nil? then exposedMaterialNew.setSpecificHeat(options['specificHeat']) end
if !options['thermalAbsorptance'].nil? then exposedMaterialNew.setThermalAbsorptance(options['thermalAbsorptance']) end
if !options['solarAbsorptance'].nil? then exposedMaterialNew.setSolarAbsorptance(options['solarAbsorptance']) end
if !options['visibleAbsorptance'].nil? then exposedMaterialNew.setVisibleAbsorptance(options['visibleAbsorptance']) end
# add material to construction
construction.insertLayer(options['layerIndex'], exposedMaterialNew)
In this example options
is a hash that contains data about the new material as well as the target layer index. It is in a resource file in a method named addNewLayerToConstruction
that takes a construction and the options hash.
There are two ways to do this - make a measure that you run through command line, or write a ruby script to add it. Which do you prefer for your workflow?
Some other information that would be useful to know, is if you are going to make a material for this layer on the fly or pick from materials already in the model. Also will you want to specify the position of this material relative to other layers.
Thank you for the response. I want to add a new material layer in the external face i.e layer index =0, by using a ruby script.