Script Editor

You can click the scripting button in the toolbar to open the script editor. The script editor supports code auto-completion and intellisense. Type and syntax errors are automatically detected. All built-in types, functions and properties are fully documented. You will use the TypeScript API to create your own components/tools.

File Explorer

The file explorer is where you can create, delete, edit and rename files.

Create Files

To create a new file, click the add button and enter a name for the file. A template window will open that allows you to quickly create a component, tool, value converter or any other file. For example, if you select component, the boilerplate code required for a component will be used as the initial contents for the file.

The ProtoTwin API uses TypeScript, so for components, tools and value converters, the .ts file extension is required. You can also drag and drop files into the explorer from your local drive. Common examples include .json files, .txt files, .onnx files or .csv files.

Edit Files

You can edit a file by selecting a file from the file explorer and then modifying its contents in the main window. A white dot will appear to the right side of the files name in the file tab, which indicates that a file has unsaved changes. You can use CTRL + S to save a file after you are happy with the modifications you’ve made.

Delete Files

To delete a file, right click on the file in the file explorer and click delete.

Rename Files

To rename a file, right click on the file in the file explorer, click rename and enter a new name.

Components

Components allow you to add custom behavior to entities or parts of your model. They allow you to create scripted logic, control machines, change the visual appearance of parts and much more. Please see the components page for more information about scripted components.

Tools

Tools allow you to execute code through the UI. With tools you can programmatically do things like: create entities, delete entities, add components to entities, remove components from entities, select entities, change the properties of an entity or a component and more. Please see the tools page for more information about tools.

Value Converters

Value converters allow you to apply functions to values as they are transferred between the ProtoTwin client and the PLC. This is particularly important for controls testing and virtual commissioning. Please see the converters page for more information about value converters.

Auto-Complete

The script editor in ProtoTwin supports code auto-completion, which predicts the code that comes next. For example, after typing:

public sensor:

The following code will be suggested:

public sensor: Handle<SensorComponent> = this.handle(SensorComponent);

The auto-complete feature is not as powerful or as intelligent as Torq, but should help speed up creating scripted components and tools. It is suggested in one of the following cases:

  • After typing a special character such as a : or = or . symbol
  • After typing Enter after a comment, which will suggest a multi-line code completion
  • Using the ALT + Z keyboard shortcut