How to move an IK chain parented on an object when I move this object by script ?

Hi everyone,

I explain my question:
- I have G8 male on a pose of pianist;
- I have an object guide, a sphere, placed just under the left hand;
- I created an IK chain on left hand and parented it to the sphere.

When I use the slider X translation on the sphere, IK chain follows the movement.
But when I want move the sphere by script, IK chain does not follow.
Here my script:

var oNode = Scene.findNodeByLabel ("SphereLeftHand");
var xProp = oNode.getXPosControl();
var currentValue = xProp.getValue();
print (currentValue); // to verify
xProp.setValue(15.50); 

The sphere moves correctly but the left hand does not move.

What I missed ?
Version of DAZ : 4.24.0.4 64 bits
Thank you for your help.
(If necessary, I can post pictures).

PS : when I enter directly a number in the field X translate in the parameters pane, only the sphere moves (same effect of my script), not the IK chain. When I use the slider all works. A whim of Daz ? :)

Post edited by pierre_basmoreau on

Comments

  • umblefuglyumblefugly Posts: 172

    pierre_basmoreau said:

    Hi everyone,

    I explain my question:
    - I have G8 male on a pose of pianist;
    - I have an object guide, a sphere, placed just under the left hand;
    - I created an IK chain on left hand and parented it to the sphere.

    When I use the slider X translation on the sphere, IK chain follows the movement.
    But when I want move the sphere by script, IK chain does not follow.
    Here my script:

    var oNode = Scene.findNodeByLabel ("SphereLeftHand");
    var xProp = oNode.getXPosControl();
    var currentValue = xProp.getValue();
    print (currentValue); // to verify
    xProp.setValue(15.50); 

    The sphere moves correctly but the left hand does not move.

    What I missed ?
    Version of DAZ : 4.24.0.4 64 bits
    Thank you for your help.
    (If necessary, I can post pictures).

    PS : when I enter directly a number in the field X translate in the parameters pane, only the sphere moves (same effect of my script), not the IK chain. When I use the slider all works. A whim of Daz ? :)

    My theory is that the script itself is not really the problem.

    The interesting part is this:

    • Dragging the X Translation slider moves the sphere and the IK chain follows.
    • Typing the same value directly into X Translation moves only the sphere.
    • Setting the property with setValue() also moves only the sphere.

    That suggests DAZ Studio may be treating an interactive slider drag differently from simply changing the value of the translation property.

    When you do this:

    var xProp = oNode.getXPosControl();xProp.setValue(15.50);

    you are directly changing the X Translation property of the sphere.

    My suspicion is that dragging the slider goes through DAZ Studio's interactive manipulation system, and that manipulation is what causes the IK solver to update the chain. Directly assigning a numeric value may bypass that particular IK/manipulator path.

    That would also explain why manually entering 15.50 in the Parameters pane gives the same result as the script. In both cases the property value changes, but DAZ does not appear to perform the same interactive IK solve that happens while the slider is being dragged.

    One thing that may be worth experimenting with is the tool-context transform functions instead of directly setting the translation property, for example:

    var oNode = Scene.findNodeByLabel("SphereLeftHand");if (oNode) {    var pos = oNode.getLocalPos();    var rot = oNode.getToolLocalRot();    var scale = oNode.getLocalScale();    pos.x = 15.50;    oNode.setToolLocalTransform(pos, rot, scale);}

    The reason I would test setToolLocalTransform() is that it operates in the context of the current manipulation tool, so it may behave closer to an interactive transform than setValue() does.

    I would not guarantee that this will trigger the IK solver, though. It is possible that the actual Universal/Translate tool performs additional internal IK processing during a mouse drag that is not exposed through the public scripting API.

    So, at the moment, my theory would be:

    The IK chain is not responding to the numeric value itself; it is responding to DAZ Studio's interactive manipulation event. setValue() and direct numeric entry change the sphere transform, but do not invoke that same IK-solving operation.

    The fact that direct numeric entry in the Parameters pane also fails is, in my opinion, the strongest clue. It makes this look much less like a missing Scene.update() call and much more like a difference between "setting a property" and "interactively manipulating a node."

     

  • Hi umblefugly,

    Thank you for your answer.
    I tested your proposition with setToolLocalTransform() but doesn't work.
    But you say an important information "internal IK processing during a mouse drag that is not exposed through the public scripting API". I found an old discussion about IK in DazScript 
    https://www.daz3d.com/forums/discussion/11642/ik-from-dazscript
    and the answer at this question joins your tought.

    It's a shame; I had envisioned an easy solution for controlling an IK chain simply by modifying the parent's value, but IK chains cannot be controlled directly via script.
    I found an alternative by using Limbstick : animate the sphere first and apply the tool from 3D Universe.

    Thanks again.
    Best regards
     

Sign In or Register to comment.