Why MotionView UserSubroutine "sysfnc" returns all 0?
Hello everyone,
I used a SYSFNC Subroutine in my Python subroutine script, for reading some system state values. The usage are showed below:
`USER({m_mp_dth.idstring},{m_mw_dth.idstring})` def CNFSUB(id, time, par, npar, loci, ni, locj, nj, gap, gapdot, gapdotdot, dflag, iflag): ipar = [0]*3 ipar[0] = int(par[0]) ipar[1] = int(par[1]) ipar[2] = int(par[1]) [dw, err] = py_sysfnc("DY", ipar) # mP_dth, mW_dth, mW_dth [70000094, 70000093, 70000093] py_errmes(err, "Error calling SYSFNC for DY, dw", id, "STOP") print("DY -- dw=%r, err=%r" % (dw, err)) … return …
I made a print for debugging, and all the print is:
DY -- dw=0.0, err=0
Seems the sysfnc returns 0 correctly. But i also made a output for the same system state:
DY({m_mp_dth.idstring},{m_mw_dth.idstring},{m_mw_dth.idstring})
The output curve in HyperGraph do has a value, shows below:

Why did SYSFNC not read those data? Is the problem in my scripting or defining the input parameters for USER()?
Could anyone help me out on this?
Sincere gratitude,
Garand
Find more posts tagged with
Hello Orestes,
Thank you for the reply. In fact, SYSFNC works well in my GFOSUB script. But I have trouble in using it in CNFSUB. Now the main point confuse me is how to achieve the same function as SYSFNC in CNFSUB. That is, read the system state data in the simulation process, and use these data to calculate parameters in the script.
Specifically, my CNFSUB script expects to calculate the contact stiffness by using the input relative displacement.
Could you please give some relevant suggestions?
Sincerely,
Garand
Hello @Garand,
from what I understand you want to use the relative displacement of the bodies in contact. Would GAP and GAPDOT attributes work for you then?

These are the ones used by the example script as well.
Best regards,
Orestes
Hello Orestis,
Thanks for the reply. I want to use the relative displacement of the two body, it may infect contact property such as stiffness. So GAP may not fulfill the need. I have to rely on sysfnc results.
Can I manage it by call another sysfnc-supported -SUB in CNFSUB, and make it returns result from sysfnc? Or if I have to define a new subroutine (with Sobroutine Builder maybe?) to realise this function?
Thank you for the attention again.
Garand
Hello @Garand,
you could maybe workaround that. Try to use a GFOSUB and store the sysfnc results in global variables. Then you may be able to access those from the CNFSUB.
Hope this helps!
Best regards,
Orestes
Hello @Garand,
you could maybe workaround that. Try to use a GFOSUB and store the sysfnc results in global variables. Then you may be able to access those from the CNFSUB.
Hope this helps!
Best regards,
Orestes
Well, I've tried in GFOSUB and MOTSUB, by add codes below in the first line of function:
[dw, err] = py_sysfnc("DY", [70000094, 70000093, 70000093])
print(dw)
Both of them print the dw value correctly, but still all 0 in CNFSUB.
Why does it happens? What can I do if I need to use it in CNFSUB?