Run a small script when a model is posed
Here's a quick scenario. I have a scene setup where I have a model posed in a car driving position. Her feet at the pedals and hands at the wheel. Whenever I make a pose changes (like steering or pushing pedals), I'd like the steering wheel or pedal dynamically react to those changes.
I've already written up a script that allows me to do this but I have to animate the model first before running the script on the entire timeline. It works fantastically. I'd much rather see it happen as I make pose changes for better posing.
I've worked with mcasual on this (big thanks to him!). I can load up a script to do DAZ callbacks - for example, I would load this script up:
var sScript = "i:/checkpedal.dsa";
var oCallBackMgr = App.getCallBackMgr();
var oCallBack = oCallBackMgr.createCallBack( "check pedal", sScript, false );
node = Scene.getPrimarySelection()
oCallBack.setConnection( node, "transformChanged()" );
Now each time the foot node changes, the script "i:/checkpedal.dsa" is executed. Do I just write up the above script then just drag and drop into the scene? I have not seen mcasual around so not sure where he is.
Any help is appreciated!
Comments
Executing the DzCallBack creation script can be accomplished the same way any other script is executed (i.e. drag-n-drop on a viewport, Content Library pane, Smart Content pane, Script IDE pane, etc.), but when performed in this way it behaves as a 'single shot' operation... Meaning, it doesn't survive the session and you have to manually execute the script every time you work with a scene/object that uses it.
A more dynamic solution would be to create a Null (DzNode) that gets parented to the bone/figure/object that you want the script executed by the DzCallBack instance to act upon. On this Null, you could create a Post-Load Script Data Item that executes the DzCallBack creation script [from a support file location, rather than a user-facing location, to avoid problems with path resolution] once it is loaded (which of course presumes the node was saved). This Post-Load script would need to contain some intelligence around efficiently handling the creation of DzCallBack instances and the connections to them. The script executed by said DzCallBack instance(s) could then identify the node(s) to be modified by finding the node(s) with your [uniquely named] data item and getting the respective parent node(s).
-Rob
Thanks for the reply. I will try and dabble with your suggestion when I have time.
I did find a neat feature which allows me to customize a new custom action, point to a script and assign a keyboard shortcut (Window -> Workspace -> Customize F3). When I hold on to the assigned key, I can then move the foot to push on the pedal and the pedal would be pushed in kind (via successive calls to the script). It does not lag the posing/animation playback as much as my previous attempt at DAZ callbacks ( even when the file is loaded up into a variable and executed along with the callback).
During my first run through the DAZ Studio user guide, I did not find this...