Class: RotateBuilding
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- RotateBuilding
- Defined in:
- lib/measures/RotateBuilding/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
define the name that a user will see.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/measures/RotateBuilding/measure.rb', line 24 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # make an argument for your name relative_building_rotation = OpenStudio::Measure::OSArgument.makeDoubleArgument('relative_building_rotation', true) relative_building_rotation.setDisplayName('Number of Degrees to Rotate Building (positive value is clockwise).') relative_building_rotation.setDefaultValue(90.0) relative_building_rotation.setUnits('degrees') args << relative_building_rotation return args end |
#description ⇒ Object
human readable description
14 15 16 |
# File 'lib/measures/RotateBuilding/measure.rb', line 14 def description return 'Rotate your building relative to its current orientation. This will not rotate site shading objects.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
19 20 21 |
# File 'lib/measures/RotateBuilding/measure.rb', line 19 def modeler_description return 'Get the North Axis field for the OS:Building object and adjusted it based on the user specified value. If the starting value is 20 degrees and the user value is 5 degrees, then the resulting value is 25 degrees.' end |
#name ⇒ Object
define the name that a user will see
9 10 11 |
# File 'lib/measures/RotateBuilding/measure.rb', line 9 def name return 'Rotate Building' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/measures/RotateBuilding/measure.rb', line 38 def run(model, runner, user_arguments) super(model, runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments(model), user_arguments) return false end # assign the user inputs to variables relative_building_rotation = runner.getDoubleArgumentValue('relative_building_rotation', user_arguments) # check the relative_building_rotation for reasonableness if (relative_building_rotation > 360) || (relative_building_rotation < -360) relative_building_rotation -= 360.0 * (relative_building_rotation / 360.0).truncate runner.registerWarning("Requested rotation was not between -360 and 360. Effective relative rotation is #{relative_building_rotation} degrees.") end # reporting initial condition of model building = model.getBuilding runner.registerValue('orientation_initial', building.northAxis) runner.registerInitialCondition("The building's initial rotation was #{building.northAxis} degrees.") # report as not applicable if effective relative rotation is 0 if relative_building_rotation == 0 runner.registerAsNotApplicable('The requested rotation was 0 degrees. The model was not altered.') else # rotate the building final_building_angle = building.setNorthAxis(building.northAxis + relative_building_rotation) runner.registerInfo("The building has been rotated by #{relative_building_rotation} degrees.") end # check for site shading model_contains_site_shading = false shading_surface_groups = model.getShadingSurfaceGroups shading_surface_groups.each do |shading_surface_group| if shading_surface_group.shadingSurfaceType == 'Site' model_contains_site_shading = true end end # issue warning if site shading surfaces exist if model_contains_site_shading runner.registerWarning('The model contains one or more site shading groups. They were not rotated with the building.') end # reporting final condition of model runner.registerValue('orientation_final', building.northAxis) runner.registerFinalCondition("The building's final rotation is #{building.northAxis} degrees.") return true end |