Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Modelling from command line or Python

Modelling from command line or Python

Hi. I am a beginner at Modelica and was wondering if it is possible to model from the command line (or alternatively from python using the OMPython package). What I mean is: in OMEdit I can set up a model by dragging for instance a ground and a resistor on to the screen and then connect the two with a line. I am wondering if it is possible to set this up from the command line some how. Maybe my sudo code below will clarify.

I am firstly wondering if this is possible, and secondly how to do this.

Sudo code:
>>> load(Modelica)
>>> import(some_path + '/Electrical/Analog/Basic/Ground.mo', name='ground1')
>>> import(some_path + '/Electrical/Analog/Basic/Resistor.mo', name='resistor1')
>>> connect(ground.p, resistor1.p)

Any answer is much appreciated.

Thanks!

Re: Modelling from command line or Python

You can look into OMEdit's logs to see which commands it uses. Some of these commands work out of the box in OMPython, some need to be called with parsed=False as far as I remember.

Re: Modelling from command line or Python

Great, thanks! Can you please tell me where I can find the logs? Or alternatively where I can view them in OMEdit?

Re: Modelling from command line or Python

Tools -> OMC CLI for accessing in the GUI

Or look for logs in your tmp-directory (on Linux: /tmp/OpenModelica_$USER/OMEdit/)

There are 0 guests and 0 other users also viewing this topic
You are here: