Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a model with OMPython #166

Open
albert-mathews opened this issue Mar 29, 2023 · 1 comment
Open

create a model with OMPython #166

albert-mathews opened this issue Mar 29, 2023 · 1 comment
Assignees

Comments

@albert-mathews
Copy link

albert-mathews commented Mar 29, 2023

in OMEdit, I can create a blank model/class, then drag and drop blocks/components, and make connections between them, incrementally building a model. Can I use OMPython to similarly incrementally build a model from scratch by adding blocks/components and connections? something like

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
cmds = [
  "newModel(getInstallationDirectoryPath() + "/share/doc/omc/testmodels/MyModel.mo")",
  "addComponent(Modelica.Electrical.Analog.Basic.Resistor "R")",
  "addComponent(Modelica.Electrical.Analog.Basic.Ground"gnd")",
  "addConnection(R.n gnd.p)",
  ... until the model is complete
  "translateModelFMU(MyModel)",
  "simulate(MyModel)",
  etc.
  ]
for cmd in cmds:
  answer = omc.sendExpression(cmd)
  print("\n{}:\n{}".format(cmd, answer))

i've read through

and nothing seemed to be obviously related to what i want to do.

using help(OMPython) i found this, is that related to what i want to do?

requestApi(self, apiName, entity=None, properties=None)
     |      # request to OMC
@arun3688
Copy link
Collaborator

@albert-mathews I guess it is not possible to incrementally build a model in OMPython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants