Problems with setting parameters via Python

Hello, I set the external force through Python. This is how I set it up:SetValue("Main.Model.Loads.shoulderF.Flocal", {0.0 -5.0, 0.0}),
Why does this error occur:[{'ERROR':
['ERROR(SCR.EXP11) : E:\Program Files\AnyBody '}
'Technology\MYdemo\ComfortPosOnGround\ComfortPosONGround\ComfortPosONGroundComplex.main.any(94) '}
": 'Flocal' : Incorrectly sized array reinitialization data for "}
"'AnyFloat[3]'",
'Error : command line parser failure.']}],
and how should I set it correctly?Thanks!

Hi,

It looks like you missed a comma between 0.0 and -5.0 in your force value. Please try {0.0, -5.0, 0.0}.

Best regards
Dave

Hi,Thank you very much for your reply. I made some revisions, but the same issue still persists. Below is my code.

try:
macro = [
# Load("ComfortPosONGround.main.any"),

    Load("ComfortPosONGroundComplex.main.any"),  

    SetValue("Main.HumanModel.Mannequin.Posture.Right.GlenohumeralFlexion", alpha[0]),
    SetValue("Main.HumanModel.Mannequin.Posture.Right.ElbowFlexion", alpha[1]),
    SetValue("Main.HumanModel.Mannequin.Posture.Right.GlenohumeralAbduction", alpha[2]),

    SetValue("Main.Model.Loads.shoulderF.Flocal", {0.0, -5.0, 0.0}),
    SetValue("Main.Model.Loads.elbowF.Flocal", {0.0, -5.0, 0.0}),
    OperationRun("Main.Study.InverseDynamics"),
    Dump("Main.Study.Output.MaxAct.Val"),
]
results = app.start_macro(macro)

Here is the error prompt of the result.
[{'ERROR':
['ERROR(SCR.EXP11) : E:\Program Files\AnyBody '}
'Technology\MYdemo\ComfortPosOnGround\ComfortPosONGround\ComfortPosONGroundComplex.main.any(94) '}
": 'Flocal' : Incorrectly sized array reinitialization data for "}
"'AnyFloat[3]'",
'Error : command line parser failure.']}

Hi @hbb

The value {0.0, -5.0, 0.0} would be interpreted as a set in Python.

You have to provide the data as a numpy array :

import numpy as np

macro = [
  ..., 
  SetValue("Main.Model.Loads.shoulderF.Flocal", np.array([0.0, -5.0, 0.0])), 
  ...,
]

I really appreciate it – you’ve solved my difficult problem