Skip to main content

Scripting in CODESYS

Using the scripting functionality in CODESYS, you can automate commands or complex program operations which would otherwise require manual mouse clicks and text input in the CODESYS user interface. For this purpose, scripts based on (Iron)Python can be created and started from the CODESYS user interface (command or configured toolbar) or from the Windows command line.

Examples of use cases

  • Integration of CODESYS in automatic build server environments

    • Continuous Integration (CI)

    • Continuous Delivery (CD)

    • Continuous Testing

  • Integration with third-party software

    • Code generators

    • Creation of projects that are custom tailored to a specific machine configuration

  • Creation of documentation

  • Updating of libraries

    • Setting of project information during the release process

  • Automatic testing

    • Mostly in connection with the CODESYS Test Manager

  • Outputting variables via monitoring APIs

Script language, Script editor

The CODESYS scripting language is modular and based on IronPython. For this purpose, the CODESYS ScriptEngine component combines the IronPython interpreter with the CODESYS development environment. Then you can use the extensive Python framework libraries, which includes file access in networks and much more.

CODESYS does not yet include its own Python editor. Create your scripts with any text editor or the Python editor.

For more information, see: Creating a Python Script

Architecture of the ScriptEngine, Extension possibilities

The (Iron)Python scripting language used in CODESYS allows for access to the CODESYS Scripting APIs to control CODESYS processes. Moreover, it lets users effectively apply both the Python standard library and third-party Python modules, as well as third-party .NET framework libraries and .NET assemblies.

Users can execute the scripts from menu commands or configured toolbars in the CODESYS interface or from the Windows command line. Add-ons such as the CODESYS Test Manager also provide ways to execute scripts.

_cds_img_scriptengine_architecture.png

With the Automation Platform APIs, the ScriptEngine APIs can be extended. Examples for this are CODESYS Test Manager and CODESYS SVN. Both provide their own objects and methods as an extension to the scripting APIs. In addition, the CODESYS Test Manager allows for the execution of scripts in a test case. For more information, see the respective API documentation of the add-ons.

Registered Automation Platform users will find more information in the CODESYS Developer Network.

For more information see: CODESYS scripting API