Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
Hello everybody
I need into a project to disable few device and enable some other using a Python script, but Iβm a beginner with this language and I canβt find a solution.
Someone could help me?
Thank you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
proj=projects.primaryobjs=proj.find('Device_1', recursive=True)assert(len(objs)==1, 'no or more than one object found')assert(objs[0].is_device, 'object is not a device')device=objs[0]
ifdevice.is_enabled():
Β Β print('disable device...')
Β Β device.disable()else:
Β Β print('enable device...')
Β Β device.enable()
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank You so much Martin
Your code works fine
Excuse a last question, something stupid, where can I find the syntax code integrated in Python to handle CoDeSys ? example 'is_device'
BR
Luke
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The documentation is in the file "ScriptEngine.chm" in the sub directory "Online Help" of CODESYS. It's not linked to the online help which you can reach directly from CODESYS.
The scripting interface is in the book "_3S.CoDeSys.ScriptEngine.BasicFunctionality Namespace".
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody
I need into a project to disable few device and enable some other using a Python script, but Iβm a beginner with this language and I canβt find a solution.
Someone could help me?
Thank you
Hi Luke.
Here my sample code:
BR
Martin
Thank You so much Martin
Your code works fine
Excuse a last question, something stupid, where can I find the syntax code integrated in Python to handle CoDeSys ? example 'is_device'
BR
Luke
Hi Luke.
The documentation is in the file "ScriptEngine.chm" in the sub directory "Online Help" of CODESYS. It's not linked to the online help which you can reach directly from CODESYS.
The scripting interface is in the book "_3S.CoDeSys.ScriptEngine.BasicFunctionality Namespace".
BR
Martin
Thank You another time Martin