- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Export as an image from Command Line
Export as an image from Command Line
Export as an image from Command Line
Hello friends!
Thank you for allowing me to post in this forum.
I know it's possible to right click and "Export as an image" any .mo file from OMEdit.
May I ask if it's possible from OMPython or the command line? Are there any scripting APIs that would allow me to do this?
OMNotebook would allow me to export as a pdf the image of the model but again I can't find an API that would allow me to export as an OMNotebook from python or the command line.
Thanks for any help. Cheers!
Re: Export as an image from Command Line
There is no such API. However, there is a python script that you can use https://github.com/OpenModelica/OpenMod … e_icons.py
Adeel.
- adeas
- 454 Posts
Re: Export as an image from Command Line
Hello Adeel thanks for replying,
I tried out generate_icons.py. I used the commands python generate_icons.py (.mo file). I ran into some issues. First of all, I had to execute generate_icons.py in C: //OpenModelica1.13.264bit to avoid path errors.
If I used python generate_icons.py lib/omlibrary/Modelica\ 3.2.3/Fluid/Examples/HeatingSystem.mo, I get the error
Error: Failed to insert class HeatingSystem within Modelica.Fluid.Examples
I realized that the path was an issue because I had to copy BouncingBall.mo into lib/omlibrary/ and OpenModelica1.13.264bit which allowed me to execute python generate_icons.py BouncingBall.mo. This did not return any error and created an svg file. However, it was an empty icon. This is understandable because BouncingBall.mo has an empty diagram view.
When I copied FeedDriveLibrary.mo to C: //OpenModelica1.13.264bit and ran python generate_icons.py FeedDriveLibrary.mo, it also managed to execute and create many other icons including the modelica logo. However the diagram view of all the examples were not created.
I only changed this part in the script
PACKAGES_TO_LOAD = []
PACKAGES_TO_LOAD_FROM_FILE = args
PACKAGES_TO_GENERATE = PACKAGES_TO_LOAD_FROM_FILE
because PACKAGES_TO_LOAD probably had some regex issues when reading the filename.
So, my question is, can this script create the Diagram View or only icons. If it could generate the Diagram Views, could someone please help guide me to do so. Thanks again.
Re: Export as an image from Command Line
As far as I remember the correct way to use the script is to pass it the classname instead of the filename. So in your example it has to be,
Code:
python generate_icons.py Modelica.Fluid.Examples.HeatingSystem
It only generates the icon view not the diagram view.
Adeel.
- adeas
- 454 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Export as an image from Command Line