1

I want to have a connection between a constraint block in the Cameo Systems Modeller and Python. Therefore I connected a constraint block with a Matlab script, which worked well, and connected a Matlab script with a Python script, which works as well. If I try to connect all of them together, so that the CSM calls the Matlab function which calls the Python function, it fails. Even if I do not use the output of my Python function. At the moment where it is a part of my Matlab script, it doesn't work anymore in the CSM, which means I do not get any outputs. Firstly, here is an example of the Matlab Code.

function distanceCheckP = mymode(time, speed)

    distanceCheckP = py.dataParse.distance(time, speed);
    out = [distanceCheckP];

end

And then something like this is Python.

def distance(time, speed):
 
distanceCheck = (3 * speed * time)
return distanceCheck

As I said if I just do the math in Matlab in works. And if I only call the Python function in my Matlab environment it works as well. I connect the Matlab to the CSM just with drag and drop. If there is any other opportunity to connect the CSM to a Python script, I also would be interested in that.

There is an old question on this thread: import external python library (pysnmp) in Cameo Systems Modeler 18.1 . Someone asked how to use external libraries in the CSM from Python, which indicates that he is able to use Python in the CSM.

clanky1997
  • 82
  • 6

1 Answers1

2

Among the script languages supported by Cameo Systems Modeler is Jython. This is a Java implementation of Python. Is that what you are looking for?

Axel Scheithauer
  • 2,758
  • 5
  • 13
  • No, I wanted to use different libraries in Python, which I could not use in Jyphon. My new Matlab script calls Python from the console. This is working also inside the CSM, but I do not know if its the best option. – clanky1997 Feb 24 '21 at 12:00
  • It should be possible to import Libraries to Jython. I don't think it is necessary to take a detour to Matlab. – Axel Scheithauer Feb 25 '21 at 13:14