User defined function not working
Thanks @GTT Adam .
Also I noticed that this function is being called just once at the start of the simulation. Would it be possible to call it everystep of the simulation so that I would get the updated values of the parameters that I am passing to the user defined function?
Hi @sudo,
Since your User Defined Function does not have any inputs, it may only calculate it once. I would try to pass in a dummy parameter so that it tries to calculate something.
Try passing in USER(34) in the function and instead of result = 34, replace it with result = [0, par[0], 0,0,0,0,0,0]
Hope this helps!
Adam Reid
Hi @sudo,
I believe that an array must be returned and not a single parameter. If we look at the example provided in MV-1203, they show the following syntax:
def REQSUB(id, time, par, npar, iflag):
[D, errflg] = py_sysfnc("DM",[par[0],par[1]]) ## sets "D" as piston
displacement mag
result = [0,D,0,0,0,0,0,0] ## lists results for output
return
return result ## sends list with results to motionsolve as
output
In this example, we can see that the distance measurement is returned as an array called 'result' with 8 inputs. I would try to return your 'result' as an array as well.
Hope this helps!
Adam Reid
Hi @sudo,
I believe that an array must be returned and not a single parameter. If we look at the example provided in MV-1203, they show the following syntax:
def REQSUB(id, time, par, npar, iflag):
[D, errflg] = py_sysfnc("DM",[par[0],par[1]]) ## sets "D" as piston
displacement mag
result = [0,D,0,0,0,0,0,0] ## lists results for output
return
return result ## sends list with results to motionsolve as
output
In this example, we can see that the distance measurement is returned as an array called 'result' with 8 inputs. I would try to return your 'result' as an array as well.
Hope this helps!
Adam Reid