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.