Simulation Script

Hello,

I'd like to script a simulation with multiple operations :

-run a first simulation

- freeze simulation for some objects

-move a group of objects

-change the simulation settings

-run a second simulation

-move a group of objects.

Is it possible to do that with the Daz3d Scripting tool ?

Is there a console to see the code for the manual operations to report it in the ScriptIDE window ?

Thank you for your help

Comments

  • var scene = Scene.findNodeByLabel("scene");var underbed = Scene.findNodeByLabel("underbed");var upperbed = Scene.findNodeByLabel("upperbed");var mgr = MainWindow.getActionMgr();sim = mgr.findAction( "DzSimulateAction" )//run simulationif( !sim ){return;}sim.trigger();//wait for the end of the simulationwhile( backgroundProgressIsActive() ) {		sleep();}//freeze simulation for a groupnode//change simulation settings (gravity)//change timeline length//turn the scene upside downscene.getXRotControl().setValue(180);//run simulationif( !sim ){return;}sim.trigger();//wait for the end of the simulationwhile( backgroundProgressIsActive() ) {		sleep();}//turn the scene upside downscene.getXRotControl().setValue(0);

    Ok I think I have coded almost everything, but I don't know how to access the "Freeze simulation" option within the script, I don't find the reference in the database, I found noticed somewhere the action   "Miscellaneous : Freeze Simulation : OptFreezeAction" but it seems to be a debugging tool to abort the simulation. I don't know how to access to the gravity settings of the simulation pannel either.

    Could you help me with that part : 

    //freeze simulation for a groupnode (underbed var)
    //change simulation settings (gravity)
    //change timeline length

     

  • PaintboxPaintbox Posts: 1,633

    Just subscribing to the thread to learn

  • PaintboxPaintbox Posts: 1,633

    @foakenstein, I was wondering if one has access to the simulate button script, because it has two phases by default, one to get to the pose, second to stabilize the simulation. I wonder if that could be of help.

  • For Freeze Simulation you could try using the find property methods on DzNode, Timeline/Play range properties belong to DzScene as I recall.

  • DzDForceModifier : dForce Simulation : Simulation Object TypeDzDForceModifier : dForce Simulation : Simulation Base ShapeDzDForceModifier : dForce Simulation : Freeze Simulation

    Using the find property methods, I found this : "DzDForceModifier : dForce Simulation : Freeze Simulation" but I don't know how to change this parameter inside the code for my group of objects.

     

  • Ok I did this with the static/dynamic surface parameters :

    var mgr = MainWindow.getActionMgr();func = mgr.findAction( "DzAddDForceModifierDynamicSurfaceAction" )if( !func ){return;}func.trigger();//var mgr = MainWindow.getActionMgr();func = mgr.findAction( "DzAddDForceModifierStaticSurfaceAction" )if( !func ){return;}func.trigger();

    All works correctly but I still need to access the simulation tab to change the gravity value inside the script.

    I don't find anything related to "gravity" in the language database. Does anyone have the reference ? 

  • I am not good enough  to understand  how to access the simulation settings, but I found an easy trick : save different simulation presets and then load them inside the script.

    var oContentMgr = App.getContentMgr();oContentMgr.openFile("D:/Ressources/My DAZ 3D Library/Presets/Simulation Settings/testnormalgravity.duf", true);

    laugh

  • PaintboxPaintbox Posts: 1,633
    edited February 2020

    That's quite clever! So you got your auto bed maker script working? laugh

    Post edited by Paintbox on
Sign In or Register to comment.