How to add a load in part of the process?

I am a novice for AnyBody, recently I want to simulate a motion consisting of bending down without load, and then bending back with load. How to realize this? How to establish the relationship between load and time or position? By the way, conditional contact is not helpful under such circumstance, and how can I read or understand the inner function which is used in conditional contact like iffun, getfun and so on? Thank you.

Dear Amin,

What you need to use is AnyForce that can be a function of a kinematic measure (e.g. position) and time.
Please read more in the Reference Manual of AnyBody.

Hope it helps,

Mohammad S. Shourijeh, PhD
AnyBody Team

Hi Mohammad,

Thank you for your reply, I already read the function of kinematic measure(AnyKinLinear, AnyKinMeasure and so on). I use AnyForce as a function of Kinematic Measure. and then judge the measured position I desired. However, The position value(Main.ModelDef.MeasureOrg0.Pos[0]) does not change, if I use position value(Main.ModelDef.MeasureOrg0.Pos) . Part of the codes is attached. Thank you.

AnyKinMeasureOrg MeasureOrg0 ={
AnyKinLinear &ref=Main.ModelDef.XYZmeasure;
AnyIntVar sigal= ltfun(Main.ModelDef.MeasureOrg0.Pos[0],2);
#if sigal
AnyForce3D load =

  F = {0, -50, 0};
  AnyRefFrame &PalmNode =Main.ModelDef.Segs.UpperArm.ElbowNode ;
  AnyDrawVector DrF = 
    Vec = .Fout/20;   // Scale the length down
      Line = {
        Style = Line3DStyleFull;
        Thickness = 0.01;
        RGB = {1, 0, 0};
        End = {
          Style = Line3DCapStyleArrow;  // This specifies the end to be an arrowhead
          RGB = {1, 0, 0};
          Thickness = 0.02;  // The head begins with twice the thickness of the shaft
          Length = 0.05;
AnyRefFrame &Palm =Main.ModelDef.Segs.UpperArm.ElbowNode ;



Hi Amin,

What you have tried to do in the code is not possible, as i read it you try to switch in and out a par of the script based on a position value, this can not be done, to switch part of the script in and out needs to be done a load time level it can not depend on a position.

The good news is that there might be another way to do what you are intending.

AnyIntVar sigal= ltfun(Main.ModelDef.MeasureOrg0.Pos[0],2);

AnyForce3D load = 

F = iffun(sigal,0.0,1.0)*{0, -50, 0};  //maybee swicth 1.0 or 0.0 around...

Best regards