How can I set a keyframe from a daz script programmatically? I found this: https://www.daz3d.com/forums/discussion/148641/how-to-script-add-key-frame-for-a-node-or-property
where it says I can use DzProperty.setValue(dzTime, value), which should set a property to value and also create a keyframe at dzTime. But as far as I can tell, that does not work.
I have to use code like this:
for (var i = firstFrame+1; i < lastFrame; i++) {
Scene.setFrame(i);
modifiers[i].getValueChannel().setValue(1);
createKeyFrame.trigger();
}
where createKeyFrame comes from
var mgr = MainWindow.getActionMgr();
for(var i = 0; i < mgr.getNumActions(); i++) {
action = mgr.getAction(i);
actionText = action.text ;
if (actionText == "Create Keys (Selected Nodes)") {
createKeyFrame = action;
}
}
But this is incredibly slow since I need to do Scene.setFrame(i) and my scene is relatively complex, so switching frames is slow (and creating a recursive keyframe is not fast either).
If I use setValue like so:
for (var i = firstFrame+1; i < lastFrame; i++) {
modifiers[i].getValueChannel().setValue(timeStep * i, 1);
}
no keyframe is created.