🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

User defined function not working

User: "sudo"
Altair Community Member

I have created a sample user defined function used in a solver variable in motionsolve.

Here is how I did it:

image.png

Here is the py code:

image.png

I tried to run the simulation and plot the results, however I am getting a value of 0 in the primary pulley radius throughout the simualation.

Sort by:
1 - 1 of 11
    User: "GTT Adam"
    Altair Employee
    Accepted Answer

    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