Scripting

Cognex Designer provides a powerful scripting environment using Microsoft C# .NET. You can write standard C# .NET code and have it execute within the Cognex Designer environment.

Note: This document does not describe how to use C#, and assumes that the user has a basic understanding of C# programming.

Cognex Designer provides two simple language extensions that allow the C# scripting to access Cognex Designer tags (A) and functions (B):

  1. Cognex Designer uses a special $ character to access tags. To read or write from a tag in a script:
    $BooleanValue = False;
    $IntegerValue = 10;
    $StringValue = "Hello";
  2. Functions use the $ sign as well. Alternatively, you can drag 'n drop from the Tag & Function browser tool window. Recognized functions will be highlighted in the Script Editor.

Note: Published (Cognex Designer or Plugin) methods with 'out' parameters cannot be compiled within a script. For more information, see the Use Methods With "out" and "ref" Parameters topic.

WebPages HMI Scripting

WebPage Elements scripts are used to program the script points for handling WebPage Element events, such as a Button's On Clicked event. These scripts execute in the Web browser running the HMI.