I'm trying to modify the "ProjectInfoExample.py" example script, to write all Standard library/project attributes (of course only the ones which a writable, I know that the Project attribute *.project is read only).
In the example file there's company, title, version, default_namespace, author and SpecialDeviceId. But there are also IsEndUserLibrary, LanguageModulAttribute and SpecialDeviceId.
I wasn't able to find a Definition of the Standard attributes in the help file...
best regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-13
Originally created by: M.Schaber
hi,
I don't have your "ProjectInfoExample.py" example script. But my "ProjectInfoCreation.py" script which seems to circulate contains the following snippet:
As the commment says, this is an example of how to set custom values which are not covered by the explicit API. There is no "registry" of valid values - an End-User can just define a value for his own company (by convention), and then access it e. G. via the generated IEC code. Also, OEMs can extend CODESYS with their own plugins, and thus define values which have "real" semantics for their plugins.
The api was modeled after the fields which were available in the CODESYS UI back then. As the project settings UI allows to set arbitrary values on the "Properties" tab page, the scripting API also provides this possibility via the dictionary interface.
Some of those values are recommended by the coding guidelines (which are included in the online help), for example, see the Section Libraries -> Guidelines for creating Libraries -> Library Development Summary -> CODESYS LibDevSummary V3.5.4.0 -> Concepts and Elements -> Library Properties defines the following properties:
I'd like to read (and if possible write) exactly These values. But when I try to execute the script Codesys replies:
'ScriptObject' object has no Attribute 'IsEndUserLibrary'
...
The same happens wit the languagemodelattribute and the specialdeviceid, is it possible to read/write These attributes?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-14
Originally created by: M.Schaber
Yes, of course, you use the dictionary syntax, as it is shown in the example script:
As I wrote, this dictionary syntax allows to read and write arbitrary values. But in that case, it also is your obligation to use the correct type (as it is when using the "Properties" page in the UI).
Internally, the project information object contains just a dictionary with strings as keys and objects as values. There is nothing special about values like "title" and "version" compared to the others. The only exception is that they have more convenient ways to configure them via explicit scripting API and UI form, in addition to the generic access via the "Properties" page and the dictionary syntax.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello,
I'm trying to modify the "ProjectInfoExample.py" example script, to write all Standard library/project attributes (of course only the ones which a writable, I know that the Project attribute *.project is read only).
In the example file there's company, title, version, default_namespace, author and SpecialDeviceId. But there are also IsEndUserLibrary, LanguageModulAttribute and SpecialDeviceId.
I wasn't able to find a Definition of the Standard attributes in the help file...
best regards
Originally created by: M.Schaber
hi,
I don't have your "ProjectInfoExample.py" example script. But my "ProjectInfoCreation.py" script which seems to circulate contains the following snippet:
As the commment says, this is an example of how to set custom values which are not covered by the explicit API. There is no "registry" of valid values - an End-User can just define a value for his own company (by convention), and then access it e. G. via the generated IEC code. Also, OEMs can extend CODESYS with their own plugins, and thus define values which have "real" semantics for their plugins.
The api was modeled after the fields which were available in the CODESYS UI back then. As the project settings UI allows to set arbitrary values on the "Properties" tab page, the scripting API also provides this possibility via the dictionary interface.
Some of those values are recommended by the coding guidelines (which are included in the online help), for example, see the Section Libraries -> Guidelines for creating Libraries -> Library Development Summary -> CODESYS LibDevSummary V3.5.4.0 -> Concepts and Elements -> Library Properties defines the following properties:
I'd like to read (and if possible write) exactly These values. But when I try to execute the script Codesys replies:
'ScriptObject' object has no Attribute 'IsEndUserLibrary'
...
The same happens wit the languagemodelattribute and the specialdeviceid, is it possible to read/write These attributes?
Originally created by: M.Schaber
Yes, of course, you use the dictionary syntax, as it is shown in the example script:
As I wrote, this dictionary syntax allows to read and write arbitrary values. But in that case, it also is your obligation to use the correct type (as it is when using the "Properties" page in the UI).
Internally, the project information object contains just a dictionary with strings as keys and objects as values. There is nothing special about values like "title" and "version" compared to the others. The only exception is that they have more convenient ways to configure them via explicit scripting API and UI form, in addition to the generic access via the "Properties" page and the dictionary syntax.
That works, thank you
only Thing, DefaultNamespace must be written whitout an underline or space.
default_namespace = info.values["DefaultNamespace"]
Originally created by: M.Schaber
Hi,
Thanks for the hint, I did correct my table above, and I did inform our documentation department so they correct the online help.
Hi,
where can i find the "ProjectInfoExample.py" or "ProjectInfoCreation.py" example script you mentioned in the previous post ?
Regards,
Dave
Originally created by: M.Schaber
Hi, Dave,
For the "ProjectInfoExample.py", you need to ask dblessin.
I did attach the "ProjectInfoCreation.py" file to this post.
HTH,
Markus
ProjectInfoCreation.py [1.52 KiB]