Tuesday, April 17, 2012

Revit API Demostration Video


Higher Quality:
http://www.youtube.com/watch?v=ANjJd_MdFvs

Future Work

If I had more time in the future to work on this Revit Model, I would like to research into creating a ribbon function for my mass model parametric intent. I have different parametric options for the user to choose from in the mass model and I would like to be able to put the interface to the parametric paths within the project user interface. By doing this, I would be able to guide the user better by creating drop down menus, buttons, input prompts, etc. to creating their customized mass model.
I believe the first step to doing this is by researching the methods to creating a ribbon panel with Revit API. The first resource I found was from the Revit 2011 API Developers Guide which has a enormous list of Revit API tools and functions that can assist with Revit API. The guide has a sections on ribbon panels to where they use functions called “Pushbutton”, “PulldownButton” and “Text Box” which creates the tools needed for me to create the parametric user interface. Other sites like Spiderinnet’s Blog and Autodesk Wikihelp has many tutorials that can assist me in developing the ribbon panel.

Autodesk (2010). “Revit 2011 API Developer Guide.” <http://www.scribd.com/doc/67901685/Revit-2011-API-Developer-Guide>. (4/16/2012).

Buidling Snapshot With Color Randomization


Project Building with Randomized Curtain Panels:

Figure 28: Building with All Panels Randomized

Figure 29: Building  with API Design Intent



Monday, April 16, 2012

Revit API Issues


Revit API Error Message:
One of the major issues I encounter when running the API code on my project file was the error message shown in Figure 33. This error message was due to the fact that the API code could not gather any instance parameters to change. In my mass family, I had type parameters for the materials of the curtain panels and this did not allow the API code to change each individual curtain panel due to the definition of a type parameter. So all I needed to do was change all of the material type parameters to instance parameters and the error was fixed.

Figure 33: C# Error message
Revit API Double Random Colors:
The second major issue I had with my API code was to make the code generate two significantly different colors for the flat face panels and the corner void panels in the full model. In Figure 29, the two panels look somewhat similar but are actually different based on the RGB integers. I thought at first that it was just a coincidence and the color just happened to turn out that way, but running it a second time slashed that theory. The pattern just kept on repeating itself. It was odd because with my small test, I knew that the two loops within the API code were engaging the right sets of panels and the two randomly generated colors were different for the two panels, so the issue must lie within the random number assignment for large scale projects. So I adjusted the limits of the random function to only choose RGB between 0 and 130 for the flat faces and 130 to 255 for the corner faces. This does limit the amount of color I would be able to generate however it gives me the necessary function to reach my design intent. 

Revit API Testing


To test the API Code, I created a project file with only one of the bay level and ran the API code with the minute amount of panel it has compared to the full model. This was a great timesaver as it only takes me 5 mins to complete the program as compared to 45 mins for the full model. Once I was able to get the fully randomize code running, I continued to modify the code to randomize base on my design intent.

Single Bay Level Mass Models with Randomized Curtain Panels:

Figure 26: Bottom Bay All Panels Randomized

Figure 27: Bottom Bay with API Design Intent

Revit API Procedure


My final goal for the Revit API code was to randomize two different sections of curtain panels for my BIM model: The flat face panels on the sides of my structure, and the corner void faces of the structure. I used the “Curtain Panel” example provided within the Project 2 sample files as a basis for the code. This API code randomizes the colors of the curtain panels for two different cases, one being if the curtain panels were made within a mass family and imported into a project file and two being if the curtain panels were created within the project file itself. My curtain panels were created within the mass family so case 1 of the API code was used and everything else was removed, including any thickness adjustment code that would have been performed.
The API Workflow for this code is:


I did not want to randomize the colors of each of the panels within the model individually so the creation of the red, blue, and green color integers was removed from the loop that repeats for every panel. The assignment of numbers for the RGB colors was coded before the loop so that for every panel that the loop would engage, it would assign the same color. This was also repeated for the second loop function that is for just the corner face panels.
In order to get the pair of loops to only engage their corresponding sets of curtain panels, I modified the inputs for the boundaries of the For loop. So for loop 1 that engages the flat face curtain panels the boundaries were from 0 to the length of the IDS vector that stores the Panel ID’s minus 36. The boundaries for loop 2 were from length of the IDS vector minus 36 to the length of the IDS vector. The number 36 originates from the finite number of corner panel faces in the BIM model.  For this part of the API code, it is required that the user copy the ID’s of the curtain panels in this order: Flat Faces, Base Level Faces, and Corner faces. In the code:

1.       Loop 1:  for (int n = 0; n < IDS.Length-36; n++)
2.       Loop 2:  for(int n = IDS.Length-36; n < IDS.Length; n++)

Other small changes to the original curtain panel code were changes in the Project ID and the curtain panel ID’s and also the addition of another random variable function for the second loop. 




Figure 25: Snapshot of C# API code for Curtain Panels (loop section)

Revit API Design Intent


Once the models were complete, I wanted to use Revit API to randomize the colors of the exterior curtain panels on the flat faces of the building and the corner void faces of the building independently. I believe the building appeal is in the uniformity of the exterior truss system and how its symmetry and solid colors help a person’s eye flow from the bottom of the tower to the top. Any discrepancies in the color scheme would distort the view flow and take away from the overall appeal of the truss system and its skin. So with Revit API, I will be randomizing the colors of the two different locations of curtain panels in the Revit Model so that the skin of the building will keep its consistency within flat faces of the building and the corners will contrast more from those flat faces to show more of the geometric shape of the structure.