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

[Solved] Loading omlibrary mo-File fails in a script

[Solved] Loading omlibrary mo-File fails in a script

Dear all,

When I want to load the file /usr/lib/omlibrary/Modelica 3.2.2/Blocks/Math.mo in OMShell-terminal it fails:

>>> loadFile("/usr/lib/omlibrary/Modelica 3.2.2/Blocks/Math.mo")
false

I can, of course, load the file into OME and here it is also possible to export an FMU of one of the blocks  (which is my original intent to use script-wise model handling). What did I wrong?

I would really appreciate any kind of hints/help.

Best wishes,
Andreas

Versions:
OMEdit 1.11.0~1-gf048cec
Connected to OpenModelica 1.14.0~dev-5867-g85b17c5

Edited by: ndrsh2 - May-09-19 10:38:12

Re: [Solved] Loading omlibrary mo-File fails in a script

ndrsh2 wrote:

When I want to load the file /usr/lib/omlibrary/Modelica 3.2.2/Blocks/Math.mo in OMShell-terminal it fails:

Hi,

I can'not seems to fine a Math.mo file in my Modelica 3.2.2

Code:

loadFile("C:/OpenModelica/lib/omlibrary/Modelica 3.2.2/Math/Special.mo")

Above code loads the Special.mo inside the Math folder and it works. Do you want to load one model or the hole package?

Cheers

Re: [Solved] Loading omlibrary mo-File fails in a script

Hi Arinomo23,

As a first step I would like to load (and then export) a model, later on, I would like to do this with a package.

I cannot reproduce your test, since I do not have a Math directory, but just Math.mo with 3551 lines of code. This is quite confusing.

Cheers,
Andreas

Re: [Solved] Loading omlibrary mo-File fails in a script

Ahhhh, i see... try to change the directory first and then load the file. For example in my case

Code:


cd("C:/Openmodelica/lib/omLibrary/Modelica 3.2.2/Blocks")
loadFile("Math.mo")

imho it should works current/big_smile

Edited by: Arinomo23 - May-09-19 09:02:57

Re: [Solved] Loading omlibrary mo-File fails in a script

Unfortunately, not. I tried this before (and didn't mentioned it explicitly).

Code:


>>> cd("/usr/lib/omlibrary/Modelica 3.2.2/Blocks")
"/usr/lib/omlibrary/Modelica 3.2.2/Blocks"

>>> loadFile("Math.mo")
false

I have the feeling that files starting with a within-statement cannot be loaded whilst stand-alone models can. If I make a copy of this file and remove the within-statement, it is working.
Why? How can I make it work with within-statement?

Edited by: ndrsh2 - May-09-19 09:37:37

Re: [Solved] Loading omlibrary mo-File fails in a script

Code:


loadModel(Modelica,{"3.2.2"})
cd("C:/OpenModelica/lib/omlibrary/Modelica 3.2.2/Blocks")
loadFile("Math.mo")

i forgot that i tested it in OM Compiler CLI. Try above commands in shell, i think now its working. current/big_smile

Re: [Solved] Loading omlibrary mo-File fails in a script

Yes, that solved the problem. Thank you very much!

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