Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1067

Can't modify Thigh Bend values in animation via a script

$
0
0

Limbstick is a great tool (compared to what Daz has out of the box), but it's buggy as hell. If you tell it to stick a dancing girl's foot to the floor, it (sometimes) doesn't care if the girl's thigh position is completely different between the first and last frame. Its goal was to keep the foot on the bed, and it did that. Great success! Only this creates an ugly glitch between the first frame and the last, because the foot is technically where it's supposed to be, but the whole leg is positioned completely differently.

I have this excel where I input a joint's 0 value, current value of about 10 frame before the last and the formula gives me a series of numbers which change the joints more or less smoothly in the last 10 frames so they match frame 0. I'm patient enough to do it manually but even I have my limits, so today I asked ChatGPT for a solution.

The golem enthusiastically got to work and quickly generated a script and instructed me how to run in on Daz's Script IDE. Happy, I thought that for once my premium ChatGPT subscription paid for itself, but of course the script didn't compile. To make a long story short, three hours later, ChatGPT's incompetence can only be matched by its never-ending optimism that this time the script will work.

So, three hours down the drain and almost nothing to show for it.

What I'm trying to do is populate a set of values in a character's Right Thigh Bend - Bend parameter, on frames 98 - 108. This script passes compilation (no thanks to ChatGPT) but other than that, does nothing at all. Any help would be appreciated and perhaps even be useful for others.

 

// DAZ Studio Script to modify "Right Thigh Bend - Bend" over a frame range

// Get the selected figure (ensure the character is selected)
var character = Scene.getPrimarySelection();
if (!character) {
    print("No character selected!");
} else {
    // Find the Right Thigh Bend - Bend parameter using its internal name
    var oNode = character.findNodeChild( "rThighBend", true );
        if (!oNode)
            print("oNode!");
    var oZRotCtrl = oNode.findPropertyByLabel( "Bend" );
        if (!oZRotCtrl) {
            print("oZRotCtrl!");
    } else {
        print(oZRotCtrl);
        // Define the range of frames and values
        var startFrame = 98;
        var endFrame = 108;
        var values = [-90.27011917,-90.14333833,-90.0165575,-89.88977667,-89.76299583,-89.636215,-89.50943417,-89.38265333,-89.2558725,-89.12909167,-89.00231083]; // Adjust values as needed

        // Ensure the values array matches the frame range
        if (values.length !== (endFrame - startFrame + 1)) {
            print("Error: Values array size does not match frame range.");
        } else {
            // Apply the values over the frame range
            for (var i = 0; i <= endFrame - startFrame; i++) {
                var frame = startFrame + i;
                var value = values[i];                 
                Scene.setFrame(frame);  // Move to the specified frame               
                oZRotCtrl.setValue(value);  // Set the value               
                //oZRotCtrl.setKeyframe();    // Create a keyframe
                //createKeyFrame.trigger();
            }

            print("Successfully applied values to Right Thigh Bend - Bend from frame " + startFrame + " to " + endFrame);
        }
    }
}

Viewing all articles
Browse latest Browse all 1067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>