Skip to main content

OpenModelica compiler (omc) interface for Python>=3.6

Project description

OpenModelicaCompilerForPython

OpenModelica compiler (omc) interface for Python>=3.6

What's this?

When omc4py.open_session() is called in with-statement, it returns session instance bound to omc executable.

from omc4py import open_session

with open_session() as session:
    ...

If open_session() cannot find the executable of omc,
One solution is to add destination of omc executable to the environ PATH.
Another solution is to specify omc executable path by argument of open_session(${path_to_omc}).

# open/close different version sessions
from omc4py import open_session

with open_session(
    "C:/Program Files/OpenModelica1.14.0-64bit/bin/omc.exe"
) as session:
    ...


with open_session(
    "C:/Program Files/OpenModelica1.14.1-64bit/bin/omc.exe"
) as session:
    ...

All methods of session are function in OpenModelica.Scripting.*. If you want to know accurate signature, read help(session) or UserGuide for OpenModelica Scripting API

# Show current omc version
from omc4py import open_session

with open_session() as session:
    print(session.getVersion())

Features in:

  • OpenModelica.Scripting.Internal
  • OpenModelica.Scripting.Experimental

available from absolute reference

# Call "stat" in "OpenModelica.Scripting.Internal"
from omc4py import open_session

with open_session() as session:
    print(session.OpenModelica.Scripting.Internal.stat(__file__))

All types of arguments for function call checked by session.

# "sortString" only take one sequence of string as argument
from omc4py import open_session

with open_session() as session:
    session.sortStrings(
        ["a", "b", "0", "1e5"]
    )  # OK

    # session.sortStrings(
    #     ["a", "b", 0, "1e5"]
    # )  # NG

    # session.sortStrings(
    #     ["a", "b", "0", 1e5]
    # )  # NG

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OpenModelicaCompiler-0.0.0a2.tar.gz (143.0 kB view hashes)

Uploaded Source

Built Distribution

OpenModelicaCompiler-0.0.0a2-py3-none-any.whl (147.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page