Scripting Basics

About Python

While it is entirely possible to create a complete and powerful project in Ignition without writing a line of script, many designers will find that in order to complete projects with specific requirements, they need to learn at least a little Python. In our experience, most industrial projects involve lots of very complex and specific requirements.

The good news is that learning Python is easy and enjoyable . Python is one of the most beautiful programming languages we've ever encountered. It is very easy to read - even if you don't know it at all, you will probably be able to understand a basic Python script. It is frequently called "executable pseudocode". If you find yourself doing a lot of scripting, you may want to pick up a basic reference book about Python.

This section is a short tutorial which should help get you started. It goes over all of the core concepts you will need for scripting in Ignition.

Testing your Scripts

The majority of your scripts in Ignition are going to be event driven, and simple to test based on the event that drives them. There are a few ways that you can test out your scripts before using them in a live project. In the Designer, you can turn on Preview Mode and watch your scripts complete. This is especially easy for button click events, since you only have the click the button. For more complex events there is a scripting console that allows you to run your code directly, without the need to recreate other events. This might be useful if you are testing code that relies on many things and you don't want to set all of them just to test this code.

Getting Help with Scripting

Scripting is one of the topics in Ignition that users frequently need help with, because it is used to achieve some of the most complex requirements of a project. If you get stuck designing a script, or would like help getting started, don't hesitate to get some help from our user forum at http://www.inductiveautomation.com/forum, it is by far the best place for scripting help.

When asking for scripting help - be precise and complete. If you're working through an error - include the text of the error, the circumstances, and the offending code. If you're stuck on something, it is helpful to describe the broader goals of what you're trying to accomplish - there is often an easy way and a hard way. Don't be shy to simply ask for some direction getting started.

In This Section ...