You are here: Start » Extensibility » Creating User Types

Creating User Types

Adaptive Vision Studio allows for defining user's own types. This can be especially useful when it is needed to pass multiple parameters conveniently throughout your application or when creating User Filters.

The user can define a structure with named fields of specified type as well as his own enumeration types (depicting several fixed options).

For example, the user can define a structure which contains such parameters as: width, height, value and position in a single place. Also, the user can define named program states by defining an enumeration type with options: Start, Stop, Error, Pause, etc.


In an example project information such as: part name, part width, part height and its tolerance is needed for checking product quality. All this data must be accessed during image analysis.

This problem can be solved without user defined types, but creating a lot of connections can make the program structure too complex. Images below show a comparison between working with a user's structure and passing multiple values as separate parameters.

A solution without user types – more connections, less readable.

A solution with user types – fewer connections, more readable.

Creating User Types in Program

To create your own type use the graphical editor described below. Alternatively you can save your project, open the main AVCODE file (e.g. with Notepad) and at the beginning of the file enter a type declaration:

struct Part
	String 	Name
	Real	Width
	Real	Height
	Real	Tolerance

Save your file and reload the project. Now the newly created type can be used as any other type in Adaptive Vision Studio.

After reloading the project the custom made type is available in Adaptive Vision Studio.

Also custom enumeration types can be added. Such types can represent a list of predefined options. To create a custom enumeration type add the code below to the top of your AVCODE file.

enum PartType

Custom enumeration types can be used like other types.

Graphical User Type Editor

Beginning with Adaptive Vision Studio 4.10 a graphical user type editor is available. It can be used to create and change user types during application runtime and doesn't require you to manually edit code files.

Graphical user type editor.

You can open the editor from the Project Explorer window.

Use this icon to open the graphical editor.

Accessing Structure Fields

To access information contained in a user structure its fields must be expanded. The picture below shows how to expand a type on an input of a macrofilter.

User type fields expanded on a macrofilter's inputs.

User type objects can be created with the CopyObject filter.

User type fields expanded on the CopyObject input.

User defined types can also be accessed with formulas.

Computation using the user defined type.

Saving User Types

User defined types work in Adaptive Vision Studio, so filters such SaveObject, WriteToString, WriteToXmlNode or TcpIp_WriteObject can be used to store and transfer user data.

Related Program Examples

User defined types can be studied in the following Program Examples: Brick Destroy, User Defined Types, User Filter With User Defined Types.

Previous: Debugging User Filters Next: Designing HMI