Close
About
FAQ
Home
Collections
Login
USC Login
Register
0
Selected
Invert selection
Deselect all
Deselect all
Click here to refresh results
Click here to refresh results
USC
/
Digital Library
/
University of Southern California Dissertations and Theses
/
Revit plugins for electrical engineering improvements in buildings: Lighting power density and electrical equipment placement
(USC Thesis Other)
Revit plugins for electrical engineering improvements in buildings: Lighting power density and electrical equipment placement
PDF
Download
Share
Open document
Flip pages
Contact Us
Contact Us
Copy asset link
Request this asset
Transcript (if available)
Content
Revit Plugins for Electrical Engineering Improvements in Buildings: Lighting Power Density and Electrical Equipment Placement by Lu Huang A Thesis Proposal SCHOOL OF ARCHITECTURE UNIVERSITY OF SOUTHERN CALIFORNIA In Partial Fulfillment of the Requirements for the Degree MASTER OF BUILDING SCIENCE Cover Page AUGUST 2018 Page | 2 Acknowledgements Thanks to my parents who always support me during my 2-years study at USC. Without them I would not have the chance to start this thesis. Many thanks to professor Karen Kensek, who spent lots of time on revising my thesis and giving me instructions. I would also like to express my sincere thanks to Mr. Winston Kahn for the technique support and letting me understand the plugin demand of engineers. Thanks to all the people who helped me during my thesis. Page | 3 Committee CHAIR: Karen M. Kensek, LEED AP BD+C Assoc. Prof. of the Pract. of Architecture USC School of Architecture kensek@usc.edu (213)740-2081 COMMITTEE MEMBER #2: Mohammed Beshir Professor USC Viterbi Beshir@usc.edu (213)740-6433 COMMITTEE MEMBER #3: Douglas E. Noble, PH.D., FAIA Associate Professor USC School of Architecture dnoble@usc.edu (213)740-4589 Page | 4 Abstract Software for the construction industry has progressed in sophistication for approximately the last three decades, with advances seen in cost, ease-of-use, and features. In addition, most software programs allow users the ability to create custom tools either through the use of scripting or accessing the API (application programming interface). Revit is a common building information modeling (BIM) program use by many people in the architecture/engineering/construction industry. One can develop add-ins in C# for simple or complex tasks with the Revit API. Electrical engineers often do repetitive tasks that would benefit from a Revit add-in that would make them more efficient and accurate. One scenario is that they have to create electrical plans after they finish single line diagrams (SLD). During the process, electrical engineers need to locate every equipment in SLD and place it in the architecture plan, which is a tedious work. In this case, a program that could complete this process automatically would enhance engineers’ efficiency. A tool was developed that could read equipment location and function information in SLD, find the correct location, and place the equipment in this position. The program allows engineers to customize principal and equipment type based on practical situation. Another scenario is when electrical engineers assess whether a building meets the LPD requirement of Title 24; they have to get the area of a room and total power of lighting fixture in this room, then calculate the LPD. Usually, such work would take about two weeks. But computer is skilled in data processing. By creating a Revit tool that can do this task automatically, electrical engineers’ work could be alleviated. Hypothesis Revit API and C# could be used for creating various programs that automating some progress of electrical engineers’ work. Research objectives To apply C# programming language and the Revit API to develop Revit plugins. To create a Revit add-in for placing electrical equipment based on the information in single line diagram. To create a Revit add-in for calculating light power density to satisfy Title 24 requirements in the State of California. Page | 5 Table of Contents Cover Page ................................................................................................................................................................... 1 Acknowledgements ...................................................................................................................................................... 2 Committee .................................................................................................................................................................... 3 Abstract ........................................................................................................................................................................ 4 Hypothesis .................................................................................................................................................................... 4 Research objectives ...................................................................................................................................................... 4 Table of Contents ......................................................................................................................................................... 5 Table of Figure ............................................................................................................................................................. 7 Chapter 1 Introduction ............................................................................................................................................. 10 1.1 Building Information Modeling ..................................................................................................................... 10 1.1.1 2D and 3D modeling .................................................................................................................................. 10 1.1.2 Level of development ................................................................................................................................ 13 1.1.3 BIM application in construction management ........................................................................................... 14 1.1.4 BIM simulation .......................................................................................................................................... 14 1.2. Revit programming: Dynamo and the Revit API ........................................................................................ 15 1.2.1 Dynamo ...................................................................................................................................................... 15 1.2.2 Revit API ................................................................................................................................................... 18 1.2.3 Revit programming: two examples ............................................................................................................ 21 1.3 Building Electrical Engineering ..................................................................................................................... 23 1.3.1 Power engineering ..................................................................................................................................... 23 1.3.1.1 Electrical system ..................................................................................................................................... 23 1.3.1.2 Power source ........................................................................................................................................... 24 1.3.1.3 Power distribution ................................................................................................................................... 24 1.3.2 Single line diagram & electrical plan ......................................................................................................... 25 1.3.3 Title 24 ....................................................................................................................................................... 27 1.4 Electrical improvement topic ......................................................................................................................... 29 1.4.1 Single line diagram .................................................................................................................................... 29 1.4.2 Energy evaluation ...................................................................................................................................... 30 1.4.3 Lighting engineering .................................................................................................................................. 30 1.5 Summary .......................................................................................................................................................... 31 Chapter 2 Background Research ............................................................................................................................. 32 2.1 Revit programming tools ................................................................................................................................ 32 2.1.1 Visual Studio.............................................................................................................................................. 32 2.1.2 Macro ......................................................................................................................................................... 34 2.1.3 Dynamo ...................................................................................................................................................... 35 2.2 Revit Data ........................................................................................................................................................ 39 2.2.1 Revit object ................................................................................................................................................ 39 2.2.2 Information exchange ................................................................................................................................ 41 2.3 BIM based automated code-checking programming ................................................................................... 42 2.4 Current Commercial plugin ........................................................................................................................... 44 2.4.1 (Conduits & Cable Tray) Hangers 2017 .................................................................................................... 44 2.4.2 Elum Tools ................................................................................................................................................. 46 Chapter 3: Methodology ........................................................................................................................................... 47 3.1 Introduction ..................................................................................................................................................... 47 3.2 Development tools ........................................................................................................................................... 47 3.3 Customization tools ......................................................................................................................................... 47 3.3.1 SLD device automatic navigation tool (SDAN) workflow ........................................................................ 47 3.3.2 Title 24-LPD evaluation tool (TLE) workflow .......................................................................................... 47 3.4 Program development ..................................................................................................................................... 48 3.4.1.1 Programming concept of SDAN ............................................................................................................. 48 3.4.1.2 Program workflow for SDAN ................................................................................................................. 50 3.4.1.2.1 Principle claim ..................................................................................................................................... 52 Page | 6 3.4.1.2.2 Logical judgement ............................................................................................................................... 52 3.4.1.2.3 Error correction .................................................................................................................................... 52 3.4.2.1 Programming concept of LTE ................................................................................................................. 52 3.4.2.2 Program workflow for Title 24-LPD evaluation tool .............................................................................. 53 3.4.2.2.1 Input standard ...................................................................................................................................... 54 3.4.2.2.2 LPD calculation ................................................................................................................................... 54 3.4.2.2.3 Result Display ...................................................................................................................................... 55 3.5 Program assessment ........................................................................................................................................ 55 3.5.1 Case Study ................................................................................................................................................. 55 3.5.1.1 Local model ............................................................................................................................................ 55 3.5.1.2 Linked model .......................................................................................................................................... 56 3.5.1.3 Real project simulation ........................................................................................................................... 57 3.5.2 Evaluation criteria ...................................................................................................................................... 57 3.5.2.1 Accuracy ................................................................................................................................................. 57 3.5.2.2 Responding speed ................................................................................................................................... 57 3.5.2.3 Customizability ....................................................................................................................................... 57 3.5.2.4 Simplicity ................................................................................................................................................ 58 3.6 Summary .......................................................................................................................................................... 58 Chapter 4 Program Development ............................................................................................................................ 59 4.1 LTE ................................................................................................................................................................... 59 4.1.1 Reference files in Visual Studio................................................................................................................. 59 4.1.2 Command button creation .......................................................................................................................... 60 4.1.3 Main program ............................................................................................................................................ 61 4.1.3.1 Obtain Revit application handle .............................................................................................................. 62 4.1.3.2 Loading standard file .............................................................................................................................. 62 4.1.3.3 Obtain room property .............................................................................................................................. 64 4.1.3.4 LPD calculation ...................................................................................................................................... 66 4.1.3.5 Linked model .......................................................................................................................................... 68 4.2 SDAN programming process .......................................................................................................................... 69 4.2.1 Find the level id ......................................................................................................................................... 69 4.2.2 Get the family symbol ................................................................................................................................ 70 4.2.3 Tag analysis ............................................................................................................................................... 71 4.2.4 Main program ............................................................................................................................................ 74 4.2.4.1 Tag claim ................................................................................................................................................ 75 4.2.4.2 Equipment list ......................................................................................................................................... 75 4.2.4.3 Searching Equipment location ................................................................................................................ 76 4.2.5 Creating equipment .................................................................................................................................... 78 4.3 Summary .......................................................................................................................................................... 78 Chapter 5 Result ........................................................................................................................................................ 79 5.1 LPD ................................................................................................................................................................... 79 5.2 SDAN ................................................................................................................................................................ 82 5.2.1 Program input ............................................................................................................................................ 82 5.3 Conclusion ........................................................................................................................................................ 88 Chapter 6 Future Work ............................................................................................................................................ 89 6.1 LPD tool ........................................................................................................................................................... 89 6.2 SDAN ................................................................................................................................................................ 89 6.3 Summary .......................................................................................................................................................... 90 References .................................................................................................................................................................. 91 Appendix .................................................................................................................................................................... 93 Source code of SDAN ............................................................................................................................................ 93 Source code of LTE ............................................................................................................................................. 100 Page | 7 Table of Figure Figure 1.1 CAD company Market Shares. ................................................................................................................... 10 Figure 1.2 MEP pipeline in BIM model. ..................................................................................................................... 11 Figure 1.3 Legend and parameter of switch board in AutoCAD ................................................................................. 12 Figure 1.4 Legend and parameter of switch board in Revit ......................................................................................... 12 Figure 1.4a Revit lounge plate. .................................................................................................................................... 13 Figure 1.4b Image of level of development. ................................................................................................................ 14 Figure 1.5 Autodesk cloud simulation interface. ......................................................................................................... 15 Figure 1.6 Creating a custom node .............................................................................................................................. 15 Figure 1.6a Test result for the custom node ................................................................................................................. 16 Figure 1.6b Three-phase representation in US ............................................................................................................ 16 Figure 1.7 Dynamo program for adapting UN electrical expression standard ............................................................. 17 Figure 1.8 The node of Electrical circuit gets Panels and Elements. ........................................................................... 17 Figure 1.9 The python scrip for developing the node of Electrical circuit get Panels and Elements. .......................... 18 Figure 1.9b Result of code execute .............................................................................................................................. 19 Figure 1.10 Methods of cable tray in Revit API. ......................................................................................................... 19 Figure 1.11 Properties of cable tray in Revit API. ....................................................................................................... 20 Figure 1.12 Difference between DLL and EXE format ............................................................................................... 20 Figure 1.13 Voltage drop calculating software by Design Master Software, Inc. ....................................................... 22 Figure 1.14 Branch Circuit Breaker and Wire Sizing by Design Master Software, Inc. ............................................. 23 Figure 1.15 UPS. ......................................................................................................................................................... 24 Figure 1.16 Diesel generator. ....................................................................................................................................... 24 Figure.1.17 Electrical power distribution system ........................................................................................................ 25 Figure 1.18 Single line diagram ................................................................................................................................... 26 Figure 1.19 Symbol for transformer in SLD. ............................................................................................................... 26 Figure 1.20 Symbol for breaker in SLD. ..................................................................................................................... 26 Figure 1.21 Symbol for motor in SLD. ........................................................................................................................ 26 Figure 1.22 Symbol for ground in SLD. ...................................................................................................................... 27 Figure 1.23 Electrical plan. .......................................................................................................................................... 27 Table 1.1 Complete building method lighting power density values. .......................................................................... 28 Table 1.2 Retail-specific Selections from the Allowed Lighting power table ............................................................. 28 Figure 1.25 Current work flow in electrical engineering ............................................................................................. 29 Figure 1.26 Lighting plan. Retrieved from USC Facilities Management Services(FMS) HED project ...................... 30 Figure 2.1 DLL file creating process in Visual Studio ................................................................................................ 32 Figure 2.2 Inheritance hierarchy of Room class. ......................................................................................................... 32 Figure 2.3 Add-In Manager under External Tools in Revit ......................................................................................... 33 Figure 2.4 A typical manifest code for Revit ............................................................................................................... 33 Figure 2.5 DLL file execute methods in Revit ............................................................................................................ 34 Figure 2.6 Macro creation and execute process ........................................................................................................... 35 Figure 2.7 Dynamo code box & C# script ................................................................................................................... 35 Figure 2.7a Wall creation by Dynamo ......................................................................................................................... 36 Figure 2.7b Created model in Revit ............................................................................................................................. 36 Figure 2.7c Code script for creating wall by C# .......................................................................................................... 36 Figure 2.8 Parameterized façade at 9:00 AM .............................................................................................................. 37 Figure 2.9 Parameterized façade at 1:00 PM ............................................................................................................... 38 Figure 2.10 Parameterized panel ................................................................................................................................. 38 Figure 2.11 Golden Gate bridge model in Dynamo ..................................................................................................... 39 Figure 2.12 Function scope of Visual Studio, Macro and Dynamo ............................................................................. 39 Figure 2.13 Room parameter in Revit ......................................................................................................................... 40 Table 2.1 Important room properties in the Revit API. ............................................................................................... 40 Figure 2.14 Sample code for retrieving room property in Revit API .......................................................................... 41 Figure 2.15 Sample code for retrieving Excel data in Revit API ................................................................................. 42 Table 2.2 Information extraction step and corresponding API Functionalities ........................................................... 43 Figure 2.16 Certificate of Compliance of USC HER project....................................................................................... 44 Figure 2.17 Conduit and hanger .................................................................................................................................. 45 Figure 2.18 Cable tray and hanger ............................................................................................................................... 45 Page | 8 Figure 2.19 Support span for cable tray. Retrieved from: Installation guide, Unitray System Inc. ............................. 46 Figure 2.20 Hanger automate placing. ......................................................................................................................... 46 Figure 3.1 Overview of methodology .......................................................................................................................... 47 Figure 3.2 Previous and proposed workflow of SLD device automatic navigation tools ............................................ 47 Figure 3.3 Previous and proposed workflow Title 24-LPD evaluation tool ................................................................ 48 Figure 3.4 Power distribution equipment room ........................................................................................................... 49 Figure 3.5 Meaning of each alphabet of equipment’s tag ............................................................................................ 50 Figure 3.6 Program workflow for SLD device automatic navigation tool ................................................................... 51 Figure 3.7 Data retrieval and process in LPD calculation ........................................................................................... 53 Figure 3.8 Data retrieval and process in LPD calculation ........................................................................................... 54 Figure 3.9a Local model plan ...................................................................................................................................... 56 Figure 3.10 Linked model plan .................................................................................................................................... 56 Figure 3.11 Model assessment ..................................................................................................................................... 57 Figure 4.1 Program overview ...................................................................................................................................... 59 Figure 4.2 Adding references ...................................................................................................................................... 60 Figure 4.3 Inheritance hierarchy of Room ................................................................................................................... 60 Figure 4.4 Plugin icon under the Add-Ins ribbon ........................................................................................................ 61 Figure 4.5 Code script for creating the plugin button .................................................................................................. 61 Figure 4.6 Manifest code for declaring a plugin at Revit ............................................................................................ 61 Figure 4.7 Code script for getting Revit application handle ........................................................................................ 62 Figure 4.8 Parameter for access to Revit data .............................................................................................................. 62 Figure 4.9 Constant and input value comparison (Code) ............................................................................................. 63 Figure 4.10 Constant and input value comparison (Result) ......................................................................................... 63 Figure 4.11 Dialog for selecting the standard file ........................................................................................................ 63 Figure 4.12 Code script for creating dialog and filter .................................................................................................. 64 Figure 4.13 Excel form of standard file ....................................................................................................................... 64 Figure 4.14 Code script for retrieving room property .................................................................................................. 65 Figure 4.14a Example for room analysis ..................................................................................................................... 66 Figure 4.15 Code script for collecting lighting fixture in a specific room ................................................................... 66 Figure 4.15a Bounding box example. .......................................................................................................................... 67 Figure 4.16 Code script for calculating total lighting power in a specific room .......................................................... 67 Figure 4.17 Code script for result display .................................................................................................................... 68 Figure 4.17a Code script for accessing to linked model .............................................................................................. 68 Figure 4.18 Code overview for SDAN ........................................................................................................................ 69 Figure 4.19 Meaning for each alphabet of electrical equipment .................................................................................. 70 Figure 4.20 Code script of Find level id ...................................................................................................................... 70 Figure 4.21 Family and family type in Revit ............................................................................................................... 71 Figure 4.22 Syntax of new family instance method in Revit API ............................................................................... 71 Figure 4.22a Code script of Getsymbol function ......................................................................................................... 71 Figure 4.23 Code overview of tag analysis .................................................................................................................. 72 Figure 4.24 Structure of string ..................................................................................................................................... 72 Figure 4.25 Test code for string truncating .................................................................................................................. 73 Figure 4.26 Result of string truncating ........................................................................................................................ 73 Figure 4.27 Code for getting level number from a string ............................................................................................ 73 Figure 4.29 Result of tag analysis ................................................................................................................................ 74 Figure 4.30 Workflow of the main program ................................................................................................................ 75 Figure 4.31 Equipment type and representative code .................................................................................................. 75 Figure 4.32 Family and family type in Revit ............................................................................................................... 76 Figure 4.33 Equipment list .......................................................................................................................................... 76 Figure 4.34 Mark illegal tag in the equipment list ....................................................................................................... 77 Figure 4.35 Room serial number in HED project. ....................................................................................................... 77 Figure 4.36 Code script for locating equipment .......................................................................................................... 78 Figure 4.37 Syntax of new family instance method in Revit API ............................................................................... 78 Figure 5.1 Plugin icon under Add-Ins ribbon .............................................................................................................. 79 Figure 5.2 Room and lighting fixture parameters ........................................................................................................ 79 Figure 5.3 Excel form of standard file ......................................................................................................................... 80 Page | 9 Figure 5.4 The result of program execute .................................................................................................................... 80 Figure 5.5 Conclusion .................................................................................................................................................. 80 Figure 5.6 Program test in the linked model ................................................................................................................ 81 Figure 5.7 LPD tool execute result in linked model .................................................................................................... 82 Figure 5.8 Equipment list ............................................................................................................................................ 83 Figure 5.9 Floor plan of the test model for SDAN ...................................................................................................... 83 Figure 5.10 3D view of the test model for SDAN ....................................................................................................... 84 Figure 5.11 Error message ........................................................................................................................................... 84 Figure 5.12 Code script to activate family symbol ...................................................................................................... 84 Figure 5.13 Result floor plan 1 .................................................................................................................................... 85 Figure 5.14 Result floor plan 2 .................................................................................................................................... 85 Figure 5.15 Equipment list .......................................................................................................................................... 86 Figure 5.16 Warning message ..................................................................................................................................... 86 Figure 5.17 New equipment for test ............................................................................................................................ 87 Figure 5.18 Expansion of equipment claim ................................................................................................................. 87 Figure 5.19 Test of expansion of equipment list (1st floor) ......................................................................................... 87 Figure 5.20 Test of expansion of equipment list (2nd floor) ....................................................................................... 88 Page | 10 Chapter 1 Introduction This chapter introduces common modeling tools in the area of building electrical engineering. It also gives an overview of electrical engineers’ work content and flow. Finally, it discusses the potential way to improve engineers’ work. 1.1 Building Information Modeling In building electrical engineering, the most two kinds of widely used modelling tools are AutoCAD and Revit (Figure 1.1, Jon Peddie). AutoCAD is the abbreviation of computer-aided design. It is developed by Autodesk and widely used in 2D modeling by architects, engineers. While Revit is a building information modeling software that also developed by Autodesk. Comparing with AutoCAD, Revit allow users to create 3D model and access building information from the 3D model. Generally, AutoCAD is more suitable for schematic design, and many senior engineers are accustomed to it. The industry is moving towards the use of BIM over CAD. Figure 1.1 CAD company Market Shares. Data from Jon Peddie Research: https://www.pddnet.com/news/2015/04/cad-market- returns-growth-reaches-8b-2014 1.1.1 2D and 3D modeling Modeling software for the construction instruction industry has generally transformed from two- dimensional CAD (computer aided drafting) to three-dimensional modeling and currently to building information model (BIM), 3D models with information attached to parametric components. With CAD, architects and engineers modelled the building in 2D. Building elements were expressed in 2D plans, sections, and elevations. AutoCAD was, and still is, a commonly used software program for 2D modeling. However, 2D model limits the expression and function. For example, a 2D model has a weak performance on the vertical surface, for example plans and sections have to be drawn separately, and it is possible that they might not agree with the plan. In order to clarify the detail of vertical surface, many vertical sections are required. Page | 11 With the advantage of BIM, the building industry including architecture, engineering, construction, and facilities management has entered into a new era. Building information modelling was developed for helping owners, architects, and contractors to design, manage, and maintain building. It is a 3D modeling process that changes how architects and engineers work (Sebastian, Rizal 2011). A basic improvement is on modeling in 3D. With the additional dimension, engineers can express more information in the model easily. For example, engineers could simply get the vertical information by creating vertical sections; in the 2D modeling, they have to create it separately. At the same time, since elements under different subject are created above the same model and all elements are three- dimensional, pipeline conflict detection could be inspected easily. Engineers just need to refer to pipeline of other subject and adjust to avoid conflict, while in the 2D modeling software, engineers have to sit together and negotiate the pipeline route. Additional section views are required for expressing pipeline arrangement clearly (Figure 1.2). Figure 1.2 MEP pipeline in BIM model. Tesla CAD Solutions. (2014, March 10). Latest BIM trends across AEC industry Retrieved from: http://www.teslacad.com.au/blog/latest-bim-trends-across-aec-industry For example, for a switch board in AutoCAD, most of the properties are about geometric information, such as color, position, and line type (Figure 1.3). They only concern the appearance of the object. For expressing more information about the object, engineers usually put annotation close to the object or sometimes create other views such as panel schedule. Therefore, the object and the information about the object is separated with geometry and text. However, even for geometry, the 2D modeling limited the ability to express the detail of the object. Actually, engineers do not create a symbol like the real component, they create a symbol to represent the component. The symbol does not reflect the geometric characteristics of the object. Page | 12 Figure 1.3 Legend and parameter of switch board in AutoCAD While in Revit (similar to other BIM software programs), there are more details for the switch board (Figure 1.4). In terms of geometry, the Revit object not only reflects the size, but also the appearance characteristics such as the metal frame. Moreover, the geometry object also includes lots of electrical data, such as circuiting information or total apparent load. In this case, the object is not just a symbol of an object, but a real component in the virtual space. The parameter is able to be accessed by Revit API, therefore, various Revit Plugins could be developed. Another example is a lounge plate, which every button and screen is detailed in the model (Figure 1.4a). Figure 1.4 Legend and parameter of switch board in Revit Page | 13 Figure 1.4a Revit lounge plate. Retrieved from: https://www.bimstore.co.uk/bim/Slimline-Lounge-Plates 1.1.2 Level of development The “Level of development” (usually short for LOD) is used for descripting the level of detail in the digital model (Figure 1.4b). The “detail” includes both geometric and numerical data, depending on calculation or operation requirement. Traditional electrical 2D CAD model only includes the model in LOD 100. The object in CAD model is just a conceptual model and described by the text in various aspect such as power, name. But there is no connection between the information and the object. The text is just put near the object to show the affiliation. While BIM model is in a higher LOD, that information is embedded in the model. Based on the model status, the model can be classified in 5 types (AIA, 2014). LOD 100 Conceptual: In this development level, the model maybe represented by symbol or other generic representation. It only contains basic information such as area, height, volume, location (AIA, 2014).. LOD 200 Approximate geometry: Based on LOD 100, the model improves its detail such as quantities, size, shape, location. Besides, the model may also include non-graphic information such as text. (AIA, 2014). LOD 300 Precise geometry: Compare to the approximate parameters in LOD 200, the model in this level has accurate details in geometry (AIA, 2014). LOD 400 Fabrication: Model in this level not only has precise geometry detail, but also assembles complete fabrication information and installation information (AIA, 2014). LOD 500 As-built: Model in this level is a field verified representation accurate in terms of size, shape, location, quantity (AIA, 2014). Page | 14 Figure 1.4b Image of level of development. Retrieved from: https://thebimhub.com/2016/09/10/dangers-of-blur-model- deliverables/#.Wua8PIjwaUk 1.1.3 BIM application in construction management BIM provides various information for contractors. For example, walls, doors, windows and other objects can be scheduled. Such complete material information benefits cost management for contractors. Moreover, BIM has an interface for exchanging data with other software for monitoring equipment making it possible for engineers to check equipment status such as the transformer’s temperature and load rate, air-conditioner’s output power and other equipment’s critical parameters. Thus, troubleshooting unusual equipment behavior is possible, thus reducing the possibility of system failure. Therefore, facility management could be enhanced by BIM in several aspects: Cost analysis: with the help of schedule, all building materials can be counted, then total material cost can be estimated by the schedule. Facility maintenance: the equipment status could be detected. Such as in MEP design, Revit can estimate water or air velocity, electrical load. Any irregular operating status can be detected and improved in early stage, that makes system more robust. Pipeline arrangement: with precise 3-D model, pipeline of different system such as electrical, plumbing could be arrangement more efficient, and also help avoid collision. 1.1.4 BIM simulation Simulation with BIM is possible. Unlike in most 2D modeling software programs, engineers are a capable of expressing interior detail of a building by real time rendering in BIM. There exists software which could use the game engine generating refined picture and even allowing engineering control the view or environment, such as weather or season, in the model by their own. More advanced features like virtual reality in rendering that makes people feeling they were not standing at the front of a computer, they were actually standing in the building. Such simulation changes people’s visual experience. Moreover, BIM is also specialized in energy and daylight simulation. For example, the Autodesk company provides the software Insight for cloud simulation services that allowing clients simulating building online and getting energy consumption predictions, façade performances, and building optimization suggestions. (Figure 1.5). Page | 15 Figure 1.5 Autodesk cloud simulation interface. Retrieved from: https://insight.autodesk.com/oneenergy/Sample/Model/31390 1.2. Revit programming: Dynamo and the Revit API Revit allows both textual programming by Revit API and graphic programming by Dynamo in order to add features to the software. 1.2.1 Dynamo Dynamo is a visual programming software. It enables users to work within a visual programming process wherein they connect elements together to define the relationships and sequences of actions that compose custom algorithms. Then, they can use algorithms created by their own for a wide array of applications from processing data to generation geometry. Combined with Revit, it helps designers to solve lots of complex tasks such as generating a 3D city model or parametric complex building shapes. In Dynamo, a visual program consists of many nodes. Each node achieves a function. Dynamo provides various node with different function. While it is also possible to build a new node in Dynamo. The following is an example of how to creating custom node (Figure 1.6). The custom node defined two input numbers. It will calculate the percentage of these two numbers. After publishing, this node can be used in Dynamo directly (Figure 1.6a). Custom node is good way to expand the function of Dynamo. Figure 1.6 Creating a custom node Page | 16 Figure 1.6a Test result for the custom node In electrical engineering, several scripts have been developed using Dynamo. For example, Benchmarq.Ltd developed a program for adapting electrical wiring and panel schedules in Revit into UK industry standard (Pippa, 2016). Every county has its own standard of information expression. For instance, three-phase electric power is a common method of alternating current electric power generation and distribution. When representing each phase of electric system, in US, uppercase letters A, B and C are used to representing each phase, while in Europe, R, S and T or L1, L2 and L3 are widely used (Figure 1.6b). Figure 1.6b Three-phase representation in US. retrieved from: USC Facilities Management Services, HER project. When UN companies cooperate with US companies, the UN standard needs to be transformed to the US standard expression. Benchmarq.Ltd achieved this target by writing a Dynamo program (Figure 1.7). The program creates a new shared parameter that used to label wires based on UN standard, such as A2, the second electrical circuit in A phase, would be changed into 2L1. Page | 17 Figure 1.7 Dynamo program for adapting UN electrical expression standard. retrieved from: http://www.bmarq.co.uk/electrical- wiring-panel-schedules-revit-tutorial/ Another example is the MEPover package that was created by BIMstallatie (https://bimstallatie.sites.google.com/site/bimstallatie/). This package offers some nodes for electrical engineering, such as the node Electrical circuit get Panels and Elements (Fig 1.8). This node retrieves the panels and elements that belong to the selected electrical circuits, which help to analysis the status of the selected circuit when the circuit is pretty longer than usual such as some time the element in different floors belongs to the same circuit. Figure 1.8 The node of Electrical circuit gets Panels and Elements. Retrieved from: https://bimstallatie.sites.google.com/site/bimstallatie/dynamo/mepover-package#TOC-ElectricalCircuit-get-Panels-and-Elements This node contains some functions that could not be covered by original node in Dynamo. Therefore, programmers use Python for developing this node (Figure 1.9). That is a feature of Dynamo that allows developer to create their own node, therefore, expanding the function of Dynamo. Page | 18 Figure 1.9 The python scrip for developing the node of Electrical circuit get Panels and Elements. 1.2.2 Revit API Revit API is the abbreviation for Revit Application Programming Interface (API), a set of subroutines and tools that allows users to customize command functions. It is designed to reflect the same user interaction paradigms as the program’s graphical user interface. In the graphical user interface in the Revit modeling program, an object is displayed as a 2D or 3D model; in the Revit API, an object is expressed in text. For example, the following code shows the method to create wall by Revit API (Figure 1.9a) (Figure 1.9b). Figure 1.9a Code script for creating wall Page | 19 Figure 1.9b Result of code execute An important help file of Revit API is the Revit SDK (software developer kit). Revit SDK is provided by Autodesk and includes lots of sample code. The Revit SDK also explains the syntax to operate every element in Revit. Every element is represented by a class in Revit API. For example, cable tray is represented by cable tray class in Revit API, and Revit API provide lots of method to operate such as create method, which means creating a new instance of cable tray (Figure 1.10). Also, the Revit API provides properties of every instance such as Id, the unique identified for an element in Revit (Figure 1.11). Therefore, with Id, users could find a specific element in Revit and edit change the element with the method. Such feature allows automatic control in Revit. Figure 1.10 Methods of cable tray in Revit API. Retrieved from: Revit SDK Page | 20 Figure 1.11 Properties of cable tray in Revit API. Retrieved from: Revit SDK Revit API works at the .NET framework, a software framework developed by Microsoft that runs primarily on Microsoft Window and provides language interoperability. There are various types of programming languages working with the Revit API, such as C#, VB.NET, Ruby, and Python. The most widely used programming language for these applications is C# (Kristian Parsons 2010). The majority of SDK samples are in C#, and the majority of online examples are in C#. Even the recommended programming language of Autodesk company is C# (Autodesk Revit Kepler API). Add-in or plugin is a software component that adds a specific feature to an existing computer program. When creating a Revit add-in, or any .NET application, a complier that can convert program code and compile into a EXE or DLL file as required. One compiler for C# is Visual Studio. In a basic program package, it may contain a single EXE file and may be accompanied with one or more DLL file (Figure 1.12). EXE means executable program. An EXE file contains an entry point or a similar part in the code where the operating system is supposed to begin the execution of the program, which indicates EXE could be executed on its own. Figure 1.12 Difference between DLL and EXE format Page | 21 DLL stands for Dynamic Link Library. A library is a collection of software that is made available for programs to use (Leo A. Notenboom, 2012). That means that when running a program, such as an EXE file, the program might load additional DLLs to make up the program. For example, in the Revit.exe case, the add-in manager plugin is placed in a separate DLL file that Revit.exe loads it every time at the startup or when using this plugin. Every DLL corresponds to a function in Revit.exe. Generally, a software is broken up into or provided as an EXE and a collection of DLLs. Launching an EXE means creating a process for it to run on and a memory space. This is necessary in order for the program to run properly (Ben Joan, 2011). Since a DLL is not launched by itself and is called by another application, it does not have its own memory space and process. It simply shares the process and memory space with the application that is calling it. Such structure executes a EXE program with the minimum memory space and maximum function. 1.2.3 Revit programming: two examples There are various application scenarios for Revit programming for the electrical engineer. For example, a program developed to run inside of Revit could help to calculate voltage drop. By writing and running an additional program, the engineer has added functionality to Revit while taking advantage of all the existing features of the program. In the example, during the power transfer, based on the ohm’s law, the voltage will be reduced due to the resistance of the wire. Therefore, the voltage of the load, which located at the end of the wire, is always lower than the voltage at the power source. If the voltage drops too much that the voltage at the load is 5% lower that the nominal voltage, the appliance could not work in good condition, such as the lamp is darker than usual or a motor is less powerful. Therefore, voltage drop is an important factor to assess the quality of power supply. Voltage drop relates to the length, size and material of the wire. The longer the wire is, the more voltage drops during the energy transfer through the wire. Lager section of the wire has a low resistance. Besides, each kind of material has different resistivity. For example, the resistivity of silver is lower than copper, therefore with the same length and size, the total resistance of the wire made by silver is lower than that made by copper. In AutoCAD, the material and size of a wire could be recorded very easily, but the length of a wire is more difficult to calculate. Because a wire may be broken both in vertical and horizontal in the plan, since the wire is not an entire object, engineers have to measure the length of each wire fragment in every plan and add them together. Otherwise, engineers could only make a rough estimation. While in Revit, since every object has parameters. The length of a wire could be tracked very easily. The size and material is also recorded in parameter. It is possible to calculate the voltage drop of a wire automatically since all the data exist in Revit. Design Master Software, Inc. has already developed a plugin to finish the task (Figure 1.13). The plugin retrieves the data from Revit, calculates the voltage drop based on an internal formula, and generates the result in a schedule. Page | 22 Figure 1.13 Voltage drop calculating software by Design Master Software, Inc. retrieved from: http://www.designmaster.biz/revit/voltage-drop.html Another example is a plug-in for the branch circuit breaker and wire sizing. When a distribution system runs, the electrical power transfers through the wire. The size of wire is determined by the amount of the load. As the load increases, the current in the wire increases. Due to the current thermal effect, if the resistance of the wire is too high, the temperature of the wire would increase to burn the wire. Therefore, a large load would be powered by large section of wire to decrease the thermal effect. It is not economic to increase the section of wire unlimited, because the price of a wire increases rapidly as the section increases. The branch circuit breaker is used to protect the branch wire when default happened. When the current going through the breaker exceeds the rated value for a specific time, that would trigger the breaker to cut off the current to protect the branch from overheat. The rated current of the circuit breaker is also determined by the branch load. However, the rated value could not be too high, because if the rated value is too higher than the branch load, when overload happens, and the wire suffered the overheat generated by the overload, the breaker would not cut off the current, since the breaker would treat the overload as common load. On the other hand, the rated value could not be too low, because if so, even the load work under normal condition, every electrical factor runs well, the breaker would cut off the current, because the breaker would treat the normal current as an over load. Therefore, the breaker will affect the normal operation of the brunch. In electrical engineering, there is a standard for the selection of the rated current of a circuit breaker and the size of a wire. Each appliance is counted into the branch load, and based on the load, one selects the correctly rated circuit breaker. Since there are numerous electrical circuits in a project, the work is tedious. Moreover, the amount of appliance in a branch is always changing during design process, the Page | 23 rated current of circuit may have to change according to the appliance. Using AutoCAD, the selection is usually processed in Excel or through a schedule. Every time the data changes, the Excel spreadsheets need to be changed by engineers. While, in Revit, since the electrical information includes the apparent load of the branch where a component located, once the appliance changes, the parameter of a breaker or wire changes. Based on the new parameter, the selection could be made. Since data could be retrieved, this selection process could be made into program (Figure 1.14). Figure 1.14 Branch Circuit Breaker and Wire Sizing by Design Master Software, Inc. retrieved from: http://www.designmaster.biz/revit/branch-circuit-breaker-si.html 1.3 Building Electrical Engineering Building electrical engineering is the branch of engineering that deals with the technology of electricity about building. Some important terms are power engineering, single line diagram, electrical plan, and Title 24. 1.3.1 Power engineering In electrical engineering, power distribution is how electricity is produced by a power plant, transferred and transmitted in the grid, distributed, and used by final user such as a resident. The scope for electrical engineering is extremely large while building electrical engineering only concentrates on the how electrical power is distributed and used in building. For the general electrical consultant, the “building” usually refers to civil architecture such as a shopping mall, office building, apartment, or a stadium. Electrical engineers cooperate with architects to decide the location of an electrical equipment room, design the route of electrical pipeline, and define the requirements of electrical equipment. Manual work still occupies lots of electrical engineers’ time. 1.3.1.1 Electrical system Generally, the duty of electrical engineer is building a path to transit the power from power source, either from municipal power system or from other sources, to the load. Page | 24 1.3.1.2 Power source Electrical power can be classified into two types: municipal power and backup power. Municipal power is kind of power source operated by a municipality, county, state, or other public utility body such as public utility district. They are governed locally and operated to provide an essential service at reasonable rates. It serves for anyone who is access to the power and has a demand for electrical power (The Regulatory Assistance Project, 2011). For most dwellings and small stores, they only have one municipal power, it is not economic efficiency for protecting the continuity of power supply for common residential building. But for large public building, the suddenly loss of power may cause huge injure. For example, for shopping center, it would result in people’s panic of dark, for hospital, the power loss of important medical facility may kill people, and for data center, data loss would happen during power outage. Therefore, generally there would exist additional electrical power source, such as diesel generator which serves for the loads that are not restrict about the continuity of power supply, or uninterruptible power supply (UPS), which generally serves for data center where even tiny loss of power would cause huge damage (Figure 1.15) (Figure 1.16). Figure 1.15 UPS. Retrieved from: https://www.amazon.com/APC-Smart-UPS-1500VA-Battery-SMC1500/dp/B007ZT2KKM Figure 1.16 Diesel generator. Retrieved from: https://subbcourier.com/shop/electrical-power-supplies/power-generation- generators/prime-power-diesel-generator-set-rated-275kva-220kw-caterpillar-3406/ 1.3.1.3 Power distribution Engineers have to distribute the power from power station to the load (Figure 1.17). The distribution system usually starts with transformer that transforms the voltage of power source into 480V which could be directly used by motor appliances. Then, switch panels are used for controlling the on and off for each distribution path. Besides, the switch panels would cut off particular load when breakdown, such as short Page | 25 circuit and overload, happened to avoid further damage. Power flows through cable or busbar to the load. At the terminal, an additional transformer would be used to transfer 480V into 208/120V, since most of the appliances work under 208/120V. Figure.1.17 Electrical power distribution system A single line diagram is an abstraction of the system, of how the power distribution system works in a building. 1.3.2 Single line diagram & electrical plan A building electrical system consists of various type of electrical components such as transformers, circuit breakers, motors, capacitors and bus bars. The number of components is enormous. To express the whole electrical system clearly and simply, single line diagrams (SLD) are widely used to represent the distribution system in electrical engineering (Figure 1.18) All the elements are represented by standardized schematic symbols (Figures 1.19 – 1.22). But the single line diagram only expresses how the electrical system works and forms, which means that the SLD only concerns about how many components exist in the system and what the components are; the SLD does not have the function to express the location of the components. Page | 26 Figure 1.18 Single line diagram. Retrieved from USC Facilities Management Services(FMS) HED project Figure 1.19 Symbol for transformer in SLD. Retrieved from: https://www.alibaba.com/product-detail/BETA-ABB-AND-ASTOR- POWER-AND_177586205.html Figure 1.20 Symbol for breaker in SLD. Retrieve from: https://www.schneider-electric.us/en/product-category/50300-circuit- breakers/ Figure 1.21 Symbol for motor in SLD. Retrieved from: http://www.baldor.com/brands/baldor-reliance/products/motors/ac- motors Page | 27 Figure 1.22 Symbol for ground in SLD. Retrieved from: https://www.voltimum.co.uk/articles/q-day-why-have-160-ohms- disappeared Generally, in a BIM project, the architects will provide the architecture model to the electrical engineer. Electrical engineers link their files to the provided model and draw on it. They place electrical equipment at appropriate positions, decide the route of bus bars and pipelines, and annotate all elements. That is how the electrical plan is created (Figure 1.23). The electrical plan answers the question of where the components are. The electrical plan combines with SLD offering contractors a full view of the whole power distribution system. These are crucial in building electrical engineering. Figure 1.23 Electrical plan. Retrieved from USC Facilities Management Services HED project However, the final electrical plan must rely on engineers’ manual work. Electrical engineers have to find the exact position, pick up corresponding equipment, and place it. As the scale of projects become much large, such work becomes more tedious and fallible. There is an opportunity for a software tool to help engineers draw partial of the electrical plan based on the SLD automatically. 1.3.3 Title 24 Another task that electrical engineers work on is Title 24 compliance. Title 24 is the building energy efficiency standards issued by the California Energy Commission. It is designed to ensure new or existing buildings achieve energy efficiency and preserve outdoor and indoor environment quality. The standards are compulsory (Nonresidential Compliance Manual, California Energy Commission, 2016). Various aspects of building performance are stipulated in Title 24 such as the building envelope, building HVAC, water heating, nonresidential, and residential lighting and solar. Among all the aspect of building performance, electrical engineers concern the lighting the most, more specially, is lighting power density. Title 24 has different LPD value requirements toward different types of space (Table 1.1). LEED also das a requirement for LPD. The exterior lighting power density shall not exceed those specified in ANSI/ASHRAE/IESNA standard 90.1-2007 (USGBC, 2018). Page | 28 Table 1.1 Complete building method lighting power density values. Retrieve from: Title 24 Table 140.6-c, http://www.energy.ca.gov/2015publications/CEC-400-2015-033/CEC-400-2015-033-CMF.pdf TYPE OF BUILDING ALLOWED LIGHTING POWER DENSITY (WATTS PER SQUARE FOOT) Auditorium Building 1.4 Classroom Building 1.1 Commercial and Industrial Storage Building 0.6 Convention Center Building 1 Financial Institution Building 1 General Commercial Building/Industrial Work Building 1 Grocery Store Building 1.5 Library Building 1.2 Medical Building/Clinic Building 1 Office Building 0.8 Parking Garage Building 0.2 Religious Facility Building 1.5 Restaurant Building 1.1 School Building 0.95 Theater Building 1.3 All other buildings 0.5 Lighting power density is a parameter describing how much lighting power a specific area has received. The computational formula is LPD= Lighting Fixture Power/Area. Generally, lighting could be divided into two parts, task lighting and decorative lighting. Task lighting is a lighting method used for specific activity, such as pendant lighting above a desk. In this case, all the power of lighting fixture should be taken into consideration for LPD calculation. While, decorative lighting is a type of lighting used for embellishing indoor or outdoor space, such as sconces or chandeliers. When calculating this type of lighting, Title 24 gives additional power allowances. For example, the allowed general lighting power for malls is 1.2 W/ft 2 , and additional power allowances for decorative lighting is 0.5W/ft 2 , which meaning, if general lighting power is under 1.2W/ft 2 , the total general lighting power and decorative lighting could be 1.7W/ft 2 (Table 1.2). Table 1.2 Retail-specific Selections from the Allowed Lighting power table. Retrieved from: Title 24, 2013, part 6, Retail lighting Page | 29 Electrical engineers do not pay much attention to the lighting performance such as accent lighting or ambient lighting. This part of work usually finished by lighting designer, but they must do the LPD calculation for the spaces. 1.4 Electrical improvement topic The wide use of BIM and the potential for programming new features brings new possibilities to liberate electrical engineers from the daily routine of repetitive tasks. There are three potential topics for enhancing building electrical engineering that are about single line diagram, LPD energy calculations, and lighting engineering. 1.4.1 Single line diagram For every electrical element in the SLD, there should be one corresponding equipment placed at electrical plan. As the project scale growing larger, placing electrical elements to its proper position usually is easy to be omitted. Thus, electrical engineers are eager to get a program that can generate equipment at its correct position automatically once it was represented in SLD (Figure 1.25). By applying such program, a large amount of manual work could be saved and finished automatically. Figure 1.25 Current work flow in electrical engineering Page | 30 1.4.2 Energy evaluation In California, all the buildings must comply with Title 24 including staying below the mandated lighting power density. For electrical engineers, they have to assess whether a project meets the requirement of Title 24 by manually calculation. A possible method to improve their work is writing a program that internally including Title 24 and assessing the building automatically. For example, Title 24 has a strict requirement towards lighting power density (LPD) based on space function. In order to assess LPD automatically, the first step for the Revit program is to read a room schedule and get the area and function of this room. Then, figure out the total number and power of all the lighting fixture in this room. Finally, calculate the LPD based on collected data and making comparison of the result with the requirement of Title 24 and showing the result of whether changing lighting fixture is required. Other aspects of Title 24 could also be assessed in similar method. In this way, large amounts of manual work could be avoided. 1.4.3 Lighting engineering Lighting engineering focuses on the providing appropriate illumination for a building, house, etc. Generally, the result would be assessed in two aspects. The first is the performance, such as whether work place get enough light and whether the light distributes evenly. Another aspect is energy consumption, because standard such as Title 24 set a maximum value for LPD. Lighting design process would be finished by professional lighting engineer. For electrical engineer, their task is circuiting the lighting fixture in lighting plan for supplying the power (Figure 1.26). However, there are currently problems that exist for this workflow. Figure 1.26 Lighting plan. Retrieved from USC Facilities Management Services(FMS) HED project Cooperation between different architecture firms has become widespread. Since they have individual component libraries, collaborative problems arise. For example, in the lighting engineering, the lighting Page | 31 design and electrical design is usually finished by different company. A common work flow is after the lighting consultants finishtheir work, a model which includes all the information about light fixtures’ position and electrical parameters is provided for electrical designer. Then the electrical designer links the provided model and replaces the fixture symbols with their customized format. Then connecting all the lighting fixtures together to make they into one circuit. If a program could help them circuit in the link model directly, electrical engineers are not required to replace fixture symbols and all the changes that lighting consult have made will be reflected on electrical engineers’ model immediately. A standardized library could save engineers time. 1.5 Summary As building projects become large in scale, the electrical system becomes more complex, while design effort still counting on manual work. Automating the process in BIM could reduce drudgery, increase efficiency, and increase accuracy, specifically for the subfields of the electrical plan drawing, lighting, and energy assessment. While comparing to the traditional 2D model, the parametric object in current BIM model includes the information required for the plugins. Revit also provides programming tools such as Revit API and Dynamo for creating the plugins. Therefore, it’s possible to automate the lighting power density assessment and equipment placement. The following chapter will discuss the coding process of the plugins. Page | 32 Chapter 2 Background Research This chapter introduces the characteristic of each program method in Revit API. Data exchange are enabled with the help of C# code script. Therefore, they are many commercial Revit plugin developed to benefit engineers’ work. This chapter also introduces other research related to this topic. 2.1 Revit programming tools Generally, there are 3 types of programming platform in Revit. Two of them are textual programming platform which users create program by writing texts. Another is visual programming platform that the program is created by manipulating program elements graphically. 2.1.1 Visual Studio Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft (Figure 2.1). Figure 2.1 DLL file creating process in Visual Studio When programming in the Visual Studio, first of all, users must add references. References are external libraries that contain various of objects, methods and classes. A class is a data structure that combines state such as property and actions such as methods in a single unit. For Revit API, even there are various of classes in Revit API, Visual Studio could not use these classes without claim. Room class is defined in Autodesk.Revit.DB.Element, therefore, the reference file of RevitDBAPI.dll should be added before editing room object in Visual Studio (Figure 2.2). Figure 2.2 Inheritance hierarchy of Room class. Retrieved from: Revit SDK After adding references, users develop their own script in Visual Studio. Revit API allows four kinds of programming language. These are C#, Python, Ruby and VB.Net. Among all these language, C# is the most widely used programming language in Revit API (Kristian Parsons 2010). After the coding process, if the code was compiled successfully, a DLL file would be created. Then there are two methods for running the DLL file. First, the DLL file could be executed by External Tools command in Revit. Under Revit Add-Ins ribbon, there is a command button called External Tools (Figure 2.3). By clicking on that, Revit start invoking Add-In Manager, which allows engineers to launch DLL files. In this case, the DLL file is a totally outside resource which means it is not registered in Revit. This method benefits the spread of DLL, because, users are not required to make further adjustments to Revit. Page | 33 Figure 2.3 Add-In Manager under External Tools in Revit Users also have another choice that converting DLL into Revit as a plugin. In this case, a manifest code is required for registering this program (Figure 2.4). The manifest code must be located in the Revit Add-in folder that under the system program data folder. During the process of Revit initiating, Revit will scan the system program data folder, checking the manifest code. Then for each manifest code, Revit will search the route that written in the code, get the DLL file. A program icon will appear under Add-in ribbon after Revit launched if the code script and the manifest code are created correctly. Once clicking the icon, Revit will execute the class registered in the manifest code. Figure 2.4 A typical manifest code for Revit In this case, the DLL is permanently attached to Revit unless users disabled it or the DLL file was removed. Unlike the first method where users have to load DLL file manually every time before executing the program, in this method user just needs to click on the program icon, the program will run automatically. It is friendly for users, but developers have to work more on coding. For example, for the DLL file LPD-test, it calculates total lighting power density of each space and compare it with given standard file (Figure 2.5). There are 2 ways to execute it in Revit. First, if execute it by External Tools, every time when user want to execute it, user have to click on the commend button, then select the file and run it. While, if make the DLL file into plugin, programmer need to add a manifest code, and add a short part of code to create a new commend button under add-in ribbon. Then when using it, users only need to click on the commend button instead of load DLL file. The result of these two methods is the same. But if such DLL file is frequently used, making the DLL file into a plugin will be more convenient. Page | 34 Figure 2.5 DLL file execute methods in Revit 2.1.2 Macro Another programming method is to create a macro. A macro is a saved sequence of commands that responds very quickly. Revit provides a macro manger that allows engineers to create and edit macros. Since Revit macros are also based on the Revit API, the syntax in a macro is almost the same as when programming in Visual Studio. The macro manager also provides similar programming interface with Visual Studio. Therefore, there are little barriers for Visual Studio programmer developing tools as Revit Macro. However, differences exist between macro and Visual Studio. A macro doesn’t generate a DLL file when building the code. Macro programming is more like the plugin creation process in Visual Studio. The system will distribute a unique code for each macro automatically during the creation, and if the code script built successfully, the function claimed in macro will appear at macro manager permanently, shows it is executable, just as the plugin icon in add-in ribbon (Figure 2.6). Although there are many advantages for programming macros, macros also have restrictions that limit their utilization. For example, only the void function is allowable for the main function in macro, while in Visual Studio, the main function could be command, application and void. Visual Studio provides more tools and possibility for developers. On the other hand, since programming in Visual Studio is still the most popular method, there are more tutorial resources online for beginners to learn Visual Studio. Page | 35 Figure 2.6 Macro creation and execute process 2.1.3 Dynamo The third programming method in Revit is Dynamo. Unlike programming by Visual Studio or Revit macros that are texted based, Dynamo is a visual programming method that developer creating programs by manipulating program elements graphically (Figure 2.7). Comparing to programming where the code script is all in text, the Dynamo program is constituted by code boxes where code was packaged in to achieve special function, such feature clarifies the program workflow. Moreover, each code box indicates input and output parameter, helping users comprehend component quickly. This can make it easier for users who are not adept at programming. Figure 2.7 Dynamo code box & C# script Here is a Dynamo script that creating a solid wall as the wall creation C# code that discussed in chapter 1 (Figure 2.7a - 2.7c). The code is intuitive such as every code block has clear input parameters and output parameters. With the connection of each code block, the programming logic is also easy to be understand such as how the points work to create lines even for a non-programmer. That are the advantages of Dynamo. Page | 36 Figure 2.7a Wall creation by Dynamo Figure 2.7b Created model in Revit Figure 2.7c Code script for creating wall by C# Page | 37 There is a similar software called Grasshopper in Rhino (a 3d modeling program) that is also a visual software program. For the users who have experience in Grasshopper, probably would be familiar with the interface of Dynamo and get used to the coding very quickly. Dynamo is specialized for parametric geometric analysis, including geometry data analysis and geometry morphing. Dynamo provides functions for users to access to the element, family and geometry component data in the Revit model, and users are able to do, solar study, and schedule management based on provided data. Because Dynamo is essentially a programming language and Python can be used with it, Dynamo applications have been built for a range of applications including geometric manipulation, heating and cooling load calculations, voice recognition for specific commands in Revit, structural beam sizing, stadium seating design, and many others. Because Dynamo allows the linear adjustment of component’s parameters, the shape of component could be changed based of the change of parameter. For instance, Dynamo could be used to analyzing performance of façade based on the solar (Figure 2.8, 2.9). As the sun moves, the angle between the law of each panel and the solar changes. The Dynamo program would make the panel changes based on the solar position. If the angle between the law of panel and solar is small, that means this panel is withstanding direct sun light. Therefore, without shading, the building in this direction gains much heat. While, as the panel in this project is parameterized component, Dynamo detects the angle and send it to the panel component, then the panel morphs in responding to the angles change (Figure 2.10). The panel rotates to keep the surface perpendicular to sun light, that block extra heat gain. Figure 2.8 Parameterized façade at 9:00 AM Page | 38 Figure 2.9 Parameterized façade at 1:00 PM Figure 2.10 Parameterized panel Dynamo also used for modeling. It can create points or line based on mathematical formulas, for example as shown in this model of a bridge (Figure 2.11). Page | 39 Figure 2.11 Golden Gate bridge model in Dynamo Dynamo also has a user-supported component library created by various authors. Though, Dynamo itself provides lots of node and function for programing, but original nodes are insufficient for design comparing to Grasshopper, which has various functions. Engineers could customize their own node by either writing Python script or combining existing nodes in Dynamo. Once, a new node created, it can be assembled into a package with other nodes, and upload online for other users to download and use it. Therefore, the package expands the function of Dynamo. In all, Dynamo is a programming tool focusing on terminal object. Comparing to plugins or macros, however, Dynamo has the smallest function scope while creating plugins with Visual Studio has the most potential capability at the current time (Figure 2.12). Figure 2.12 Function scope of Visual Studio, Macro and Dynamo 2.2 Revit Data This section introduces Revit objects and the way to retrieve information from Revit. 2.2.1 Revit object In Revit, every object contains data attributes, or more specifically in Revit terminology, properties. For example, once a room is created in Revit, all the geometric information is included in property windows Page | 40 such as the area, perimeter or height (Figure 2.13). No only visualized data (like a 3d model), but also the parameters that allow users to see and change the work space can be retrieved and adjusted by the programmer via the Revit API. Figure 2.13 Room parameter in Revit For instance, in Revit API, the room created in Revit is not treated as a geometric model, it is a class described by code script. Room object belongs to the spatial element in Revit API, therefore, if filtering out the element that is not belonging to the spatial element, the remaining elements are rooms. Revit API provides a room class package for programmers get access to the room topology in Autodesk Revit (Table 2.1). When programming in C#, as a room object was defined as a room class, its room property could easily be retrieved. Table 2.1 Important room properties in the Revit API. Property Area The area. Document Returns the Document in which the Element resides. Id Returns the Document in which the Element resides. Level Gets the level of the room. LevelId The id of the level associated with the element. Name A human readable name for the Element. Number The number. Perimeter The perimeter. Volume Get the Volume of the Room. A section of C# code script demonstrates getting access to the room properties Name and Area in the Revit API (Figure 2.14). At first, the program defined a collection (a set of objects) that filtered out all elements except the spatial element in the previous document. Next, each spatial was defined as room class. In this case, adding a postfix following the room class could get the corresponding property. Here Page | 41 the room name was assigned to the string parameter, while the room area was assigned to the double parameter. Figure 2.14 Sample code for retrieving room property in Revit API 2.2.2 Information exchange Revit also allows users to import outside Excel data. There is a Microsoft.Office.Interop.Excel reference that contains the methods used for interoperability with Excel. For example, a paragraph of code script is used for opening a specific Excel file under a file path and then get the data in Excel sheet and print in the Revit (Figure 2.15). The string path parameter stores the path way of the Excel sheet waiting to be opened and declares a parameter “Excel” that represent the Excel program. After that, the “Excel” parameter loads the file path that saved in the “path” and gets the Excel sheet saved into the parameter “ExcelSheet.” Next The code is retrieves the cell value at the first column from the first row to the fourth row. Finally, the cell values are presented in Revit in a task dialog window. The data in Excel can be retrieved very easily. This technique can be used for many uses that need to link to a spreadsheet, including examples like like code checking or structural calculations. Page | 42 Figure 2.15 Sample code for retrieving Excel data in Revit API 2.3 BIM based automated code-checking programming Every building within a jurisdiction has to go through process of legal requirement assessment, which is mostly based on a code compliance design check. The code usually set numerical value constraints or spatial requirements that may or may not require domain-specific analysis (Joáo Poças Martins, 2013). While LPD tool is kind of code compliance checking program that check whether lighting design meet the requirement of Title 24. Some of the research on this area can benefit the development of LPD tool. In the 60’s, Steven J.Fenves initiated the research on developing processors which convert decision tables or code into execution programs. As a result of his efforts and the efforts of those who followed him, significant progress was made in the building code standardization field. However, the resulting procedures remained mainly manual based (C.Eastman, 2009). With the widespread applying of CAD tools, and driven by the demand of constraint checking of designs in mechanical engineering, researchers began to investigate the possibility of automating the validation of building designs according to the enforced legislation. Generally, an automated rule-based checking program consists of four major steps: rule interpretation, building model preparation, rule execution and rule reporting (C.Eastman, 2009). The rule interpretation means converting human written rules into code script that could be understood by computer. Rules for building are first drafted by people and written in human language such as text, tables, or equations. These rules have legal status in building codes. In order to developing rule-based checking program, programmers have to interpret and translate the written rules into computer code. Page | 43 There is connection between human language and computer language. With Revit API, operation in human written rules can be translated into code script. Susmita Sinha gave several examples of language translation between human and computer (Table 2.2). Table 2.2 Information extraction step and corresponding API Functionalities. Based on Susmita Sinha, Extracting information from building information models for energy code compliance of building envelope Information extraction step Revit Built-In parameters and Methods; C# Methods for logical and arithmetic operations Inputs in User Interface Windows Forms; Class Libraries to run the code for DLL Project Description Element-ProjectInfo; Access in property of Document as Document.ProjectInformation Selecting Compliance Option & Climate Zone Through interface created by Windows Forms and Buttons. Switch-Case and If-Else conditions Constraint If-Else condition Extracting Thickness of component and dividing by Conductivity CompoundStructure.GetLayers()/ CompoundStructure.GetLayerWidth() Checking against threshold value For Minimum case/ Maximum case Reporting stored value result as Excel file Use of .csv format and unit conversions;XmlWriter For rule report, in Title 24 assessment process, the final report is the Certificate of Compliance which including the information of the project such as project name, project type (Figure 2.16). It records all lighting fixtures including the watt and number of each luminaire, and the total installed watt. Page | 44 Figure 2.16 Certificate of Compliance of USC HER project. retrieved from: USC Facilities Management Services, HER project. 2.4 Current Commercial plugin There are many plugins developed for ease engineers’ work in different aspects. Some of them start their business use. 2.4.1 (Conduits & Cable Tray) Hangers 2017 One plugin focuses on place hanger for conduits and cable tray. Its name is (Conduits & Cable Tray) Hangers 2017, developed by BIM SOFT SOLUTIONS. A conduit is a tube that used for protecting electric wiring, while cable tray is used for supporting insulated electrical cables (Figure 2.17 – 2.18). Both of them need hangers to sustain their weight. Usually, a cable tray is petty long. The length is the distance from the load to the power source, therefore, the cable tray needs many hangers to sustain. Usually the support span is a constant that less than the length of one section of tray (Unitray systems INC.). Therefore, placing hangers is a repeated work. While this plugin automates this process (Figure 2.19 – 2.20). Users could select the cable tray their wanted and place it on the element they are desired. The hanger would be automated placed along with the element with equal span. That can save lots of time. Page | 45 Figure 2.17 Conduit and hanger Figure 2.18 Cable tray and hanger Page | 46 Figure 2.19 Support span for cable tray. Retrieved from: Installation guide, Unitray System Inc. Figure 2.20 Hanger automate placing. Retrieved from: https://apps.autodesk.com/RVT/en/Detail/Index?id=8360862130945868351&appLang=en&os=Win64 2.4.2 Elum Tools Elum Tools is a fully integrated lighting calculation and visualization plugin for Revit. It is developed by Lighting Analysts, Inc. For this company, a famous software developed by it is Agi 32 (Figure 2.21). Agi 32 is a simulation tool used for lighting analysis and rendering. Engineers can customize the object surface, material, lighting fixture parameter, direction and other properties to test illumination performance. It is accurate that generating the illuminance in every point in the space, so it is widely used in illumination engineering. But it does have a strong 3D modeling function. The 3D model from Revit cannot be used by Agi32. While the function of this plugin is kind of transplanting Agi32 to Revit that allow designers to quantify light. For example, this plugin calculates the illuminance value of the ground at the simulation 1 (Figure 2.22 – 2.23). While, not only the result can be digitized, but also it can be visualized. In the simulation scenario 2, the result is range from blue to red, based on the height of illuminance (Figure 2.24). Page | 47 Chapter 3: Methodology 3.1 Introduction This chapter introduces the rational logic and workflow for creating tools and then discusses the process of creating Revit customization tools (Figure 3.1). Each customization tool was developed in Visual Studio individually. They have different programming concepts and different C# script, but they can be follow a similar workflow. Figure 3.1 Overview of methodology 3.2 Development tools All of the customization tools were developed in Visual Studio with C#. As has already been discussed, e C# is most widely used programming language in Revit API and has more tutorials and sample code. Visual Studio is a general C# complier. The tools were developed in Visual Studio with C#. 3.3 Customization tools Two tools were created. One was called SLD device automatic navigation tool (SDAN). Another was Title 24-LPD evaluation tool (TLE). 3.3.1 SLD device automatic navigation tool (SDAN) workflow As has already been discussed, electrical engineers have to create electrical plan based on the single line diagram(SLD). Electrical engineers have to read the SLD, check each component in the SLD, and place the components into the correct position. That is totally manual work and very time consuming. But there is a potential relation between the position of component and its attributes; once the attribute of the component was defined in SLD, the position of component was determined based on the attribute (Figure 3.2). Figure 3.2 Previous and proposed workflow of SLD device automatic navigation tools 3.3.2 Title 24-LPD evaluation tool (TLE) workflow The second tool developed was the Title 24-LPD evaluation tool. During the energy assessment process, electrical engineers have to check LPD of each space as to whether it meets the requirement. They must calculate the total power of the lighting fixture of each space, and get the area of space. Then dividing the total lighting power with the area, and finally comparing the result with the requirement of Title 24 to check whether it exceeds the standard value of Title 24. This process is also usually done manually. But, Page | 48 it is possible to automate this process, because all the data is existing in the BIM model, the program just needs to grasp all the data and process them (Figure 3.3). The processing logic is extreme simple, only some basic mathematical calculation. Figure 3.3 Previous and proposed workflow Title 24-LPD evaluation tool 3.4 Program development This section explains the critical logic of the tools, the data process in the tools and overall workflow. 3.4.1.1 Programming concept of SDAN The crucial point for creating the tool was how to make the computer understand where the electrical equipment should be placed. A navigator was required to tell the destination of the equipment. In electrical design, the hierarchy of equipment influences its position. Generally, due to voltage loss during electricity transmission, the distribution diameter is limited. For a large site, in order to keep the voltage stable at the end of the distribution system, the large site would be divided into serval small parts and get the power that would not influence others. Inside each distribution area, there would exist a power distribution room where the main panel box located. At the same time, the smaller area will be continued subdividing. For example, at a small apartment, probably that each story shares one distribution room. And each story will be divided into many individual units. Every individual unit needs a switch box to control the power of lighting, socket, and appliances. A common scenario is the switch box would be located within the unit that easy for residents to handle. That is a typical two levels of distribution system at the terminal of electrical system. The level of distribution equipment influences equipment’s position. A higher level is usually at power distribution room and equipment in secondary level locates at terminal space. For easy identification, architects give a serial number for terminal space with the same function. For example, apartment units will probably be numbered as 101, 102, 203 and etc. In this serial number, the first digital indicates in which floor units located, and the second and third number indicates the specific location of the room. Usually the equipment is unique in each floor. Therefore, for tracking a specific room in a building, four aspects of information are required. a. Number of floor level b. Area (usually defines by fire zone) c. Room’s function (name) d. Serial number All these four aspects of information are included in the architecture plan. The electrical engineers also need to assign the type of equipment such as the switch box, panel box, or control box. After assembling all the information, a specific electrical equipment can be located. That is the logic for the placement of the equipment for electrical engineering, and that is also how a navigator works. There were two ideas for creating a navigator that contained such five aspects of information. The first idea is when creating the SLD was to add extra attributes for defining the architecture and electrical information for locating each element. However, the new software should not increase the burden on the Page | 49 electrical engineer. If the information of each individual element need to be imputed manually, that makes no sense. A navigator should be generated naturally during electrical engineering design flow. For the second idea, the name of each equipment could serve as the navigator. There are several unique features for the name. 1. Equipment name is naturally generated during the design process. 2. Each equipment owns a unique name. 3. The name usually indicates equipment’s general location and function. Here is a project located in China. It is an office building. Inside the power distribution room, each equipment has its name, and actually the name has its principle (Figure 3.4). Figure 3.4 Power distribution equipment room For example: 1-G-n-AL-1 1. For the first digital “1”, because there are two office buildings in the project, in order to identify each of them, this tower was number as “1.” 2. “G” means the area or the function of this tower. Because This tower had two functions; the upper floors were a hotel while the lower levers were office space. Here “G” indicated the office. In the upper level, the hotel was mark by “H.” 3. “n” indicates the story. 4. “AL” represents the type of equipment. For example, here “AL” means panel box for general residents’ power. “AP” usually means the box giving power for motors. 5. The last digital “1” is the serial number. If more than one box has the same function, they would be identified by serial number. Besides, if the serial number does not contain dash, it probably belongs to the panel box, while if contains dash, it may be a switch box. In this case, the serial number of the switch box would generally equal to the room’s serial number. Based on these principles, even an electrical engineer had never saw the architecture plan, he would probably understand that “1G21Al-3” is a switch box located at 21 floors, room number 3 (Figure 3.5). In this case, the principle could serve as navigator guiding the equipment to specific place. Page | 50 Figure 3.5 Meaning of each alphabet of equipment’s tag 3.4.1.2 Program workflow for SDAN The program started with inputting SLD. After loading SLD, the program will be executed in several steps (Figure 3.6). Page | 51 Figure 3.6 Program workflow for SLD device automatic navigation tool Page | 52 3.4.1.2.1 Principle claim Since the navigator for the program is the equipment’s name, the meaning of the potential combination of the name need to be claimed. This including the meaning of each alphabet or digit and the sequence of all characters. Therefore, the first step for the program is to claim the meaning of equipment’s name. As what has been discussed, the floor, equipment function and serial number must have a corresponding alphabet or digit in name. 3.4.1.2.2 Logical judgement The core section of the program is to decide where the equipment should be located. After checking the validity of all electrical elements’ name, SDAN starts with selecting individual equipment. Then, it scans the whole architecture plans. If there exist rooms that coincide with the equipment, the program records it and counts how many rooms are coinciding with the equipment. Because sometimes architects may tag several rooms with the same name by mistake, engineers were unable to locate the position. Therefore, if more than one room matching single equipment, such case should be treated as error and record waiting for engineers dealing with manually. While, if only one room matching single equipment, that is a valid relevance and should be kept recorded. Then selecting the room and placing the Revit model based on equipment code name. After this step, a complete loop for locating equipment is finished. Next, the program will check whether there is still any equipment waiting to be located. If so, the program would go back to the start of this section and execute the loop again till all equipment finished. 3.4.1.2.3 Error correction In the last section, the equipment that marked with error during the second section would be retrieved and highlighted in the SLD, reminding engineers to locate all the equipment manually. After completing all three sections, the main program has executed to its end. Every electrical equipment had been scanned and located to the correct place. Chapter 5 shows a case study example of this workflow. 3.4.2.1 Programming concept of LTE There are three critical parameters in the LPD calculation: room type, room area, and total lighting power in the room. Room type determines the allowable LPD in this specific kind of space because different activities require different lighting level. For instance, a department store needs more lights on the product to attract customers (1.5 W/sq ft) or students need more lighting for studying in classrooms (1.1 W/sq ft). While there are also some areas that are not so strict with lighting, such as storage building (0.5 W/sq ft) or parking structure (0.2 W/sq ft), that the lighting level would affect their performance. Room area and total lighting power together determine the LPD in space. On a completed Revit model, these three critical parameters required for calculating LPD already exist. Engineers need to retrieve these data that exist in model and process them. The process is divided into two separate tasks (Figure 3.7). Page | 53 Figure 3.7 Data retrieval and process in LPD calculation The first task is retrieving Title 24 standard data from outside file. In the room properties, the tag indicates the function of this space. The program scans space properties and get the room type. Then the software scans the Title 24 standard file imported from outside source, and when the type of building in Title 24 standard equals the room type from model, the program seizes the data and keeps it. The second task is calculating LPD in space. Room area parameter could be retrieved from room properties very easily. While for total lighting power, the program has to check the number of lighting fixture which located within the space. At the same time, for each lighting fixture, the properties of lighting fixture in Revit includes the power. Therefore, summing up the power of each lighting fixture would generate the total lighting power in this space. 3.4.2.2 Program workflow for Title 24-LPD evaluation tool The program workflow for Title 24-LPD evaluation tool is much simpler. It consists of three components: input, LPD calculation, and results (Figure 3.8). Page | 54 Figure 3.8 Data retrieval and process in LPD calculation 3.4.2.2.1 Input standard Though the tool was designed for Title 24 standard, Title 24 keeps updating every year. The requirement of LPD value changes constantly. As Title 24 is a standard for California, in different states or country, there exist other standards. Therefore, reserving a place for changing the specific standard requirements is necessary. For example, instead of pre-input the standard value in the code, LTE allow user to sect an Excel file that including the type of room space and allowed its LPD. Based on the project, a different standard can be applied such as Title 24 or ASHRAE. In this way, LTE can be used in different locations or other states whose requirements are different. 3.4.2.2.2 LPD calculation After importing Excel files, the program finds the room area and name and retrieves the Title 24 standards from imported file based on the room tag. It then checks the lighting fixtures that are existing in the room and sums up the total power of lighting fixtures. By dividing the total power by room area, LPD is calculated. Page | 55 Then it compares the calculated LPD with the Title 24 standard. If calculated the LPD is under the standard, then the room meets the requirement. The room will be marked as passed, and the program will move to next space. If not, calculated LPD is higher than standard, the program would record this room, change the color of the space. The qualified space would be changed into green, while unqualified space would be change into red. If the room type does not exist in the Title 24, the room would be changed into blue. 3.4.2.2.3 Result Display When the main program executed to the end, all unsatisfactory room would be recalled, waiting for users’ adjustment. Reminding users to decrease lighting fixtures number or using high efficiency appliances to reduce lighting power. Chapter 5 shows an example of this process for a building. 3.5 Program assessment Though, these two tools have different function, since they are designed for electrical engineers, based on the characteristic of electrical engineers, they share the same criterion for effectiveness. The tools would be tested in different types of model with several evaluation criterions. 3.5.1 Case Study When electrical engineers create electrical plans, usually they link electrical elements with architect plans in two ways. One way is placing electrical elements directly in the local architecture plan. (Fig 3.9a). In this case, architecture property is readable and adjustable for engineers. Such scenario widely exists in the individual work or the small scale of projects which architecture plan usually would not change. Another way is placing element in linked model (Figure 3.10) This scenario usually appears on the large scale of projects where multi-specialty cooperation is required. Architecture plan changes frequently in this case. By linking the external model created by architects, electrical engineers are able to catch changes made by architects immediately, and adjust electrical plan. At the same time, engineers in other subjects are also able to link electrical model. Therefore, linked model benefits the information exchange between different subjects that contributes to cooperation (Figure 3.9). Figure 3.9 Workflow for coordinating architectural model and MEP model Retrieved from: https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Revit- Collaborate/files/GUID-6A5B3BBA-77FE-4CFE-9D0C-B347D5C402E2-htm.html 3.5.1.1 Local model Starting from the local model simplifier the research process, since architecture parameters are readable directly in the local model, the number of variable could be controlled and the validity of execute result could be checked easily (Figure 3.9a). The developing C# script would not be complicated. However, Page | 56 local model is less widely used in architect firm. It is kind of scheme research. By applying such kind of case study, a basic prototype of the program was created. Figure 3.9a Local model plan 3.5.1.2 Linked model Linked model is an advanced case study (Figure 3.10). Since linked model is more widely applied in real architecture design, the program must be effective in link model. In linked model, actually, engineers never create a real architecture model, they just load a model as a reference in their model. And once the model in the original route changes, the linked model will also change. Such feature enables distance cooperation. For example, architects create a model in cloud and engineers in other areas could link the model and create electrical plans or structure plans. However, the architecture information in linked model is locked, linked model users could change architecture parameters. Therefore, information retrieval method in linked model is different from the local model. Figure 3.10 Linked model plan Page | 57 3.5.1.3 Real project simulation The final stage is actually a real project simulation. During this stage, components created in step 1 and 2 were assembled into a final program. 3.5.2 Evaluation criteria The performance should be evaluated in four aspects: accuracy, responding speed, customizability, and simplicity. 3.5.2.1 Accuracy This is an essential requirement. The program should be able to locate the position of electrical equipment precisely. Therefore, if program really works, it should be able to read the mark of device and compare the mark with architecture plan, then find the right place for the device (Figure 3.11). Otherwise, the program is useless. Figure 3.11 Model assessment 3.5.2.2 Responding speed Waiting for a response of program is frustrating. Whether user experience is good or not depends on responding speed greatly. Generally, 0.1 second is about the limit for having the user feel that system is reacting instantaneously and 1.0 second is about the limit for user’s flow of thought to stay uninterrupted (Nielsen 1993). While 10 seconds is about the limit for keeping the user’s attention focused on the dialogue (Nielsen 1993). Therefore, responding less than 10 second may be a suitable time limit. Because engineers are highly focused during work. Responding longer than 10 seconds will distract they. That is not expected to happen. But, as project become larger, the amount of parameter increases, program has to take more time scanning the whole project. Responding time would expand. So, code optimization is important in program development. 3.5.2.3 Customizability Every company has its own naming principle. The principle works in this project does not mean it can be applied to another project. Meanwhile, predicting what kind of equipment will be used in a project is Page | 58 difficult. Therefore, the program must have expansibility that allowing engineers customizing name principle based on their own requirement and adding new type of new equipment whenever they want. 3.5.2.4 Simplicity Program works for boosting engineers’ work efficiency. It should make people work simpler. Therefore, unnecessary setting that increasing engineers’ burden such as redundant information input should be avoided. Also, the configuration interface ought to be easy to be understand. 3.6 Summary This chapter discussed the programing concept of each plugin. Also gave some idea of case study to test the plugin. The coding was based on the concept in chapter 3. In Chapter 4, the code will be presented and explained. The program results will be presented in chapter 5. Page | 59 Chapter 4 Program Development A plugin can be treated as the combination of a series of tiny function units. This chapter explains how to build each function unit for LTE and SDAN, and how they are assembled together to work properly. 4.1 LTE This section discusses how the code is organized to calculate lighting power density in each space. The program is divided into three parts: add references, command button creation, and main program (Figure 4.1). Figure 4.1 Program overview 4.1.1 Reference files in Visual Studio At the very beginning of developing a program, adding reference files is necessary (Figure 4.2). Visual Studio does not have the Revit API package, which means that accessing Revit parameters, families, schedules, and other elements in Revit is impossible. Under the installation path of Revit exists various kinds of reference files, and among them, RevitAPI.dll, RevitDBAPI.dll and RevitAPIUI.dll. Revit DB means Revit database. RevitDBAPI.dll provides the programming entrance for accessing to the Revit data such as object parameters. UI is short for the user interface, and RevitAPIUI.dll provides the entrance for accessing to the external command such as task dialog class and ribbon button class. Page | 60 Figure 4.2 Adding references Another step is using and specifying the namespace. A namespace is a declarative region that used to organize various kinds of the family inside it. For example, under the Architecture namespace in Revit API, not only exists the room class but also includes railing class, stairs class and other class related to architecture. Based on the inheritance hierarchy system in Revit API for using a specific class and method, not only the reference file that includes this class should be added, but also the namespace that includes it should be declared in the code (Figure 4.3). Figure 4.3 Inheritance hierarchy of Room 4.1.2 Command button creation The next part of the code works for creating an icon under Add-Ins ribbon in Revit for triggering the LPD tool (Figure 4.4). This would allow users to directly start the new tool by clicking on the button in Revit. The “buttonData” declares the name of the added command button (Figure 4.5). The string “LPDtest.Command” would execute the command under “LPDtest” namespace when the button is clicked. The code also specifies the image to use to launch the plug-in. Page | 61 Figure 4.4 Plugin icon under the Add-Ins ribbon Figure 4.5 Code script for creating the plugin button In addition to this, an AddIn Manifest code is also necessary (Figure 4.6). The AddIn Manifest code contains all the assembly information for declaring the AddIn in Revit. Here, the “<Name>LPD calculation” indicates the name of newly added ribbon. The “<Assembly>C:\Users\huan5\Desktop\code\LPD-test\LPD-test\bin\Debug\LPD-test.dll” tells Revit the location on the hard drive of the corresponding DLL file of the ribbon. Because sometimes there is maybe more than one ribbon created in one code script, each ribbon owns a unique ID, and the full class name needs to be present in the AddIn Manifest code. Figure 4.6 Manifest code for declaring a plugin at Revit 4.1.3 Main program The main program is the crucial part of the plugin that achieves the purpose of LPD calculation and comparison. It consists of many functional components such as obtaining the Revit handle, loading standard file, room property collection and LPD calculation. The following text tries to explain how each function component works and how they assembled together. Page | 62 4.1.3.1 Obtain Revit application handle The purpose of obtaining the Revit handle is to access to Revit data. The Revit API provides some parameters for access to Revit data (Figure 4.7). First, the “commandData.Application” represents Revit itself and is saved in the variable of “uiapp.” (Figure 4.8). In Revit, there may be several projects opened at the same time, but only one project can be selected. For the selected project, it is called the “ActiveUIDocument” in the Revit API. In the code script, the selected project is saved in the “uidoc.” All the objects in the selected project are in the “Document” property of “uidoc,” so it is saved into the variable “doc.” By this code script, a container “doc” that includes all objects such as walls, windows, and doors is created. The further operation is based on this container. Figure 4.7 Code script for getting Revit application handle Figure 4.8 Parameter for access to Revit data 4.1.3.2 Loading standard file The LPD tools will calculate the lighting power density of a specific space and make a comparison with a given standard. This given standard can be either embedded or input into the program. If the standard is written by programmers and embedded in the program, that means the value is constant and can be changed by users. While another type of standard is input by the users, which means it is variable. Such type allows engineers input different standard based on a project. For example, in the following code, the parameter “number1” is a variable that allows users input a value for it (Figure 4.9 – 4.10). While the parameter “number2” is a constant that the value of it is already given in the program. Page | 63 Figure 4.9 Constant and input value comparison (Code) Figure 4.10 Constant and input value comparison (Result) In order to allow engineers to input different standard files based on the project or standard update, it is better for users to input their own standard. Therefore, an “OpenFileDialog” is created to ask engineers to select the standard file they want to use. To avoid false input, the default form of the input file is set to an Excel XLSX file (Figure 4.11 – 4.13). After the engineer selects the standard file, the route of the selected file is saved into the variable “Excelfile.” Then, the program opens the Excel file of where the “Excelfile” located. All the information under the Excel sheet is saved into the class of “ExcelSheet.” Figure 4.11 Dialog for selecting the standard file Page | 64 Figure 4.12 Code script for creating dialog and filter Figure 4.13 Excel form of standard file 4.1.3.3 Obtain room property For calculating LPD, data about the room and lighting fixtures are required. Since the container “doc” includes all objects in the selected project, a filtering process is necessary to retrieve all room objects and lighting fixtures. Then the room is analyzed (Figure 4.14). Page | 65 Figure 4.14 Code script for retrieving room property At first, a collector “a” stores all the room objects. Then each room in the collector “a” will be checked. In the Title 24 assessment, the room type and area are the crucial factors. But when retrieving room names from Revit, the result is a string that contains the room name and serial number, which is a number. Therefore, the letter and the number need to be separated and saved into different variables. Before further use, the name should be checked against the standard file to see whether this kind of room type exists to avoid a system error. Usually, in the standard file, only the first letter is capitalized while the capitalization of the room name in Revit is not necessarily the same. To unify the expression, both of them are changed into all capital letters to make a comparison, and only when they are the same, the program keeps running, otherwise, the program will skip this room and go to the next room. For example, for the following room, the room name “Classroom Building” is saved into the variable “roomname.” (Figure 4.14a). Next, the program starts scanning the type of building list in the standard file from the first cell to the end. If the cell value equaled the “roomname,” such as the cell at row 3, the corresponding allowed LPD would be retrieved into a variable for future comparison. While if the cell value was empty, that indicated such room type did not existed in the standard file. This room will be skipped. Page | 66 Figure 4.14a Example for room analysis 4.1.3.4 LPD calculation After obtaining the necessary information, the next step is calculating the lighting power density in each room. In this session, the program also started from creating a collector that retrieved all lighting fixtures in the selected room (Figure 4.15). But unlike room collecting where the searching area is the entire project, the lighting fixture searching area was limited in the selected room. In order to achieve that, the selected room must be set into a bounding box – an invisible 3D rectangular space that contains the room (Figure 4.15a). For example, for the following three columns, the orange rectangle boxes are the smallest rectangle that contains the column. That are the bounding boxes for these columns. The Revit API does not provide methods (a term in C# for a code block to perform a task) to make a judgment that whether an object is located in a room, but it provided methods to make a judgment that whether an object is located in a bounding box. Therefore, an additional logical condition was added for the collector that the lighting fixture must within the bounding box of the room. Figure 4.15 Code script for collecting lighting fixture in a specific room Page | 67 Figure 4.15a Bounding box example. Retrieved from: https://knowledge.autodesk.com/support/revit-products/learn- explore/caas/CloudHelp/cloudhelp/2015/ENU/Revit-Model/files/GUID-C88AAF36-7F89-4599-8C57-CD9B02390C27-htm.html The collector “collectorb” gathered all lighting fixtures in the selected room, and all the information required for LPD calculation is completed. The allowed LPD value is saved into the variable “standard.” (Figure 4.16). Then, a loop that scanning every lighting fixture in “collectorb” starts. The property “RBS_ELEC_APPARENT_LOAD” of each lighting fixture is retrieved and saved into variable “power,” because this value equaled the electrical power of the lighting fixture. Another variable “totalpower” is used to accumulate the total lighting power. In each lighting fixture checking loop, the “totalpower” equals the “totalpower” in the last loop plus the power of lighting fixture in the current loop. Therefore, when the loop finished, the “totalpower” equaled the sum of all lighting fixtures. Figure 4.16 Code script for calculating total lighting power in a specific room Then by dividing the total lighting power in the room by the room area, which was saved previously, the lighting power density is calculated. The result saves in the “roomLPD.” As the allowed LPD value saving in the “standard,” the following code script comparing the “standard” with the “roomLPD.” If the “roomLPD” is less than “standard,” the designed LPD value fulfills the Title 24 requirement. Otherwise, engineers need to reduce the total lighting fixture power by changing the types or numbers of fixtures and re-run the plug-in. Page | 68 In order to show the results, task dialogs are created to show each room’s name, area, allowed LPD, real LPD, and the conclusion (Figure 4.17). Figure 4.17 Code script for result display 4.1.3.5 Linked model The previous code only services for calculating LPD in the real model. It cannot retrieve the data from a linked model. Therefore, another part of code script is added (Figure 4.17a). Figure 4.17a Code script for accessing to linked model The collector “elems” gathered all linked files. The following code aimed at creating a “linkedDoc” to represent the linked model. Because, like the previous process, when all objects in a real model were made into a document “doc,” with the help of various classes, operation on the objects such as room, lighting fixture, and others became possible. Since linked model was also kind of model that can be represented by document parameter, a variable “linkedDoc” was created to represent each linked model. Then the rest of the code was similar to the LPD calculation process in real model despite when gathering elements such as spatial element, the searching scope must be limited within the linked model. In this way, the LPD tool can also work in the linked model. Page | 69 4.2 SDAN programming process This section discusses the SDAN developing process (Figure 4.18). SDAN also consists of many code blocks that achieving a tiny function such as find level id, get the family symbol, tag analysis, and the main program. As the process of adding references was already discussed in 4.1, it will be skipped in this part. Other code blocks will be discussed in the following section 4.2. Figure 4.18 Code overview for SDAN 4.2.1 Find the level id The level is also kind of element in Revit. Likes other elements in Revit, the level has parameters such as name or id. As discussed in chapter 3, in equipment tag, there is a number indicates in which floor the equipment is located (Figure 4.19). SDAN will get this number and collect all rooms on this floor, then decide where the equipment should be placed. The “find level id” function is used for helping collect the rooms in given floor (Figure 4.20). The function has two inputs, one of them is the “doc” which was explained in 4.1. Another is the level name. While the level name in Revit is not a number. For a specific floor, the level name of it is “Level” plus the floor number. For example, the level name of the second floor is “Level 2”. With the level name input, as other similar filter processes in LPD tools, the “find level id” function collects all level elements, and check the level name of each level element until that equals to the input level name. Then get the level id and return it. With the result, the main program can quickly collect all rooms with given floor number. Page | 70 Figure 4.19 Meaning for each alphabet of electrical equipment Figure 4.20 Code script of Find level id 4.2.2 Get the family symbol In Revit, a family is a group of elements with a common set of properties and a related graphical representation. (Autodesk) Under a specific Revit family, there may exist various kinds family types (Figure 4.21) For example, for the family automatic transfer switch, the family name is “Automatic Transfer Switch”. Under this family, there are several types classified based on the amps. Every type corresponds to a unique symbol. In Revit API, the type name, which under “Automatic Transfer Switch” is “100-200 A” or “200-400 A”, is called the symbol name. When creating a new object in Revit, the “NewFamilyInstance” method can be applied (Figure 4.22) This method requires several inputs. One of these is “FamilySymbol” that decides which specific object should be inserted. Other inputs will be discussed later. Therefore, the “GetSymbol” function is necessary in the SDAN. Page | 71 Figure 4.21 Family and family type in Revit Figure 4.22 Syntax of new family instance method in Revit API Despite the “Document” parameter, which represents all objects in the selected project, the “GetSymbol” function also requires two other inputs, one is the “familyName”, another is “symbolName.” (Figure 4.22a). Based on the inputs, the function will select the family which the name equals the given “familyName”. Then return the family symbol with the give “symbolName”. Figure 4.22a Code script of Getsymbol function 4.2.3 Tag analysis As discussed, each alphabet and number in equipment tag has special meaning, and a tag analysis is necessary to divide the tag into individual units and retrieve corresponding information (Figure 4.23) Page | 72 Figure 4.23 Code overview of tag analysis In C#, every character in a string has a unique index. For instance, 2AL202, a tag means a lighting and appliance panelboard that is located in the second floor of room 202. The number that indicates the floor number is at the head of the string (Figure 4.24). Therefore, when retrieving the floor number, the string character is checked from the first index until the character is not a number, recording the index. Then truncating the string from the index 0 to the recorded index “i” will get the floor number. The method “substring (a, b)” can achieve such target. It means truncating the string from index a with the length of b. For example, in the following code, the string “resulta” is the string that truncating “2AL202” from the index 1 with the length of 3, therefore, the result string is “AL2”. While the string “resultb” is the string that truncating “2AL202” from the index 2 with the length of 2, therefore, the result string is “L2” (Figure 4.25 - 4.26). Since the character “i” saves the last index which a corresponding string character is a number, the character “levelnumber” equals the floor number of the equipment (Figure 4.27). Figure 4.24 Structure of string Page | 73 Figure 4.25 Test code for string truncating Figure 4.26 Result of string truncating Figure 4.27 Code for getting level number from a string For the equipment type, the scan continues from the index of “i” until the string character is a number or equals “M.” M” indicates the panel box located in an electrical room while the number means the end of equipment type. Suppose the scan stopped and current index is “j”. Therefore, the string between the index “i” with “j” is the equipment type. The final step for the tag analysis is to get the serial number. Generally, one room would not have two panel-boxes of the same type, but sometimes an equipment room such as a mechanical room might have lots of equipment that cannot be supplied by only one-panel box. In this case, two or more panel-boxes are necessary. So not only a serial number for a room, but also a serial number for the equipment is required. For example, 2AP202-1 and 2AP202-2, both represent a metering switchboard at room 202, while because they have the same equipment type and location, therefore additional dash and number “-1” and “-2” are used for distinguishing these two switchboards. Since a dash may exist in the equipment name, the serial number could not be simply retrieved by truncating the string from the index of “j,” which is the last alphabet of equipment type to the last string character. The code must test whether “-” is existed in the string. If “-” existed, SDAN truncates the string from the index of “j” to the index before the string character “-” and saved into the “serial1”. The rest part of the string which is the equipment serial number is saved into “serial2.” (Figure 4.28). Page | 74 Figure 4.28 Code for retrieving serial number and parameter assemble The results of testing the function are shown below (Figure 4.29). Each character in the tag is analyzed and sorted into different parameters. Then all parameters are assembled into an array and returned into the main program. Figure 4.29 Result of tag analysis 4.2.4 Main program In the main program, all function units assemble together to create the family instance (Figure 4.30). Page | 75 Figure 4.30 Workflow of the main program 4.2.4.1 Tag claim The program starts with a tag claim. A tag claim is a process that defines the corresponding relation between the family name in Revit and the alphabet combination used by electrical engineers. For example, AT represents Automatic Transfer Switch. AL represents Lighting and Appliance Panelboard. “AT” and “AL” are used by engineers to represent specific equipment type, while these alphabet combinations cannot be understood by Revit. Therefore, an Excel sheet that contains the alphabet and the corresponding family name is necessary (Figure 4.31). As the tag analysis function gets the string the represent the equipment type, SDAN scan the tag claim sheets until a cell’s value equals the string returned by tag analysis function, then get the family name in the corresponding cell. This family name will be input to get family symbol function to help create the family instance in Revit. Figure 4.31 Equipment type and representative code 4.2.4.2 Equipment list When scanning the single line diagram, only two pieces of data are important: first is the equipment tag, second is the rated value of the equipment. For example, for the automatic transfer switch, it has various kind of rated current, like 100-200A or 200-400A, which means it is under the best working condition within this current range. As discussed in 4.2.2, the equipment name “Automatic Transfer Switch” equals the family name (Figure 4.32). The current rated value equals the family symbol name. Page | 76 Figure 4.32 Family and family type in Revit Therefore, with these two specific pieces of data, the corresponding component in Revit could be determined. Since other information such as size or shape is not important in this step, an Excel sheet that only includes equipment tag and rated value is created to represent the single line diagram (Figure 4.33). Figure 4.33 Equipment list 4.2.4.3 Searching Equipment location With the classified information, SDAN starts a filter progress that searching for the corresponding room to the equipment tag. First is the floor. SDAN collects all room elements that level equals the “levelnumber” character. Before the next step, there must be some error detecting. Because in case of error input, such as an equipment tag is 10AL1 while the building is a five-floor building, the correct location for the equipment does not exist, and the equipment tag should be treated as an illegal tag. In order to achieve that, a collector “Rooms1” collects all room elements where the floor level equals the equipment level. Then a logical judgment is made about whether the collector “Rooms1” is empty or not. If “Rooms1” is empty, that means the tag is illegal since the level number of the equipment does not exist in the building. In that case, this equipment will be skipped. In order to mark this illegal tag in the equipment list, the cell at column C with the same row of equipment tag will be filled with “illegal tag” (Figure 4.34). Page | 77 Figure 4.34 Mark illegal tag in the equipment list The next step is to find the corresponding family name for the equipment. As discussed in 4.2.4.2, SDAN compares the “equiptype” parameter with the Excel sheet. Once the cell value of the Excel sheet equals the “equiptype,” SDAN retrieves the cell value next to the previous cell to get the family name. If none of the cell value equals “equiptype,” the equipment tag also should be treated as an illegal tag, since there is not a family in Revit corresponding to this equipment. So far, the floor and family type of the equipment has been determined. The last factor for determining the location is the room serial number. Usually, the room will be tagged in the following style (Figure 4.35). Figure 4.35 Room serial number in HED project. Retrieved from: USC Facilities Management Services(FMS) HED project. The first digit usually indicates the floor. The remaining digits indicate the room serial number, and this serial number is unique. Therefore, to represent a metering switchboard in the room 222, associate athletic director, the tag will be 2AP222, or 2AP22 which the floor number is deleted. As discussed, when directly retrieve the name of the room, the result includes both room number and room name, therefore, a parameter “roomserial” truncating the room number out. After converting the data type from integer to string, the result which saved into the “roomnumber” was used to compare with Page | 78 the equipment serial number (Figure 4.36). If the two parameters are equal, the program keeps going to generating instance. Figure 4.36 Code script for locating equipment 4.2.5 Creating equipment Once the room number is determined, SDAN starts placing equipment in the corresponding room. In Revit API, the “NewFamilyInstance” method is used for creating a new instance in Revit, but this method requires several parameters (Figure 4.37). Figure 4.37 Syntax of new family instance method in Revit API First is the coordinates parameter XYZ, which represent the physical location where the instance is to be placed. In order to ensure the new instance is located within the room, the room is made into a bounding box, and the center point’s coordinates are retrieved and saved into a variable. Second is the family symbol object that represents the type of instance to be placed. As discussed previously, for defining a specific equipment family instance in Revit, two kinds of information are required, one is the family name and the other is the family type that is treated as symbol name in Revit API. The family name is already saved in the equipment claim sheet, and the family type is saved in the equipment list. They were saved in two string variables. A function was created to get the family symbol with the given family name and symbol name. This function first collects all class object that family name equals the given family name, then among all the collected objects, the “GetSymbol” function will pick up the specific family symbol that the symbol name equals the given value. Then the function returns the family symbol to the main program. This method also requires a host for placing created equipment. A host in Revit is into which the instance will be embedded. The host could be wall or floor or other instances in Revit. For example, when placing a window, a wall must be picked to host the window. SDAN picks the floor for hosting the instance. With these three variables selected, “newfamilyinstance” creates a newly selected family instance into the corresponding room in Revit. As the SDAN will scan each equipment in the equipment list, all the equipment will be placed into the corresponding position. 4.3 Summary Each program was divided into small functional units. They were developed by C# in Visual Studio. After debugging, the result showed each unit worked properly. Next, they were assembled together to form a working system. The systems were tested, and the results are shown in chapter 5. Page | 79 Chapter 5 Result This chapter explains how the code developed in chapter 4 runs. A conclusion about whether the program achieved the designed function was made after comparing the expected results with the results generated by program executing. 5.1 LPD LPD tool is a plugin that calculates the lighting power density of each space in the Revit and comparesthe results with the Title 24 lighting standard to check whether the lighting design satisfied the requirement of the selected standard. The add-in created a new icon under the ribbon of Add-Ins in Revit (Figure 5.1). The new icon is used to represent and start up the LPD tool. Figure 5.1 Plugin icon under Add-Ins ribbon The test model is a simple classroom (Figure 5.2). Room type is classroom building which the total area is 325.5 SF. There are ten lighting fixtures in the room with 17VA for each lighting fixture. Therefore, total lighting power is 10 x 17 VA = 170 VA. The lighting power density equals 170 VA / 325.5 SF = 0.52 W/SF. Lighting Power Density = 10 x 17 VA / 325.5 SF = 0.52 W/ SF, lower than Title 24 standard. Figure 5.2 Room and lighting fixture parameters Based on Title 24, for a classroom building, the allowed lighting power density is 0.8 W/SF (Figure 5.3). Since the real LPD is lower than the allowed LPD, this lighting design satisfies Title 24’s requirement. Page | 80 Figure 5.3 Excel form of standard file When clicking on the “LPD tool” icon, a task dialog that asking for selecting standard would be presented. After selecting the standard file, program keeps running, and the result of executing this program is below (Figure 5.4). Figure 5.4 The result of program execute The first dialog shows the model type, allowed lighting power density, room’s property, and calculated value. The results equal the anticipated result (Figure 5.5). Therefore, for the calculation part, the LPD tool finished perfectly. Another dialog shows the conclusion whether the value is within the standard requirement. Figure 5.5 Conclusion Page | 81 Another model is made to test whether the program works well with the linked model. The real model includes one restaurant and one grocery store (Figure 5.6). Then the real model is linked in another file and saved. Lighting fixture are placed in the linked model. After running the program, the results are shown (Figure 5.7). Figure 5.6 Program test in the linked model Page | 82 Figure 5.7 LPD tool execute result in linked model Based on the results, two conclusions can be drawn: 1. The LPD tool can recognize the linked model and also exchange data with the linked model. 2. The LPD tool is able to get the allowed lighting power density value from a standard based on the room type. In summary, the LPD tool can achieve the expected function. Chapter 6 describes potential future improvements. 5.2 SDAN SDAN is a plugin that scans a single line diagram and for equipment listed in single line diagram, puts them in the correct room in Revit. This section discusses the program input and shows that SDAN achieves most of the designed function. 5.2.1 Program input As discussed in Chapter 4, there were two input files for SDAN. One was an equipment list that recorded all electrical equipment and their tags that represent the single line diagram (Figure 5.8). The number of items could be increased. Another was a file that records the corresponding relation between equipment tag and its symbol in Revit. Page | 83 Figure 5.8 Equipment list The test model was a 2-floor building (Figure 5.9 – 5.10). Every room was labeled with a unique number. Based on the previous input, the expected result was that in room 102, a “Lighting and Appliance Panelboard - 208V MCB – Surface” instance of the type “100 A” would be created. In room 101, a “Metering Switchboard” instance of the type “24x26.25” would be created. Figure 5.9 Floor plan of the test model for SDAN Page | 84 Figure 5.10 3D view of the test model for SDAN As the program was executed, a bug appeared. An error message indicated that the family symbol was not active (Figure 5.11). That was because such family symbol was never used in Revit. To solve this error, a new paragraph of code script was added into the code. The “famsss” was the family symbol got by “GetSymbol” function. Before direction creating the family instance by using this symbol, another progress that checking whether the selected family symbol was active or not (Figure 5.12). If it was not active, the command “famsss.Activate” changed the symbol status. Then the symbol could be used in Revit. Figure 5.11 Error message Figure 5.12 Code script to activate family symbol After debugging, the program run successfully (Figure 5.13 - 5.14). Page | 85 Figure 5.13 Result floor plan 1 Figure 5.14 Result floor plan 2 At the center of room 101, a new instance of “Metering Switchboard” of the type “24”x26.25”” was created. The mark equaled to the corresponding equipment tag. Other electrical equipment listed in the equipment list was also created correctly. Page | 86 While based on the performance, currently SDAN has several shortcomings: First, SDAN cannot avoid equipment overlapping when two or more equipment will be generated in the same space. For example, for the following equipment list, both of the “1AT101” and “1AP101” were located in the room 101 (Figure 5.15). Therefore, based on the sequence of equipment in the list, the “1AT101” would be generated first. While, when generating the “1AP101,” SDAN could not move the “1AP101” to avoid overlapping with the “1AT101.” Both of them would be generated at the center of room 101. Figure 5.15 Equipment list Second, if one equipment was generated for twice, SDAN can neither replace the existed instance with new instance nor cancelled the new creating process (Figure 5.16). The result showed that two identical instances appeared in the same place. They would be resulting in double counting in the schedules. Figure 5.16 Warning message These are the two directions for improving the performance of SDAN. SDAN supports users to expand equipment list and equipment type. An equipment list that avoiding SDAN shortages is below (Figure 5.17 – 5.18). Page | 87 Figure 5.17 New equipment for test Figure 5.18 Expansion of equipment claim The results showed SDAN could recognize the new tag type and generate them correctly in the right place. Therefore, engineers can set their own equipment type as many as their need. SDAN has extensibility (Figure 5.19 – 5.20). Figure 5.19 Test of expansion of equipment list (1st floor) Page | 88 Figure 5.20 Test of expansion of equipment list (2nd floor) 5.3 Conclusion Both of plugins achieved their basic functionality. The LPD tool can calculate the lighting power density correctly and assess it against the Title 24 standard. SDAN can place electrical equipment into the right place based on a given Excel equipment list. But both of the programs have some shortcomings. The programs do not be tested under real project. Unpredictable input may result into program failure. Further debugging is required to make the programs more robust. Another potential direction for improving programs’ improvement is adding new function to the plugins. For example, adding code to LTE to generate certificate compliance. For SDAN, efforts can be made on generating SLD diagram based on previous electrical plan. All these improvements will be discussed in Chapter 6. Page | 89 Chapter 6 Future Work Although the two plugins can achieve the basic designed function, they still have shortages that can be improved in various aspects. This chapter will discuss the potential method to enhance the plugins. 6.1 Software test These two plugins have gone through with unit testing and integration testing that each program module is working and all modules can work to achieve basic requirement. While they are not going through stress testing which is a testing to evaluate how the program works under unpredictable condition. In real project, users may not familiar with the correct form of input data. For example, users may input an undeclared equipment type in SDAN. In this case, the program would fail due to the incorrect input. The whole program is fragile that need to fix bug and avoid executing with incorrect data. Then the program can become more robust. 6.1 LPD tool In a real project, the LPD calculation results are not presented in the form of task dialog, but a certificate of compliance. As discussed in chapter 2, the certificate of compliance includes information such as the type of each lighting fixture, numbers or installed watts. Visual Studio also enable users to create pdf file via coding. But composing the pdf file such as font style, size or text position is very difficult. An easier way to achieve is setting up a template that including all texts and forms with the cells which waiting for inputting empty. As program running, the cell will be filled with required information to generate a complete certificate. This method benefits because first with the help of horizontal and vertical coordinates, locating text position will be easier comparing to a blank paper. Second, when finished a page, simply copy the template can create a new page. In this way generating certificate of compliance becomes easier. LPD tool only works when the room’s name exists in Title 24 standard. But in a real project, the room’s name can be various. For example, in a classroom building, there are room such as classroom and study room. They are not listed in Title 24. To solve it, a sub-list records all type of room’s name under a building will be help. Third, the program was not tested in a real project. Though LPD tool works perfect in simple model, Whether LPD tool can work well in a real project still need further test because in real project the input information cannot be predicted that may lead to program failure. On the other hand, the best way to check a program’s function is testing it under a real project. If the program can generate the certificate of compliance as what engineers made in a project, that prove LPD tool has practical use value. 6.2 SDAN To simplify the coding, during program development, an Excel file of equipment list was used to represent the single line diagram, while actually this scenario will not happen in real project. The code script need to be adjusted to read the information in single line diagram. In chapter 5, two shortages were discussed. First, SDAN could not avoid equipment overlapping when two or more equipment would be generated in the same space. The primary location for generating equipment was the center of room. Additional code script works to check whether an instance existed in the location where the new instance will be generated. If so, move the new created instance to an empty place to avoid overlapping. Second, before creating a new instance, another progress that checking whether the instance is already existed in the space is added in the program to avoid double creating. Based on the code, SDAN only works for equipment tag which follows the sequence of “floor-equipment type-room’s number-serial number.” But the form of tag varies depending on the company. Therefore, the Page | 90 code need to be modified that allow users to customize their own combination of equipment tag. The input interface should be improved in the future. Another potential improvement on SDAN is not only generating electrical equipment in the electrical plan based on SLD, but also SDAN can generating SLD based on the information in electrical plan. SDAN must be able to fix the connection between each equipment and express it in SLD. Moreover, in order to make SDAN more intelligent, a potential improvement on SDAN is creating an algorithm to find the most appropriate place for the generated equipment. Because, an electrical equipment will not be simply placed on the wall. Actually, when placing the electrical equipment, the elevation of the equipment and the space between different equipment must be taken into consideration. A research need to be done on previous projects to find the logic between electrical device and its definite position in the room. 6.3 Summary Even the created plugins can achieve the designed function, they can be improved on various aspects such as making program more robust or adding new function. The plugins still need to be updated in the future. Future work will focus on providing intelligent input or output instead of previous Excel file or task dialogue. Especially generating certificate of compliance for LTE to allow LTE to be used in real project directly. Page | 91 References “APC Smart-UPS 1500VA UPS Battery Backup with Pure Sine Wave Output (SMC1500)” Amazon. Last accessed May 7, 2018. https://www.amazon.com/APC-Smart-UPS-1500VA-Battery- SMC1500/dp/B007ZT2KKM “Beta, Abb and Astor power and distribution transformers, 33kv and 11kv line materials, solar panel and cables” Alibaba. Last accessed May 7, 2018. https://www.alibaba.com/product-detail/BETA- ABB-AND-ASTOR-POWER-AND_177586205.html “Circuit Breakers” Scheider Electric. Last accessed May 7, 2018. https://www.schneider- electric.us/en/product-category/50300-circuit-breakers/ “Prime Power Diesel Generator Set, rated 275kVA / 220kW, Caterpillar 3406” Subbcourier. Last accessed May 7, 2018. https://subbcourier.com/shop/electrical-power-supplies/power-generation- generators/prime-power-diesel-generator-set-rated-275kva-220kw-caterpillar-3406/ “Why have 160 ohms disappeared from the earth rod in this installation”. Last modified January 30, 2015. https://www.voltimum.co.uk/articles/q-day-why-have-160-ohms-disappeared “AC Motors” ABB. Last accessed May 7, 2018. https://www.baldor.com/brands/baldor- reliance/products/motors/ac-motors “Electrical Circuit get Panels and Elements” BIMStallatie. Last accessed May 7, 2018. https://bimstallatie.sites.google.com/site/bimstallatie/dynamo/mepover-package#TOC- ElectricalCircuit-get-Panels-and-Elements “Sample Detailed Model” Autodesk. Last modified June 7, 2017. https://insight.autodesk.com/oneenergy/Sample/Model/31390 “Slimline – Lounge Plates” bimstore.co.uk. Last modified Jul 13, 2017. https://www.bimstore.co.uk/bim/Slimline-Lounge-Plates “Workflow: Copy/Monitor for Linked Models” Autodesk. Last modified Feb 07, 2017. https://knowledge.autodesk.com/support/revit-products/learn- explore/caas/CloudHelp/cloudhelp/2016/ENU/Revit-Collaborate/files/GUID-6A5B3BBA-77FE- 4CFE-9D0C-B347D5C402E2-htm.html ABB. “AC Motors” ABB. Last accessed May 7, 2018. https://www.baldor.com/brands/baldor- reliance/products/motors/ac-motors AIA. “What is this thing called LOD.” Exploring the LOD Specification. July 29, 2014, 12-17. Arayici, Yusuf, P. Coates, Lauri Koskela, Mike Kagioglou, Colin Usher, and K. O'reilly. "BIM adoption and implementation for architectural practices." Structural survey 29, no. 1 (2011): 7-25. Autodesk, “About Bounding Boxes” Autodesk.” Last modified April 13, 2015. https://knowledge.autodesk.com/support/revit-products/learn- explore/caas/CloudHelp/cloudhelp/2015/ENU/Revit-Model/files/GUID-C88AAF36-7F89-4599- 8C57-CD9B02390C27-htm.html Autodesk, “Workflow: Copy/Monitor for Linked Models” Autodesk.” Last modified Feb 07, 2017. https://knowledge.autodesk.com/support/revit-products/learn- explore/caas/CloudHelp/cloudhelp/2016/ENU/Revit-Collaborate/files/GUID-6A5B3BBA-77FE- 4CFE-9D0C-B347D5C402E2-htm.html Ben, Joan. "Difference Between EXE and DLL." DifferenceBetween.net. May 19, 2011 (http://www.differencebetween.net/technology/difference-between-exe-and-dll/). California Energy Commission. “Nonresidential Compliance Manual for the 2016 Building Energy Efficiency Standards.” Title 24, Part 6. California Lighting Technology Center. “Detail lighting.” 2013 Title 24, Part 6 Design Master Software “Branch Circuit Breaker and Wire Sizing”. Last accessed May 7, 2018. http://www.designmaster.biz/revit/branch-circuit-breaker-si.html Design Master Software “Voltage Drop”. Last accessed May 7, 2018. http://www.designmaster.biz/revit/voltage-drop.html Page | 92 Eastman, Chuck, Jae-min Lee, Yeon-suk Jeong, and Jin-kook Lee. “Automatic rule-based checking of building designs.” Automation in Construction. no. 18 (2009) 1011-1033 Joáo Poças Martins, Andre Monteiro. “LicA: A BIM based automated code-checking application for water distribution systems.” Automation in Construction. no. 29(2013)12-23 Jon Peddie Research. “CAD Market Returns to Growth; Reaches $8B in 2014.” Retrieved April 24, 2015 (https://www.pddnet.com/news/2015/04/cad-market-returns-growth-reaches-8b-2014). Kristian Parsons. “Getting Started with the Revit API.” Revit RTC Technology Conference. 2010. Lighting Analysts, Inc. “Elum Tools 2018” last modified February 2, 2018. https://apps.autodesk.com/RVT/en/Detail/Index?id=8360862130945868351&appLang=en&os= Win64 Nielsen, Jakob. “Response Times: The 3 Important Limits.” Usability Engineering. January 1, 1993, Chapter 5 Notenboom,Leo A. “What's the difference between a DLL and an EXE, and why is it important that I know?” ask-leo.com. January 15, 2012 (http://ask- leo.com/whats_the_difference_between_a_dll_and_an_exe_and_why_is_it_important_that_i_kno w.html). Regulatory Assistance Project. “Electricity Regulation In the US: A Guide.” March 2011, 9-10. Saad Al Jabri. “The Dangers of Blurred Model Deliverables” last modified September 10, 2016. https://thebimhub.com/2016/09/10/dangers-of-blur-model-deliverables/#.WvDR14gvyUl Sebastian, Rizal. "Changing roles of the clients, architects and contractors through BIM." Engineering, Construction and Architectural Management 18, no. 2 (2011): 176-187. Sebastian, Rizal. "Integrated design and engineering using building information modelling: a pilot project of small-scale housing development in the Netherlands." Architectural Engineering and Design Management 6, no. 2 (2010): 103-110. Sinha, Susmita, Anil Sawhney, André Borrmann, and Fabian Ritter. "Extracting information from building information models for energy code compliance of building envelope." In Proceedings of the RICS COBRA Conference 2013, pp. 1-16. 2013.Susmita Sinha, Anil Sawhney, Andre Borrmann and Fabian Ritter. “Extracting information from building information models for energy code compliance of building envelope.” In Proceedings of the RICS COBRA Conference 2013, pp. 1-16. 2013. Solihin, W., and C. Eastman. “Classification of rules for automated BIM rule checking development.” Automation in Construction. no. 53 (2015) 69-82 Tassos, Pippa “Electrical Wiring and Panel Schedules in Revit – UK industry Standard Adaptation.” Retrieved November 9th, 2016 (http://www.bmarq.co.uk/electrical-wiring-panel-schedules-revit- tutorial/). Tesla CAD solutions. “Latest BIM Trends Across AEC Industry”. Retrieved March 10, 2014 (https://www.teslacad.com.au/blog/latest-bim-trends-across-aec-industry/). USGBC. “Lighting power density.” Last accessed May 7, 2018. (https://www.usgbc.org/credits/reqss8r51) Page | 93 Appendix Source code of SDAN using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Architecture; using Autodesk.Revit.DB.Structure; using Autodesk.Revit.Attributes; using System.Windows.Forms; using System.Text.RegularExpressions; using Microsoft.Office.Interop.Excel; using Microsoft.Office.Tools.Excel; using Autodesk.Revit.DB.Analysis; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB.Electrical; namespace stringtest { [Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { // Find level ID for room filter public ElementId Findlevelid(Document doc, string levelname) { ElementId flag = null; FilteredElementCollector lvlCollector = new FilteredElementCollector(doc); ICollection<Element> lvlCollection = lvlCollector.OfClass(typeof(Level)).ToElements(); foreach (Element l in lvlCollection) { Level lvl = l as Level; if (lvl.Name == levelname) { flag = lvl.Id; } } return flag; } // Get family symbol for placing equipment public FamilySymbol GetSymbol(Document document, string familyName, string symbolName) { return new FilteredElementCollector(document).OfClass(typeof(Family)). Page | 94 OfType<Family>().FirstOrDefault(f => f.Name.Equals(familyName))?. GetFamilySymbolIds().Select(id => document.GetElement(id)). OfType<FamilySymbol>().FirstOrDefault(symbol => symbol.Name.Equals(symbolName)); } //Tage analysis public string[] Tag(string equipmenttag) { int i = 0; int j = 0; string levelnumber = ""; string equiptype = ""; string char3 = ""; string serial1 = ""; string serial2 = ""; for (i = 0; i < equipmenttag.Length; i++) { if (char.IsLetter(equipmenttag[i])) { break; } } levelnumber = equipmenttag.Substring(0, i); for (j = i; j < equipmenttag.Length; j++) { if ((equipmenttag[j].ToString() == "M") | (char.IsNumber(equipmenttag[j]))) { break; } } equiptype = equipmenttag.Substring(i, j - i); if (equipmenttag.IndexOf("-") >= 0) { if (equipmenttag[j].ToString() == "M") { char3 = equipmenttag[j].ToString(); serial1 = equipmenttag.Substring(j + 1, equipmenttag.LastIndexOf("-") - j - 1); serial2 = equipmenttag.Substring(equipmenttag.LastIndexOf("-") + 1, equipmenttag.Length - equipmenttag.LastIndexOf("-") - 1); } else { char3 = ""; serial1 = equipmenttag.Substring(j, equipmenttag.LastIndexOf("-") - j); serial2 = equipmenttag.Substring(equipmenttag.LastIndexOf("-") + 1, equipmenttag.Length - equipmenttag.LastIndexOf("-") - 1); } Page | 95 } else { if (equipmenttag[j].ToString() == "M") { char3 = equipmenttag[j].ToString(); serial1 = equipmenttag.Substring(j + 1, equipmenttag.Length - j - 1); } else { char3 = ""; serial1 = equipmenttag.Substring(j, equipmenttag.Length - j); } } string[] xxx = new string[] { levelnumber, equiptype, char3, serial1, serial2 }; return xxx; } public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { // Get Revit handle UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; #region Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; Document doc = uidoc.Document; Transaction transno = new Transaction(doc); Transaction tran = new Transaction(doc); FilteredElementCollector collector = new FilteredElementCollector(doc); List<Element> Rooms = new FilteredElementCollector(doc). OfClass(typeof(SpatialElement)).WhereElementIsNotElementType(). Where(room => room.GetType() == typeof(Room)).ToList(); #endregion #region Range quip; Range quipa; Range quipb; int Excelcola = 0; int Excelcolb = 0; string equip = ""; Page | 96 string equipa = ""; string equipmenttype = ""; #endregion // Tag claim & Equipment list string Equiplist = "C:\\Users\\huan5\\Desktop\\thesis-new\\test file\\Test.xlsx"; #region Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook wb = Excel.Workbooks.Open(Equiplist); Sheets ExcelSheet = wb.Worksheets; Microsoft.Office.Interop.Excel.Worksheet eqclaim = (Microsoft.Office.Interop.Excel.Worksheet)ExcelSheet["Sheet1"]; Microsoft.Office.Interop.Excel.Worksheet eqlist = (Microsoft.Office.Interop.Excel.Worksheet)ExcelSheet["List"]; #endregion int Excelcol = 0; Range rangetag; Range rangerate; string tag; string rate; string[] taga; string level = ""; string type = ""; string assort = ""; string serial = ""; string serialsub = ""; string roomnumber = ""; int flag = 0; XYZ center; ElementId levelid = null; //Room tage acquirement and analysis for (Excelcol = 2; ; Excelcol++) { rangetag = (Microsoft.Office.Interop.Excel.Range)eqlist.Cells[Excelcol, 1]; rangerate = (Microsoft.Office.Interop.Excel.Range)eqlist.Cells[Excelcol, 2]; object obj = rangetag.Value2; if (obj == null) { break; } tag = rangetag.Value.ToString(); rate = rangerate.Value.ToString(); taga = Tag(tag); Page | 97 level = "Level " + taga[0]; type = taga[1]; assort = taga[2]; serial = taga[3]; serialsub = taga[4]; ((Range)eqlist.Cells[Excelcol, 3]).Value2 = ""; levelid = Findlevelid(doc, level); List<Room> Rooms1 = new List<Room> (Rooms.Where(room => room.LevelId == levelid).Select(r => r as Room)); if (Rooms1 == null) { ((Range)eqlist.Cells[Excelcol, 3]).Value2 = "illegal tag"; continue; } for (Excelcolb = 3; ; Excelcolb++) { quipa = (Microsoft.Office.Interop.Excel.Range)eqclaim.Cells[Excelcolb, 3]; equipa = quipa.Value.ToString(); object obj2 = quipa.Value2; if (obj2 == null) { ((Range)eqlist.Cells[Excelcol, 3]).Value2 = "illegal tag"; break; } if (equipa == type) { quipb = (Microsoft.Office.Interop.Excel.Range)eqclaim.Cells[Excelcolb, 4]; equipmenttype = quipb.Value.ToString(); break; } } // Creating family instance foreach (Room t in Rooms1) { int roomserial = Convert.ToInt16(Regex.Match(t.Name, @"\d+").Value); roomnumber = roomserial.ToString(); if (roomnumber == serial) { flag = 1; FamilySymbol famsss = null; famsss = GetSymbol(doc, equipmenttype, rate); tran.Start("Check whether family symbol is active"); if (!famsss.IsActive) { Page | 98 famsss.Activate(); } tran.Commit(); roomnumber = t.Number.ToString(); BoundingBoxXYZ bounding = t.get_BoundingBox(null); Autodesk.Revit.DB.Outline outline = new Autodesk.Revit.DB.Outline(bounding.Min, bounding.Max); BoundingBoxIntersectsFilter filterbl = new BoundingBoxIntersectsFilter(outline); // XYZ center = (bounding.Max + bounding.Min) * 0.5; if (equipmenttype != "Lighting and Appliance Panelboard - 208V MCB - Surface") { string rr = ""; double x = (bounding.Min.X + bounding.Max.X) * 0.5; double y = (bounding.Min.Y + bounding.Max.Y) * 0.5; double z = bounding.Min.Z; center = new XYZ(x, y, z); // Autodesk.Revit.DB.Floor floor = FilteredElementCollector collectorb = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Floor)).WherePasses(filterbl); Autodesk.Revit.DB.Floor floor = collectorb.FirstElement() as Autodesk.Revit.DB.Floor; FilteredElementCollector collectordd = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WherePasses(filterbl); collectordd.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ElectricalEquipment); foreach (FamilyInstance a in collectordd) { rr = a.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString(); if (rr == tag) break; } if (rr == tag) continue; //.FirstElement() as Autodesk.Revit.DB.Floor; transno.Start("create new equipment"); FamilyInstance instance = doc.Create.NewFamilyInstance(center, famsss, floor, StructuralType.NonStructural); Autodesk.Revit.DB.Parameter p = instance.get_Parameter(BuiltInParameter.ALL_MODEL_MARK); p.Set(tag); transno.Commit(); } if(equipmenttype == "Lighting and Appliance Panelboard - 208V MCB - Surface") { string rr = ""; Page | 99 TaskDialog.Show("xxx", rate + " " + equipmenttype); double x = (bounding.Min.X + bounding.Max.X) * 0.5; double y = bounding.Min.Y; double z = bounding.Min.Z + 3; center = new XYZ(x, y+2, z); XYZ aa= new XYZ(x-1,y,z); FilteredElementCollector collectorb = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Wall)).WherePasses(filterbl); FilteredElementCollector collectordd = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WherePasses(filterbl); collectordd.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ElectricalEquipment); foreach (FamilyInstance a in collectordd) { rr = a.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString(); if (rr == tag) break; } if (rr == tag) continue; Autodesk.Revit.DB.Wall wall= collectorb.FirstElement() as Autodesk.Revit.DB.Wall; transno.Start("create new equipment"); FamilyInstance instance = doc.Create.NewFamilyInstance(center, famsss, wall, StructuralType.NonStructural); ElementId id = instance.Id; Autodesk.Revit.DB.Parameter p = instance.get_Parameter(BuiltInParameter.ALL_MODEL_MARK); p.Set(tag); //Autodesk.Revit.DB.Line axis = Autodesk.Revit.DB.Line.CreateBound(center, aa); //ElementTransformUtils.RotateElement(doc, id, axis, Math.PI / 2); transno.Commit(); } break; } } } wb.Save(); wb.Close(0); Excel.Quit(); return Result.Succeeded; } } } Page | 100 Source code of LTE using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.Attributes; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB.Architecture; using Autodesk.Revit.DB.Electrical; using Autodesk.Revit.DB.Lighting; using System.Text.RegularExpressions; using Microsoft.Office.Interop.Excel; using System.Windows.Forms; using System.Windows.Media.Imaging; using System.Reflection; namespace LPDtest { public class CsAddPanel : IExternalApplication { // Both OnStartup and OnShutdown must be implemented as public method public Result OnStartup(UIControlledApplication application) { // Add a new ribbon panel RibbonPanel ribbonPanel = application.CreateRibbonPanel("LPD calculation"); // Create a push button to trigger a command add it to the ribbon panel. string thisAssemblyPath = Assembly.GetExecutingAssembly().Location; PushButtonData buttonData = new PushButtonData("HelloWorld", "LPD tool", thisAssemblyPath, "LPDtest.Command"); PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton; // Optionally, other properties may be assigned to the button // a) tool-tip pushButton.ToolTip = "Calculate the LPD for space"; // b) large bitmap Uri uriImage = new Uri(@"C:\Users\huan5\Desktop\thesis-new\pic\program icon\leaf.png"); BitmapImage largeImage = new BitmapImage(uriImage); pushButton.LargeImage = largeImage; return Result.Succeeded; } public Result OnShutdown(UIControlledApplication application) { // nothing to clean up in this simple case return Result.Succeeded; Page | 101 } } [Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { //Get Revit application Handle #region UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; Document doc = uidoc.Document; #endregion //Room color change based on calculation result #region //Green color indicate such room type does not exist in standard Transaction transno = new Transaction(doc); OverrideGraphicSettings noroom = new OverrideGraphicSettings(); noroom.SetProjectionLineColor(new Color(0, 200, 0)); //Red color indicate such room type does not meet the requirement Transaction transfail = new Transaction(doc); OverrideGraphicSettings failroom = new OverrideGraphicSettings(); failroom.SetProjectionLineColor(new Color(200, 0, 0)); #endregion //Parameter delcare #region int count = 0; List<string> alname = new List<string>(); List<double> alarea = new List<double>(); int ExcelCol; string cellvalue = ""; string cellstandard = ""; Range range; Range standardrange; double standard; string res = ""; bool compare = false; string roomnameclear = ""; #endregion FilteredElementCollector collector = new FilteredElementCollector(doc); Page | 102 //Load energy assessment standard #region OpenFileDialog ofd = new OpenFileDialog(); string Excelfile = ""; ofd.DefaultExt = ".xlsx"; ofd.Filter = "xlsx file(*.xlsx)|*.xlsx|All files (*.*)|*.*"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Excelfile = ofd.FileName; } string path = Excelfile; Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application(); Workbook wb = Excel.Workbooks.Open(path); Worksheet ExcelSheet = (Microsoft.Office.Interop.Excel.Worksheet)wb.ActiveSheet; #endregion //collect all rooms FilteredElementCollector a = new FilteredElementCollector(doc).OfClass(typeof(SpatialElement)); //Check each room foreach (SpatialElement e in a) { Room room = e as Room; //Get letters in room.name string roomname = Regex.Replace(room.Name, @"\d", ""); //Get room serial number int roomserial = Convert.ToInt16(Regex.Match(room.Name, @"\d+").Value); // Get room area and name double roomarea = room.Area; for (ExcelCol = 1; ; ExcelCol++) { //Check the cellvalue in first column, if cellvalue is empty, the roomtage is not exist range = (Microsoft.Office.Interop.Excel.Range)ExcelSheet.Cells[ExcelCol, 1]; if (range.Value2 != null) { cellvalue = range.Value.ToString(); } else { TaskDialog.Show("test", "This type of space does not exist in standard!"); transno.Start("changeColor"); uidoc.ActiveView.SetElementOverrides(room.Id, noroom); Page | 103 transno.Commit(); break; } //Check room type in standard. Break the loop when found out correspond roomtype roomnameclear = new string(roomname.Where(Char.IsLetter).ToArray()).ToLower(); string cellvalueclear = new string(cellvalue.Where(Char.IsLetter).ToArray()).ToLower(); compare = String.Equals(cellvalueclear, roomnameclear, StringComparison.Ordinal); if (compare) { break; } } //Get total lighting fixture power in the room BoundingBoxXYZ bb = room.get_BoundingBox(null); Autodesk.Revit.DB.Outline outline = new Autodesk.Revit.DB.Outline(bb.Min, bb.Max); BoundingBoxIntersectsFilter filterb = new BoundingBoxIntersectsFilter(outline); FilteredElementCollector collectorb = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .WhereElementIsViewIndependent() .OfClass(typeof(FamilyInstance)) .WherePasses(filterb); collectorb.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures); double totalpower = 0; if (compare) { res = cellvalue; standardrange = (Microsoft.Office.Interop.Excel.Range)ExcelSheet.Cells[ExcelCol, 2]; cellstandard = standardrange.Value.ToString(); standard = Convert.ToDouble(cellstandard); foreach (FamilyInstance lightFixture in collectorb.Cast<FamilyInstance>()) { if (lightFixture == null) // check null reference continue; FamilySymbol lightfamilysymbol = lightFixture.Symbol; var powerstr = lightfamilysymbol.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD).AsValueString(); double power = Convert.ToDouble(Regex.Replace(powerstr, @"\D", "")); totalpower = totalpower + power; } Double roomLPD = totalpower / room.Area; Page | 104 TaskDialog.Show("Result", "This is a real model"+"\n"+room.Name+"\n"+"Standard value is " + standard.ToString() + "\n" + "Room area is " + room.Area.ToString() + "\n" + "Room lighting power is " + totalpower.ToString() + "\n" + "Room LPD is " + roomLPD.ToString()); if (roomLPD < standard) { TaskDialog.Show("Conclusion", room.Name + "\n"+"pass"); } else { TaskDialog.Show("Conclusion", room.Name + "\n"+"fail"); } } } IList<Element> elems = collector .OfCategory(BuiltInCategory.OST_RvtLinks) .OfClass(typeof(RevitLinkType)) .ToElements(); foreach (Element e in elems) { RevitLinkType linkType = e as RevitLinkType; String s = String.Empty; foreach (Document linkedDoc in uiapp.Application.Documents) { if (linkedDoc.Title.Equals(linkType.Name)) { FilteredElementCollector collLinked = new FilteredElementCollector(linkedDoc).OfClass(typeof(SpatialElement)); foreach (SpatialElement abc in collLinked) { //get room element Room room = abc as Room; if (null == room) { continue; } //Get letters in room.name string roomname = Regex.Replace(room.Name, @"\d", ""); //Get room serial number int roomserial = Convert.ToInt16(Regex.Match(room.Name, @"\d+").Value); //Get room area and name Page | 105 for (ExcelCol = 1; ; ExcelCol++) { //Check the cellvalue in first column, if cellvalue is empty, the roomtage is not exist range = (Microsoft.Office.Interop.Excel.Range)ExcelSheet.Cells[ExcelCol, 1]; if (range.Value2 != null) { cellvalue = range.Value.ToString(); } else { TaskDialog.Show("test", room.Name + "\n" + "This room type does exists in standard!"); transno.Start("changeColor"); uidoc.ActiveView.SetElementOverrides(room.Id, noroom); transno.Commit(); break; } /*Check room type in standard. Break the loop when found out correspond roomtype*/ roomnameclear = new string(roomname.Where(Char.IsLetter).ToArray()).ToLower(); string cellvalueclear = new string(cellvalue.Where(Char.IsLetter).ToArray()).ToLower(); compare = String.Equals(cellvalueclear, roomnameclear, StringComparison.Ordinal); if (compare) { break; } } //Get total lighting fixture power in the room BoundingBoxXYZ bbl = room.get_BoundingBox(null); Autodesk.Revit.DB.Outline outline = new Autodesk.Revit.DB.Outline(bbl.Min, bbl.Max); BoundingBoxIntersectsFilter filterbl = new BoundingBoxIntersectsFilter(outline); FilteredElementCollector collectorb = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .WhereElementIsViewIndependent() .OfClass(typeof(FamilyInstance)) .WherePasses(filterbl); // FilteredElementCollector collectoral = new FilteredElementCollector(doc); collectorb.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_LightingFixtures); double totalpower = 0; Page | 106 if (compare) { res = cellvalue; standardrange = (Microsoft.Office.Interop.Excel.Range)ExcelSheet.Cells[ExcelCol, 2]; cellstandard = standardrange.Value.ToString(); standard = Convert.ToDouble(cellstandard); foreach (FamilyInstance lightFixture in collectorb.Cast<FamilyInstance>()) { if (lightFixture == null) // check null reference continue; FamilySymbol lightfamilysymbol = lightFixture.Symbol; var powerstr = lightfamilysymbol.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD).AsValueString(); double power = Convert.ToDouble(Regex.Replace(powerstr, @"\D", "")); totalpower = totalpower + power; } Double roomLPD = totalpower / room.Area; TaskDialog.Show("Result", "This is a linked model" + "\n" + room.Name + "\n" + "Standard value is " + standard.ToString() + "\n" + "Room area is " + room.Area.ToString() + "\n" + "Room lighting power is " + totalpower.ToString() + "\n" + "Room LPD is " + roomLPD.ToString()); if (roomLPD < standard) { TaskDialog.Show("Conclusion", room.Name + "\n" + "pass"); } else { TaskDialog.Show("Conclusion", room.Name + "\n" + "fail"); } } } } } } wb.Close(0); Excel.Quit(); return Result.Succeeded; } } }
Abstract (if available)
Abstract
Software for the construction industry has progressed in sophistication for approximately the last three decades, with advances seen in cost, ease-of-use, and features. In addition, most software programs allow users the ability to create custom tools either through the use of scripting or accessing the API (application programming interface). Revit is a common building information modeling (BIM) program use by many people in the architecture/engineering/construction industry. One can develop add-ins in C# for simple or complex tasks with the Revit API. ❧ Electrical engineers often do repetitive tasks that would benefit from a Revit add-in that would make them more efficient and accurate. One scenario is that they have to create electrical plans after they finish single line diagrams (SLD). During the process, electrical engineers need to locate every equipment in SLD and place it in the architecture plan, which is a tedious work. In this case, a program that could complete this process automatically would enhance engineers’ efficiency. A tool was developed that could read equipment location and function information in SLD, find the correct location, and place the equipment in this position. The program allows engineers to customize principal and equipment type based on the practical situation. ❧ Another scenario is when electrical engineers assess whether a building meets the LPD requirement of Title 24
Linked assets
University of Southern California Dissertations and Theses
Conceptually similar
PDF
MM Electrical Tool: a tool for generating electrical single line diagrams in BIM
PDF
Automating fire code compliance using BIM and Revit plug-ins
PDF
Streamlining precast back-frame design: automated design using Revit plugin
PDF
Streamlining sustainable design in building information modeling: BIM-based PV design and analysis tools
PDF
Bridging the gap: a tool to support bim data transparency for interoperability with building energy performance software
PDF
CFD visualization: a case study for using a building information modeling with virtual reality
PDF
Using building information modeling with augmented reality: visualizing and editing MEP systems with a mobile augmented reality application
PDF
Building information modeling: guidelines for project execution plan (PxP) for India
PDF
Acoustics simulation for stadium design using EASE: analyzing acoustics and providing retrofit options for the Los Angeles Memorial Coliseum
PDF
Multi-domain assessment of a kinetic facade: determining the control strategy of a kinetic façade using BIM based on energy performance, daylighting, and occupants’ preferences; Multi-domain asse...
PDF
Planning in advance for rehabilitation and restoration using BIM and seismic simulation to record and analyze the Japanese House in Los Angeles
PDF
Building bridges: filling gaps between BIM and other tools in mechanical design
PDF
A BIM-based visualization tool for facilities management: fault detection through integrating real-time sensor data into BIM
PDF
Carbon accounting tool (CAT) in BIM: an embodied carbon plug-in for revit
PDF
Data visualization in VR/AR: static data analysis in buildings
PDF
Pre-cast concrete envelopes in hot-humid climates: examining envelopes to reduce cooling load and electrical consumption
PDF
Building information modeling based design review and facility management: Virtual reality workflows and augmented reality experiment for healthcare project
PDF
A BIM-based tool for accessible design standard plan check: an automated plan review plug-in for Revit focusing on accessible design
PDF
Pushing the solar envelope: determining solar envelope generating principles for sites with existing buildings
PDF
Office floor plans generation based on Generative Adversarial Network
Asset Metadata
Creator
Huang, Lu
(author)
Core Title
Revit plugins for electrical engineering improvements in buildings: Lighting power density and electrical equipment placement
School
School of Architecture
Degree
Master of Building Science
Degree Program
Building Science
Publication Date
07/29/2018
Defense Date
04/26/2018
Publisher
University of Southern California
(original),
University of Southern California. Libraries
(digital)
Tag
BIM,C#: Visual Studio,LPD,OAI-PMH Harvest,Revit,Revit API,SLD
Format
application/pdf
(imt)
Language
English
Contributor
Electronically uploaded by the author
(provenance)
Advisor
Kensek, Karen M. (
committee chair
), Beshir, Mohammed (
committee member
), Noble, Douglas E. (
committee member
)
Creator Email
Huan504@usc.edu
Permanent Link (DOI)
https://doi.org/10.25549/usctheses-c89-39403
Unique identifier
UC11672617
Identifier
etd-HuangLu-6555.pdf (filename),usctheses-c89-39403 (legacy record id)
Legacy Identifier
etd-HuangLu-6555.pdf
Dmrecord
39403
Document Type
Thesis
Format
application/pdf (imt)
Rights
Huang, Lu
Type
texts
Source
University of Southern California
(contributing entity),
University of Southern California Dissertations and Theses
(collection)
Access Conditions
The author retains rights to his/her dissertation, thesis or other graduate work according to U.S. copyright law. Electronic access is being provided by the USC Libraries in agreement with the a...
Repository Name
University of Southern California Digital Library
Repository Location
USC Digital Library, University of Southern California, University Park Campus MC 2810, 3434 South Grand Avenue, 2nd Floor, Los Angeles, California 90089-2810, USA
Tags
BIM
C#: Visual Studio
LPD
Revit
Revit API
SLD