I promised Carrie's Chief Academy class that I would share this macro that we showed off in class. I have since made some improvements.
The attached .json file contains the macro. Much of the details about what it is doing any why is included as comments within the Ruby code.
The attached .calibz file contains walls, doors, and a window. I included walls, doors, and windows derived from each of the defaults in our default template plan. These objects are already using the attached macro. You must import the macros for the library objects to work, otherwise you will get errors.
To see the macro in use just open one of the library objects and look at the drywall in the components panel.
If you have any thoughts on how to improve this macro please share.
Below is the entire text of the macro for your convenience:
# This macro is designed to estimate drywall
# Chief's default estimate does not account for
# drywalling over doors and windows
# Chief's default estimate also rounds each wall
# surface to the nearest quarter sheet.
# The result of this macro can be divided by the
# sheet size (in sq ft) to get an exact count
# When using this macro be sure to account for
# waste separately
# Walls always have :upper_layers
# Pony Walls also have :lower_layers
# either could have drywall
if owner.respond_to?(:upper_layers) and owner.respond_to?(:lower_layers)
# Usually we don't want drywall in the attic so return 0.0 in this case
# note: it has been brought to my attention that attic walls may provide
# drywall below a sloped (vaulted, cathedral) ceiling.
# For this reason you my want to delete the following line
return 0.0 if owner.is_attic
# sum will add up all of the things inside it
# we want to add the upper drywall area to the lower drywall area
[owner.upper_layers, owner.lower_layers].sum do |wall_part|
# interior walls have more than one drywall layer
# so lets do another sum
wall_part.sum do |layer|
# we only want the drywall layers so check to see if it says "Drywall"
# if you call drywall something else you can check for that instead
# if the material name does not contain "Drywall" this layer counts 0.0
layer.material_data.description.include?("Drywall") ? layer.area : 0.0
# at this point we know we are not a wall
# the only thing we need from doors or windows is :height and :width
# so lets make sure this owner has them
# this doesn't mean it is a door or window, but we won't plan on using this
# for anything else
elsif owner.respond_to?(:height) and owner.respond_to?(:width) and owner.respond_to?(:is_on_exterior_wall)
# for interior walls count both sides
num_sides = is_on_exterior_wall ? 1 : 2
# height and width are measured in inches so divide by 144 to get sq ft
num_sides * owner.height * owner.width / 144
# this is not currently intended to compute drywall for anything else
# so force an error
raise "cannot compute drywall area for this object"
MatList Drywall Over openings.calibz