Calling Scripts Via Toolbar Icons

Overview

You can configure up to 32 icons that will be displayed in a toolbar to access Python script files with one click.

Components required:

  • An .ico file defining the icon.

  • A .py file storing the Python script.

  • A config.json file specifying the call information outline for each icon. A maximum of 16 icons can be configured per file.

To configure more than 16 icons, create two config.json files and store each file at one of the following locations:

  • C:\Program Files\Schneider Electric\EcoStruxure Machine Expert\Script Commands

  • <ESME_Installation_Directory\LogicBuilder\Script Commands, for example, C:\Program Files\Schneider Electric\EcoStruxure Machine Expert\V2.0\LogicBuilder\Script Commands

When you start EcoStruxure Machine Expert, the script calls and the related icons are added to the dialog box Tools > Customize in the tab Command Icons, category ScriptEngine Commands. You can add them to a new or to an existing toolbar in the Toolbars tab of the Tools > Customize dialog box.

Elements of the config.json Configuration File

Each config.json configuration file contains the following required and optional elements:

Element

Required

Description

"Name"

Yes

This text is displayed as a tooltip for the icon in the toolbar.

Example:

"Name": "Pause"

"Desc"

No

This element is not used in EcoStruxure Machine Expert.

"Icon"

Yes

This element contains the name of the image file (in .ico format) if the image file is located in the same folder (Script Commands) as the config.json file.

Example:

"Icon": "pause.ico"

If the image file is not located in the (Script Commands) folder, you can add the path information here, such as <directory path>\\<icon name>.ico.

"Path"

Yes

This element contains the name of the Python script file in .py format if the script file is located in the same folder (Script Commands) as the config.json file.

Example:

"Path": "stop.py"

If the script file is not located in the (Script Commands) folder, you can add the path information here, such as <directory path>\\<script name>.py.

"Params"

No

Use this element only if the script requires parameters.

Example:

"Params": [ "file1", "file2" ]

Example of a config.json File

A config.json file can have the following content:

[
   {
      "Name": "Start Process1",
      "Desc": "Processing1",
      "Icon": "process1.ico",
      "Path": "proc1.py",
   },
   {
      "Name": "Start Process2",
      "Desc": "Processing2",
      "Icon": "process2.ico",
      "Path": "proc2.py",
      "Params":
            [
                  "exit"
            ]
      }
]

The folder Script Commands thus contains the following files:

  • config.json

  • process1.ico

  • proc1.py

  • process2.ico

  • proc2.py

The ScriptEngine Commands list of the Tools > Customize dialog box contains the following entries that you can add to a toolbar:

  • Start Process1

  • Start Process2

Click an icon in the toolbar to execute the respective script file.