Page 1 of 2

Copying and pasting shapes in scripts in GEDI

Posted: Mon Nov 12, 2018 8:39 am
by akim
Hello,

Is it possible to copy and paste shapes using scripts in GEDI? I want to copy Panel referenc shapes into other panels from the template panel.
I don’t really like an idea of parsing of .pnl files)

Re: Copying and pasting shapes in scripts in GEDI

Posted: Mon Nov 12, 2018 2:04 pm
by leoknipp
If you want to add a reference to a panel during runtime (not in GEDI) you can use the CTRL function addSymbol().

Is this the function you are looking for?

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Copying and pasting shapes in scripts in GEDI

Posted: Mon Nov 12, 2018 2:44 pm
by akim
No, I need in GEDI but not in runtime. I am trying to make mass parameterization tool for dp and corresponding panel references generation.

Re: Copying and pasting shapes in scripts in GEDI

Posted: Tue Nov 13, 2018 2:18 pm
by leoknipp
If you want to generate panels automatically you can write scripts which
-- read the information which is required to generate the panel
-- use addSymbol() to add the references to the panel
-- use panel.writeToFile() to save the panel displayed in the Vision module.

"writeToFile" is a new option in the UI (WinCC OA 3.16) to save panels during runtime.
For details please have a look at the WinCC OA Documentation.

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Copying and pasting shapes in scripts in GEDI

Posted: Tue Nov 13, 2018 5:52 pm
by akim
I have version 15. Apparently I will parse the pnl file.
Thank you for the reply.

Re: Copying and pasting shapes in scripts in GEDI

Posted: Tue Nov 13, 2018 7:42 pm
by mkoller
In fact you can also use 3.15 and a gedi extension script, which uses addSymbol() in the callback, e.g.
in scripts/gedi/addRef_ext.ctl

Code: Select all


main()
{
int id = moduleAddMenu("Test");
moduleAddAction("addRef", "", "", id, -1, "work");
}

work()
{
addSymbol(myModuleName(), rootPanel(), "ref1.pnl", "r1", makeDynString(), 100, 100);
}

Re: Copying and pasting shapes in scripts in GEDI

Posted: Wed Nov 14, 2018 4:55 am
by akim
I tried addSymbol. But it works only with an open panel.
Through the script, I can open the panel, but I don’t know how to save it through the script after the addition of the reference.

Otherwise, after adding the reference, I have to make any change on the panel manually or through a script,
in order for the Save button to become active, then click on it manually.

Maybe there is an opportunity to send the command of the hot key CTL+S to GEDI window?

Re: Copying and pasting shapes in scripts in GEDI

Posted: Wed Nov 14, 2018 5:30 am
by mkoller
I think it's now time to find out what you really want to achieve.
If you want to just automate some steps within Gedi and do other editing manually, then the gedi extension scripts are the way to go, however currently you can not automate all actions gedi can do (working on that for 3.17).
If you want to create new panels from scratch via scripting, then you don't need Gedi at all and you should go with any script which
opens a panel, adds Panel References/Shapes (addSymbol, addShape) and writes the panel to disk, using the panel method "writeToFile" (which is also available in 3.15).

Re: Copying and pasting shapes in scripts in GEDI

Posted: Wed Nov 14, 2018 5:49 am
by akim
Yes, I want to create new panels from scratch via scripting.
Please give an example or reference how to use "writeToFile". According to the documentation, only the Table element has this method.
And please tell me how to use the panel as an object. To call its methods.

Re: Copying and pasting shapes in scripts in GEDI

Posted: Wed Nov 14, 2018 7:10 am
by Gertjan van Schijndel
Andrey Kim wrote:
Apparently I will parse the pnl file.

The xml format is easier to parse. If addSymbol and writeToFile is not sufficient, then I would parse the xml format.
The panel writeToFile is documented under: Graphics editor (GEDI) -> The Property Sheet -> Properties and events of the panel.