Check out this script:
Balcony Builder_building_01
Also, if you want to capture and reuse Code snippets. download this awesome plugin called MetaHopper. https://www.food4rhino.com/app/metahopper
(Rick & Morty fans: You can do all sorts of META stuff with it.)