Monday, April 16, 2012

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)

No comments:

Post a Comment