The project created by the script contains the "LibraryManager", but not the standard POU 'PLC_PRG' and not the 'Taskkonfiguration'.
Where have I made a mistake?
CoDeSys V3.4 SP3 Hotfix 1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have just tried out with CoDeSys V3.4 SP3 Patch 2 ==> It works
Was is a bug in CoDeSys V3.4 SP3 Hotfix 1?
I only changed the device version (3.4.3.0 ==>3.4.3.20):```
I am not 100% sure, but I believe it is related to the device description file of the PLC.
If you haven't un-installed the previous version, you could choose the new device description in this older version and run the script again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
jbo hat geschrieben:
I have just tried out with CoDeSys V3.4 SP3 Patch 2 ==> It works
Was is a bug in CoDeSys V3.4 SP3 Hotfix 1?
I only changed the device version (3.4.3.0 ==>3.4.3.20):\# add PLC
proj.add("LMC_PacDrive",4096,"0000 0001","3.4.3.20
Sorry, that was a mistake.
It does not work
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually that is the normal behaviour, because you start a new empty project and then add the Device.
With the (manual) CoDeSys File New "Wizard" you can choose a standard project which let you select the Device and POU language. Only then it will add the Task and PLC_PRG automatically.
With the script I think the only solution is to add this yourself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-21
Originally created by: Maximilian.Blase
jbo hat geschrieben:
Hi,
is it possible to insert a new POU by Python script?
Best regards,
jbo
Hi @ all,
over four years have passed since the last entry. Therefore i wannted to ask again, if it is now possible to create a new POU or DTU with Python without xml im- and export.
Best regards,
M. Blase
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maximilian.Blase hat geschrieben:
Hi @ all,
over four years have passed since the last entry. Therefore i wannted to ask again, if it is now possible to create a new POU or DTU with Python without xml im- and export.
Right now, this is not yet possible, but this improvement is already listed in our Jira tracker CDS-44087 , so it will be implemented eventually.
Since CODESYS V3.5 SP6 you can read and write the textual declaration and/or implementation part of POU objects which have one. Search for "IScriptTextDocument" and "IScriptTextualObjectMarker" in the ScriptEngine documentation.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-21
Originally created by: Maximilian.Blase
Hi Martin,
let me first say thank you for your very quick response. Less than 30 minutes. I am impressed. Also it is a little bit funny because we are both from germany. Who cares.
M.Keller hat geschrieben:
...
Since CODESYS V3.5 SP6 you can read and write the textual declaration and/or implementation part of POU objects which have one. Search for "IScriptTextDocument" and "IScriptTextualObjectMarker" in the ScriptEngine documentation.
...
I've already read about this possibility and so this was my intention at the second step. But at first i have to create new POUs and DTUs, or? Otherwise the objects have to be generated in the past manualy. This is the point i want to avoid.
Best regards,
Maximilian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-22
Originally created by: M.Schaber
Hi,
Yes, they have to be created - but for creating them, you could always use the same PLCOpenXML template of an empty POU, which you could even embed as a string into your Python script. Then use rename and text editing functions to populate it.
HTH,
Markus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Schaber hat geschrieben:
Hi,
Yes, they have to be created - but for creating them, you could always use the same PLCOpenXML template of an empty POU, which you could even embed as a string into your Python script. Then use rename and text editing functions to populate it.
HTH,
Markus
Is it possible that only POUs from type Function_Block can be edited with the IScriptTextDocument Methods.
Because a POU of type Program returns at request for has_textual_declaration and has_textual_implementation both with false (3.5 SP7), while returning true for type of Function_Block.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-02-29
Originally created by: M.Schaber
Hi,
PLKM hat geschrieben:
Is it possible that only POUs from type Function_Block can be edited with the IScriptTextDocument Methods.
Because a POU of type Program returns at request for has_textual_declaration and has_textual_implementation both with false (3.5 SP7), while returning true for type of Function_Block.
In my test, it works with SP7.
One common mistake is that your script might work on the Task Call object below the Task configuration which is calling your PROGRAM - it has the same name as the PROGRAM it calls, and thus the script might accidentally find it, instead of the PROGRAM itself.
If that is not your problem, please send a stripped-down example project and script to e support@codesys.com e , so we can reproduce and fix the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Schaber hat geschrieben:
Hi,
In my test, it works with SP7.
One common mistake is that your script might work on the Task Call object below the Task configuration which is calling your PROGRAM - it has the same name as the PROGRAM it calls, and thus the script might accidentally find it, instead of the PROGRAM itself.
If that is not your problem, please send a stripped-down example project and script to e support@codesys.com e , so we can reproduce and fix the problem.
My fault. As you said i had chosen the PLC_PRG task instead of the PROGRAM itself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
is it possible to insert a new POU by Python script?
Best regards,
jbo
If you have already created it and exported it to .xml (manually), you can import it with a script.
See my post about import XML.
Originally created by: M.Schaber
Hi, Jbo,
As TimvH wrote, it is possible to insert a POU via PLCOpenXML import (and in 3.4 SP4 also in the normal standard export format).
PLCOpenXML can be imported from a file and from a string, that means that you can even "embed" the POU XML as a multiline string in your script.
Markus
Hi TimvH, Hi M.Schaber,
many thanks for your answers.
Background of my question:
I created a new project by the following Python-Script:
The project created by the script contains the "LibraryManager", but not the standard POU 'PLC_PRG' and not the 'Taskkonfiguration'.
Where have I made a mistake?
CoDeSys V3.4 SP3 Hotfix 1
I have just tried out with CoDeSys V3.4 SP3 Patch 2 ==> It works
Was is a bug in CoDeSys V3.4 SP3 Hotfix 1?
I only changed the device version (3.4.3.0 ==>3.4.3.20):```
# add PLC
proj.add("LMC_PacDrive",4096,"0000 0001","3.4.3.20
```
I am not 100% sure, but I believe it is related to the device description file of the PLC.
If you haven't un-installed the previous version, you could choose the new device description in this older version and run the script again.
Sorry, that was a mistake.
It does not work
Actually that is the normal behaviour, because you start a new empty project and then add the Device.
With the (manual) CoDeSys File New "Wizard" you can choose a standard project which let you select the Device and POU language. Only then it will add the Task and PLC_PRG automatically.
With the script I think the only solution is to add this yourself.
Originally created by: Maximilian.Blase
Hi @ all,
over four years have passed since the last entry. Therefore i wannted to ask again, if it is now possible to create a new POU or DTU with Python without xml im- and export.
Best regards,
M. Blase
Hi M. Blase.
Right now, this is not yet possible, but this improvement is already listed in our Jira tracker CDS-44087 , so it will be implemented eventually.
Since CODESYS V3.5 SP6 you can read and write the textual declaration and/or implementation part of POU objects which have one. Search for "IScriptTextDocument" and "IScriptTextualObjectMarker" in the ScriptEngine documentation.
BR
Martin
Originally created by: Maximilian.Blase
Hi Martin,
let me first say thank you for your very quick response. Less than 30 minutes. I am impressed. Also it is a little bit funny because we are both from germany. Who cares.
I've already read about this possibility and so this was my intention at the second step. But at first i have to create new POUs and DTUs, or? Otherwise the objects have to be generated in the past manualy. This is the point i want to avoid.
Best regards,
Maximilian
Originally created by: M.Schaber
Hi,
Yes, they have to be created - but for creating them, you could always use the same PLCOpenXML template of an empty POU, which you could even embed as a string into your Python script. Then use rename and text editing functions to populate it.
HTH,
Markus
Is it possible that only POUs from type Function_Block can be edited with the IScriptTextDocument Methods.
Because a POU of type Program returns at request for has_textual_declaration and has_textual_implementation both with false (3.5 SP7), while returning true for type of Function_Block.
Originally created by: M.Schaber
Hi,
In my test, it works with SP7.
One common mistake is that your script might work on the Task Call object below the Task configuration which is calling your PROGRAM - it has the same name as the PROGRAM it calls, and thus the script might accidentally find it, instead of the PROGRAM itself.
If that is not your problem, please send a stripped-down example project and script to e support@codesys.com e , so we can reproduce and fix the problem.
My fault. As you said i had chosen the PLC_PRG task instead of the PROGRAM itself.