Automatic code generation using Python and Automation Studio
In this article, I'll explain how you can use Python alongside Automation Studio to generate code automatically and get to the next level of your industrial automation journey. Without further ado, let's talk about some of the advantages and uses case.
Advantages
Use cases
There are many other use cases, but here are the ones I'm using the most on a day-to-day basis
Below will be an example of me creating a Conveyor module based of my Template module and instantiating it 2 times. I'll click on most of the files that the scripts generate. The intent is not to explain everything that's happening, but just to notice how much work is done automatically in seconds.
Recommended by LinkedIn
How to develop your script
It's important to understand that almost every file in Automation Studio is text-based. That means you can quite easily make changes to any of them using Python.
In my opinion, your script should have at least the following class in order to be efficient
With the 5 classes above, you'll be able to navigate automatically anywhere in your project and perform changes to the files you want easily.
Please note that you'll need to have strong coding guidelines. You can't make a script if the files structure you're parsing are always different.
Disclaimer, I'm not a python programmer. I'm probably bad at best, but this skill level is sufficient in order to produce useful script.
End of post! Please leave a comment if you use automatic code generation already or if you found that topic interesting.
If you're an innovative machine builders or an end-user that wants to do complicated project involving AcoposTrak, Acopos6D along with some robots for flexible manufacturing, please reach out. We've got the software engineering skills to get you up and running in no time!
Interesting! I’ve always pondered the idea of scripting up a tool that would convert Python language to rslogix xml. Allowing you to write PLC programs with Python language. Would be really cool!
And if you want to add a GUI quickly to the python script, you can use the DelphiVCL or DelphiFMX python module which bridges the power of #Delphi and its rock solid UI frameworks with the flexibility of python and the python4Delphi bridge: https://www.embarcadero.com/new-tools/python/delphi-4-python
Brillant. Compare to the old fashion with for example macros in Excel, this class looks like really more modern.👍👍👍
Excellent use case for bringing python into the automation workflow! I also use it to translate excel based alarm lists into the mappAlarmX format!