| Bug #92985 | Add ability to export an unselected Diagram to PNG/[other] from Python script | ||
|---|---|---|---|
| Submitted: | 29 Oct 2018 9:47 | Modified: | 5 Dec 2018 22:53 |
| Reporter: | Sergey Susikov | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Workbench: Modeling | Severity: | S4 (Feature request) |
| Version: | 6.3.10 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | WBBugReporter | ||
[29 Oct 2018 9:55]
Marcin Szalowicz
Thank you for the feature request.
[5 Dec 2018 22:53]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Workbench 8.0.14 release, and here's the changelog entry: The following new functions were added to the Workbench GRT module: * activateDiagram(<Diagram>) Opens the selected EER diagram for use with the exportPNG, exportSVG, exportPS, and exportPDF functions. * exportDiagramToPng(<Diagram>, <Path>) Performs a PNG export of an EER diagram to the path provided without activating it. Thank you for the bug report.

Description: Preface: I'm trying to integrate MySQL Workbench diagram exporting to a CI pipeline and thus using a Docker image to run it in headless mode with X11 display. It means that the model file I open is "fresh" every time the program starts (i.e. no cache/preferences saved). Using built-in Python shell it's possible to export a diagram only if it's selected manually (by mouse click), there's no way to open a model and choose any (even if there's only one) diagram from the code. How to repeat: On a fresh installation run the following script (for instance, like this: `mysql-workbench --run 'grt.modules.Workbench.exportPNG('model.png')' --model ~/workspace/model.mwb --quit-when-done`): ``` import grt grt.modules.Workbench.exportPNG('model.png') ``` The result is: > Current diagram cannot be exported as image, please select a diagram first. Expected result: The diagram is saved as a PNG file. Suggested fix: There are several potential ways to resolve the issue: 1. Use `grt.modules.WbPrinting.printTo*File` approach - make methods that accept diagram and file name as arguments; 2. Make `grt.modules.Workbench.editObject` open diagram tab when call with Diagram object (now throws unsupported type exception); 3. Add a wrapper to "View -> Select next main tab" menu item as diagram tab actually opens on program load, just not being selected automatically; 4. Select first diagram automatically when loading the program.