< All Topics

Scripting

Scripting allows you to make demonstration models that can run without being connected to a PLC.

The model below has been set up with a script that allows the motor to start when a load activates the first sensor and a new load to be released when the load activates the second sensor.

  • Open Experior in Physics Mode
  • Place two basic conveyors on the 3D scene and add a motor to the conveyors
  • For the second conveyor instead of adding a new motor select MOTOR1 from the context menu
  • Place a photoeye from the sensor catalog at the red end of the 1st conveyor and one in the middle of the 2nd conveyor
  • Pick a feeder from the basic catalog and place it above the photoeye in the 1st conveyor’s red end
  • Switch to the scripting tab and enter the code as shown below
    public void On(object trigger, string symbol)
    {
        if (symbol == "SENSOR1")
        {
            Motor.Start("MOTOR1");
        }
        
        if (symbol == "SENSOR2")
        {
            Assembly.Activate("FEEDER1");
        }
    }
  • Press F5 to compile the script
  • Switch back to the model
  • Press P to activate run mode
  • Release the first load by double clicking on the feeder
  • The motor starts and when the first load activates the sensor
  • When the load activates the second sensor a new load will be released

 

Target Methods

In addition to the default target methods, you can add the methods listed in the tables below from the context menu which is accessed by right clicking in the scripting area.

  • Motor Started: Use if you want to be informed when a motor starts.
  • Input Changed: Use if you want to be informed when a defined PLC output changes value.
  • Value Changed: Use if you want to be notified when a defined PLC output changes status (only relevant in connection with I/O registers).
  • Position Changed: Use if you want to be informed when an assembly changes position.
  • Message Received: Use if you want to subscribe to telegrams which are received at the connection in question (can only be used with STX/ETX and RFC1006 connections).
  • Telegram Received: Use if you want to subscribe to telegram received events.
  • Step:  Called at every frame update. Activation Assembly specific method, only used for certain customized assemblies.

 

Script Methods

From the script environment you can access all public classes, methods and properties in all the different plugins and catalogs that are linked to Experior.

There are some static classes that makes it easy to make a script. This is not an object oriented approach but for some situations this is okay.

Two of the static classes are already used in the example above – that’s is the Motor and Assembly class. Below you can see the content of all the static script classes:

Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Previous OEM Licence Type
Next Startup Options