Special UI controls for Lights

For ARCHICAD 18, the user interface control choices for Lamps got a little wider, introducing:

  • UI_COLORPICKER: for setting the 3 light color component from the graphical UI
  • UI_SLIDER: a slider control for setting the light intensity, or any integer type parameter

Something similar to these was used to be automatically provided above the old All Parameters list, without the possibility to customize them.
Since hiding the old list is very fashionable these days, scripting these controls on the graphical UI may be necessary.

Special Lamp parameters

Lights have some extra parameter types compared to everyday GDL objects:
HowToLightUI_specParams

  • gs_light_switch: Boolean type, for turning the light ON/OFF
  • gs_color_red: real type parameter for setting the red component of the light
  • gs_color_green: real type parameter for setting the green component of the light
  • gs_color_blue: real type parameter for setting the blue component of the light
  • gs_light_intensity: integer type, to set the strength of the light beam

To get the correct setup, use the Light subtype (General GDL Object/Model Element/Electrical Element/Light) provided by GRAPHISOFT, or create your own sub-subtype.
These parameters also have a special type in the xml format: LightSwitch, ColorRGB, Intensity.

Color picker control

The specialty of this UI control is the ability to set 3 parameter values at the same time. The UI control itself gives access to the color-fusion palette provided by the operating system, therefore the syntax is quite simple:

ui_colorpicker "redParamName", "greenParamName", "blueParamName", posX, posY, controlWidth, controlHeight

The lock command has no effect on this control whatsoever, so simply omit it if the light function is turned off.

Note: you don’t have to use the parameters provided by the Light subtype of GRAPHISOFT. The control works with any 3 real type parameters. Just make sure you use the same 3 parameters in the LIGHT command.

Slider control

This control can be used to visualize any integer parameters, preferably with a predefined range. The segmentation number can be controlled with a command parameter (nSegments), and the slider itself can be horizontal or vertical, depending on the width-height input parameter value relations:

ui_slider "integerParName", posX, posY, controlWidth, controlHeight, nSegments

For convenience, pair the slider control with a regular infield:
HowToLightUI_sliderInfieldPair

Example light UI object for this post can be downloaded here.