I would like to know if it is possible to modify a GVL constant variable via a python script?
If true how can I achieve this?
If false what should I use?
In the meantime, is there a list of all available global variables in python like projects, online... ?
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
dam hat geschrieben:
I would like to know if it is possible to modify a GVL constant variable via a python script?
You have to find the GVL object, which contains the variable(s) you want to change, and then you can either export, edit the XML and re-import the object or you can use the interface to modify the structured text (ST) of the declaration directly.
The interface is documented in the CHM of the ScriptEngine, which you can find the OnlineHelp directory in the CODESYS base directory. All object which containt an ST based declaration and/or implementation, support the interface so you can check for it.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please remove the brackets after because it is a property and not a method. This property is only to check if the object has an ST based declaration. You get the text with the property , e.g. gvl.text, and modify it with one of the methods, e.g. gvl.replace(modifiedDeclaration).
From your third post:
gvl.get_children(True)
With you can only get the children of the object in the project structure. But variables are not children of the GVL object. You can only read or modify the ST based declaration.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Indeed gvl.has_textual_declaration returns True but I do not have the text property.
I am using SoMachine 4.1 so maybe the version of Codesys is too old?
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
dam hat geschrieben:
Indeed gvl.has_textual_declaration returns True but I do not have the text property.
First you have to get the IScriptTextDocument object through the property (see interface IScriptObjectWithTextualDeclaration ) and than you can use or on that object.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the information and I confirm that it works with Codesys 3.5.7 but it does not work with SoMachine 4.1
dam hat geschrieben:
Indeed gvl.has_textual_declaration returns True but I do not have the text property.
I am using SoMachine 4.1 so maybe the version of Codesys is too old?
In fact, I was confused and I tested on Codesys 3.5.7 not on SoMachine 4.1. With SoMachine I do not have has_textual_declaration (it usesScriptEngine v3.5.3).
Is it possible to update ScriptEngine to a newer version in SoMachine or use a different API?
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-03-14
Originally created by: M.Schaber
Hi, Dam,
dam hat geschrieben:
Thank you for the information and I confirm that it works with Codesys 3.5.7 but it does not work with SoMachine 4.1
In fact, I was confused and I tested on Codesys 3.5.7 on SoMachine 4.1. With SoMachine I do not have has_textual_declaration (it usesScriptEngine v3.5.3).
Is it possible to update ScriptEngine to a newer version in SoMachine or use a different API?
Regards
Updating the ScriptEngine to a newer version cannot be done by a SoMachine enduser, this must be done by Schneider Electric.
As far as I remember, Schneider also added some of their own extensions to the ScriptEngine, but I'm not sure whether that was for SoMachine or SoMachine Motion, and which version. I guess you need to ask the Schneider Support contact...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I would like to know if it is possible to modify a GVL constant variable via a python script?
If true how can I achieve this?
If false what should I use?
In the meantime, is there a list of all available global variables in python like projects, online... ?
Regards
Hi dam.
You have to find the GVL object, which contains the variable(s) you want to change, and then you can either export, edit the XML and re-import the object or you can use the interface to modify the structured text (ST) of the declaration directly.
The interface is documented in the CHM of the ScriptEngine, which you can find the OnlineHelp directory in the CODESYS base directory. All object which containt an ST based declaration and/or implementation, support the interface so you can check for it.
BR
Martin
I tried to do:
but it failed as gvl is a ScriptObject.
Any hint?
Regards
To add more informations if I do:
I got all the values of GVL but:
returns an empty list.
Regards
Hi dam.
From your second post in this thread:
Please remove the brackets after because it is a property and not a method. This property is only to check if the object has an ST based declaration. You get the text with the property , e.g. gvl.text, and modify it with one of the methods, e.g. gvl.replace(modifiedDeclaration).
From your third post:
With you can only get the children of the object in the project structure. But variables are not children of the GVL object. You can only read or modify the ST based declaration.
BR
Martin
Indeed gvl.has_textual_declaration returns True but I do not have the text property.
I am using SoMachine 4.1 so maybe the version of Codesys is too old?
Regards
Hi dam
Sorry, my fault.
First you have to get the IScriptTextDocument object through the property (see interface IScriptObjectWithTextualDeclaration ) and than you can use or on that object.
BR
Martin
Thank you for the information and I confirm that it works with Codesys 3.5.7 but it does not work with SoMachine 4.1
In fact, I was confused and I tested on Codesys 3.5.7 not on SoMachine 4.1. With SoMachine I do not have has_textual_declaration (it usesScriptEngine v3.5.3).
Is it possible to update ScriptEngine to a newer version in SoMachine or use a different API?
Regards
Originally created by: M.Schaber
Hi, Dam,
Updating the ScriptEngine to a newer version cannot be done by a SoMachine enduser, this must be done by Schneider Electric.
As far as I remember, Schneider also added some of their own extensions to the ScriptEngine, but I'm not sure whether that was for SoMachine or SoMachine Motion, and which version. I guess you need to ask the Schneider Support contact...
Ok thank you M.Schaber and M.Keller.
Regards