Programmatically Modifying the Appearance of a Decoration in LabVIEW

Updated Nov 25, 2020

Environment

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

How can I programmatically modify the appearance of decorations while a VI is running? For example, I may want to change the dimensions, position, color, or text of a decoration. 

Decorations can be programmatically controlled in LabVIEW through property nodes. The steps below describe a method to obtain programmatic access to decorations:
  1. Add a VI Server Reference to the block diagram by right-clicking to show the Functions Palette » Application Control subpallete » VI Server Reference.
  2. Right click the VI Server Reference and select Create » Property for VI Class » Front Panel.
  3. Right-click the Front Panel Reference terminal and select Create » Property for Panel Class » Decorations[]. This gives you an array of reference to all of the decorations on the front panel.
  4. Place an Index Array, Programming » Array » Index Array on the block diagram.
  5. Create a constant to wire to the Index terminal and wire the Decorations[] terminal to the n-dimension array terminal.
  6. Right-click the output of the Index Array and select the desired property in the Create » Property for Decoration Class menu.
  7. Right-click the Decoration Class property node and select Change All To Write.
  8. Right-click the input to the desired property and select Create » Control.

Note: This image is a LabVIEW snippet which includes LabVIEW code that you can reuse in your project. To use a snippet right-click the image, save it to your computer and drag the file onto your LabVIEW diagram.
In order to specifically edit the text of a free label, follow steps 1-5 above and then continue with the following steps:
  1. Add a To More Specific Class VI to the block diagram. Right-click the block diagram and select Programming » Application Control » To More Specific Class.
  2. Right click the Target Class terminal and select Create » Constant.
  3. Specify the Text class by clicking the To More Specific Class and selecting Generic » GObject » Decoration » Text » Text. 
  4. Right-click the Specific Class Reference terminal and select Create » Property for Text Class » Text.

Note: This image is a LabVIEW snippet which includes LabVIEW code that you can reuse in your project. To use a snippet right-click the image, save it to your computer and drag the file onto your LabVIEW diagram.