Sunday, December 5, 2010

API Development and Application



Creating Revit Architecture 2010 API


In the earlier section creating the solar PV parametric family was discussed. In this section an API application is created in C# that gets parameter values from Revit project either as type or as instance parameters and sets them to certain values stored in an excel database. One of the challenges was that there is no dll file for accessing an excel database for 64 bit operating system and hence; a CSV format file is used to access database values. Following diagram illustrates the procedure.


Process

1. Getting Revit architecture 2010 type parameters using family instance ID and its parameter values: Solar altitude and azimuth angle govern the resulting position of sun in the sky at a particular time (hour and day). Two parameters of solar altitude and azimuth angle are obtained from Revit Architecture 2010 project using C# code.
Code for getting element ID
2. Creating a user interface: A window’s form is developed using the C# programming that includes text boxes for user input. This form is designed for future use also and hence contains some additional text boxes. For the purpose of this project, only one text box would be used to input hour of the day. This form would calculate/access and show solar altitude and azimuth value for the input time. After clicking show PV position it would change the PV orientation and would show it.
User interface form
Code for accessing csv database

3. Creating a database for sun positions: A Microsoft Excel file is used to calculate solar altitudes and azimuth values. This file is saved as a CSV format file in order to make accessible from 64 bit operating system. This file contain three columns and nearly 132 rows for solar altitudes and azimuths for every 6 minutes (6 minutes as 0.1) interval. Therefore, on of the limitation is that user can only input a time in 6 minutes interval.
Sample of sun position database in csv format and altitude & azimuth illustration

4. Setting these values to database values based on user input: User would input time value in a windows form (see figure below) and API would search access relevant data from CSV format database and set its value to Revit parameters. A CSV format database of solar altitude and azimuth is created for 5 June 2010. Use inputs time in decimal e.g. morning 8:30 would be input as 8.5 and afternoon 2:30 would be 14.50. 
Code for getting type parameters from Revit project and setting them to value from csv database

Whenever add in API is triggered window’s form appears (see figures below) and user inputs time value in the form. API, based on these values, sets solar altitude and azimuth data from excel/CSV database. Changed values would be returned to Revit Architecture 2010 to make changes in the family parameters and changed drawings would be displayed.

Instructions for Use

Although these families are designed as standalone parametric families but these can be directly loaded into the project. The pergola family can be applied to any outdoor spaces and host project's parameters can be assigned to the family parameters. 

Makes sure, AutoDesk Revit Architecture 2010 possesses add in capabilities. Click on add in and then select "Add in Manager (manual)" from external tools drop down menu.A dialogue box would appear as shown in figure below. As a suggestion, remove existing file by selecting and clicking remove and load relevant dll file. Go to relevant folder e.g. for pergola go to pergola folder>Pergola_Revit API>Revit API>bin>Debug>UserDefinedParameterReadWrite.dll. Select this file and run it. Similarly for sloping roof family, first load appropriate file and run the add in tool.

Dialogue box after running add in tool

A user interface form as shown earlier would appear. Input desired time in a day. Make sure that time is put in the interval of 6 minutes (e.g. 5.5, 5.6, 5.7 ) and it is in the range of  5:30 am and 6:30 pm (as most of the solar energy potential fall in this range). This is the limitation of this project, however remaining time can also be included in the database. 

User interface showing input time

Click calculate button and a message box would pop up to show you input time you just entered. Click OK and it would show azimuth and altitude values for that time in the text boxes on the form. Click show position and it would change solar panels position based on altitude and azimuth at entered time. To repeat, click again on add in manager.

Application

After applying this application to a project that is loaded with earlier developed PV parametric family, solar panels changed their orientation based on entered time. Following figures show results at two different times.

Sloping Roof Example: Solar PV positions at two different times




Pergola Example: Solar PV positions at two different times






Watch pergola and sloping roof family with PV panel changing their position in motion

Pergola Video:

Sloping Roof Video: 


Limitations

Current limitations of this project are mainly related to database capabilities, as currently used database holds only one day's data. However, this project is just for demonstration of Revit API that facilitates interaction between two programs. Some other limitations include, current inability to produce solar power schedule for economic evaluation of solar PV options.

Future Work


Future development would include developing a comprehensive data for the entire year. Current location selected is College Station, TX but other location may also be connected. Web sites that advertise and sell building integrated PVs could also be integrated in this system in order to enable user selecting PV of his/her choice. 

No comments:

Post a Comment