In previous project, I created the model of Allianz Arena, a soccer stadium in Munich, Germany. One feature of this stadium is that it changes its color at night based on the host team. Since the stadium is the home to
two clubs - Bayern and TSV 1860, when Beyern has a game, the stadium will appear red; and when
TSV 1860 has a game, the stadium will appear blue. If there are other teams have a game, the stadium will appear white.
two clubs - Bayern and TSV 1860, when Beyern has a game, the stadium will appear red; and when
TSV 1860 has a game, the stadium will appear blue. If there are other teams have a game, the stadium will appear white.
To realize the effect, I put lights behind the curtain panels, by changing the color of the lighting, the stadium will appear different effects.
Method & Implementation
First of all, I do some changes in the model. I put lights on 4th to the top floors. The lights are placed just
behind the curtain panels, so that I can use them to light the whole stadium. The key point is to change
the color of the lighting, I manually change the light color filter to get the color I want. To assure the lighting
effect, I make some adjustment to the material of the curtain panels - set the color into white, reflectance as
90%, transmittance as 100%.
behind the curtain panels, so that I can use them to light the whole stadium. The key point is to change
the color of the lighting, I manually change the light color filter to get the color I want. To assure the lighting
effect, I make some adjustment to the material of the curtain panels - set the color into white, reflectance as
90%, transmittance as 100%.
Secondly, I need to set a parameter to input the name of the host team. This parameter is very important,
because it will drive the color change. Since the color change control the effect of the whole stadium, I set
this parameter under the mass family. Later, I will change the text content of this parameter, combining with C# program, I can realize the color change.
because it will drive the color change. Since the color change control the effect of the whole stadium, I set
this parameter under the mass family. Later, I will change the text content of this parameter, combining with C# program, I can realize the color change.
The third part is to build the code with C# Express.
Basically, there are six steps:
1. Initialize, get the project, and start a transaction
2. Get objects by Ids
3. Get parameters of the objects
4. Get values of the parameters
5. Set parameters of objects using new values
6. Commit the transaction and terminate the API program
I would discuss step 2 to step 5, which is the essence in the source code.
In step 2, I get the Id of a light instance at the project level. The light is selected randomly, because later
I will change the type parameter of the light. Any instance from the family enables me to access to the type parameter.
I will change the type parameter of the light. Any instance from the family enables me to access to the type parameter.
Step 3 includes two parts:
1. Get instance parameter of the objects
For mass family, I need the parameter of "HostTeam", which is the driving
parameter of the color change.
2. Get type parameter of the objects
For the light instance, use its Instance Id to get its Type Id. Under the Type Parameters, the Color Filter
parameter is what I need finally, and it will be changed according to the HostTeam parameter.
parameter is what I need finally, and it will be changed according to the HostTeam parameter.
Step 4 is the instruction of the color coding.
In C# program, LightColor -
16711680 represents Blue,
225 represents Red,
Step 5 is to calculate the new values of the light color.
It is decided by the HostTeam.
Red for "Bayern"
Blue for "TSV 1860"
Finally, once the source code project is built successfully, I can run it in Revit model.
In Revit, select the mass family, for the HostTeam parameter, change its text content to "Bayern".
Then use the Add-In-Manager tool to run Project2.dll file. We can see the effect from the Lights view
under 3D views. By rendering with exterior artificial only setting, the stadium will appear red lighting effect.
Then use the Add-In-Manager tool to run Project2.dll file. We can see the effect from the Lights view
under 3D views. By rendering with exterior artificial only setting, the stadium will appear red lighting effect.
If we change the HostTeam parameter, and run Add-In-Manager, we will see the lighting effects accordingly.
Results
Reference
1. For Light Color Filter parameter
2. For Color Code