Applying Poses, Camera, saving scene

This was something I did in Poser for my workflow using python.  Think of it as a mass rendering setup - and I'd like to see if I can do it in Daz.

Essentially fill a scene with a few characters, 1 or 2.. and run a script that applies a pose to each character, and sets a camera.  That scene is either saved or best case sent to a queue for rendering.   Then apply the next two poses and camera and so on.

I understand that while this script is running, the user can't use daz, but that would be fine - it would be something running overnight anyway.  I started looking through some of the documentation just now - but if it's not possible I'd like to save time.

With poser I was able to send the scene to the queue renderer and move right along to the next set of poses.  Not sure I can do that with Daz but I did see one 3rd party product for queue rendering daz scenes, so perhaps that would be what I need to do,  Although I'm not sure that product supports iray rendering.

Thanks for any help

Comments

  • wp583044wp583044 Posts: 9
    edited November 2017

    So right now I'm using Poser in this way.

    I've got a ton of poses and cameras, I load up two characters into a scene, and run a python script that loads multiple poses and camera position for the figures in the scene, and sends each setup to the render queue.  It then moves on to the next set of poses and camera position.  This way I can do 400 some smallish renders with one click of the button.

    That's accomplished through a python script.  

    Can that workflow be duplicated in Daz Studio using various add-ons, scripting, etc?

    Thanks for your time!

    Post edited by Richard Haseltine on
  • Yes, up to a point; I'm not sure they are quite what you want but there are tools available along these lines. Applying a folder or list of poses via script is pretty simple, but DS itself doesn't have the ability to queue renders and I'm sure how the Scripted Rendering system would handle it: that might make it impossible to get DS back for other work while rendering (though if you have a separate render machine that would certainly be workable).

  • Yea, currently once I start the process in poser using a python script - the application is unusable until all the script runs through all the poses and queues each render - which is fine, I run it overnight.

    Essentially the script works like this

    select character 1
    apply pose to character 1
    apply face to character 1
    select character 2
    apply pose to character 2
    apply face to character 2
    select camera
    pose camera
    Add render to queue (setting filename for the output render)

    *repeat the above*

  • Would this be a better question to ask in the techinical nults+bolts area?

  • Merged old thread with new thread in Scripting forum. I'm not sur there are many diectly appicable entries, but you might want to look through some of the Sample Scripts: http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/start

    I think, at first blush, the sequence would be something along the lines of

    wp583044 said:

    Yea, currently once I start the process in poser using a python script - the application is unusable until all the script runs through all the poses and queues each render - which is fine, I run it overnight.

    Essentially the script works like this

    select character 1

    DS does allow multi selection, which you can access via Scene.getSelectedSkeletonList() which returns an array of figures which are seelcted by their root or a bone, or (sincce you are going to want to chnage the selection state) you could use Scene.findNode( name ) or Scene.findNodeByLbale( label ) to get your figures

    apply pose to character 1
    apply face to character 1

    Use DzDir to get the list of files in a known (or selected) folder via the entryList method, then iterate over that using figure.seelct( true) to set the figure to seelcted, the Content Manager (App.getContentMgr) to apply the presets with ContentMgr.OpenNativeFile( filename ), and figure.selected( false ) to deselect.

    select character 2
    apply pose to character 2
    apply face to character 2
    select camera
    pose camera

    Treat the othe figure and the camera in the same way

    Add render to queue (setting filename forthe output render)

    Use the Render Manager (App.getRenderMgr() ) to launch the render ( RenderMgr.doRender() ) - optionally, if you want to vary the settings, you could load a Render Settings preset as with the poses above or you could set options via doRender, which is I think covered in the samples.

  • Thanks for the direction - I'll give it a go learning what I can.  Many thanks again for both the merging and the help.

  • algovincianalgovincian Posts: 2,611
    edited November 2017
    wp583044 said:

    This was something I did in Poser for my workflow using python.  Think of it as a mass rendering setup - and I'd like to see if I can do it in Daz.

    Essentially fill a scene with a few characters, 1 or 2.. and run a script that applies a pose to each character, and sets a camera.  That scene is either saved or best case sent to a queue for rendering.   Then apply the next two poses and camera and so on.

    I understand that while this script is running, the user can't use daz, but that would be fine - it would be something running overnight anyway.  I started looking through some of the documentation just now - but if it's not possible I'd like to save time.

    With poser I was able to send the scene to the queue renderer and move right along to the next set of poses.  Not sure I can do that with Daz but I did see one 3rd party product for queue rendering daz scenes, so perhaps that would be what I need to do,  Although I'm not sure that product supports iray rendering.

    Thanks for any help

    I think this is doable. In my NPR work, I select each material for each node in the scene, read/analyze the currently applied mat, apply a new custom shader, dynamically set parameters for the newly applied shader based on the original mats, and then render the scene out to a specified file. I rinse and repeat this for 8 different render passes.

    In case you already haven't set this up successfully, to add to what Richard has already mentioned, here's some pseudo code chunks (please check the docs) that you may find useful:

    oNode = Scene.findNodeByLabel ( "Your Node Label" );
    oNode .select(true);

    var oContentMgr = App.getContentMgr();
    oContentMgr.openFile("your-pose-preset.duf", true);

    var oRenderMgr = App.getRenderMgr();
    var oSettings = oRenderMgr.getRenderOptions();
    oSettings.renderImgToId = settings.DirectToFile;
    oSettings.renderImgFilename = "your-output-filename";
    oSettings.applyChanges();
    oRenderMgr.doRender();

    You also may need to add a manual delay in order to wait for smoothing modifiers to be applied and settle before rendering starts.

    Hope this helps.

    - Greg

     

    Post edited by algovincian on
  • awesome, thanks for the code - makes sense, 

    I'll need to test the rendering, although I'm assuming that the render will need to finish before the next poses are applies and the script continues, but I'll cross that bridge when I get there.

     

     

  • So I gave this a run and it worked pretty well, much as expected.  I'm going to add a brief pause as greg mentioned above although I haven't yet seen any problems with smoothing.  The above will set the scene and render, and will only continue when that render completes.  I'd eventually like to see a way to put that to a render queue, so I'm going to check that out - but I can run this overnight and be happy as a clam.  

    It's a breath of fresh air in terms of how I can deal with poses and cameras, organization structure in Daz Studio has been cleaner and easy to understand for this scripting.

  • Okay - well it seems I can get about 5 renders in a row before I get an error and the script stops.

    The script is constructed as so:

    (I've changed some of the file locations and render locations, the plan is to have these repeat quite a few times, so stopping at 5 isn't good.

    Figure1 = Scene.findNodeByLabel ( "Fig1" );Figure2 = Scene.findNodeByLabel ( "Fig2" );Camera = Scene.findNodeByLabel ( "Main" );Figure1 .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/pose.duf" , true);Figure1 .select(false);Figure2 .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/pose.duf" , true);Figure2 .select(false);Camera .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/camera pose.duf" , true);Camera .select(false);var oRenderMgr = App.getRenderMgr();var oSettings = oRenderMgr.getRenderOptions();oSettings.renderImgToId = oSettings.DirectToFile;oSettings.renderImgFilename = "renderlocation/render.jpg";oSettings.applyChanges();    var nCycles = 100000;    var nFrequency = 100;    startProgress( "This is a simple progress test.", nCycles/nFrequency, true, true );    for( var i = 0; i < nCycles; i += 1 ){     if( i%nFrequency == 0 ){      stepProgress( 1 );     }    }    finishProgress();oRenderMgr.doRender();Figure1 .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/pose2.duf" , true);Figure1 .select(false);Figure2 .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/pose2.duf" , true);Figure2 .select(false);Camera .select(true);var oContentMgr = App.getContentMgr();oContentMgr.openFile("Pose Location/camera pose2.duf" , true);Camera .select(false);var oRenderMgr = App.getRenderMgr();var oSettings = oRenderMgr.getRenderOptions();oSettings.renderImgToId = oSettings.DirectToFile;oSettings.renderImgFilename = "renderlocation/render.jpg";oSettings.applyChanges();    var nCycles = 100000;    var nFrequency = 100;    startProgress( "This is a simple progress test.", nCycles/nFrequency, true, true );    for( var i = 0; i < nCycles; i += 1 ){     if( i%nFrequency == 0 ){      stepProgress( 1 );     }    }    finishProgress();oRenderMgr.doRender();

    The error I eventually receieve is

    general\dzscript.cpp(658): Unhandled error while executing script.
    QScriptEngine::popContext() doesn't match with pushContext()

    And if I attempt to begin the script from the failure point, I get the error again.

    My question is that am I missing some dispose or delete items on certain objects?  Not sure if I'm hitting a wall because I'm not removing something after each render.

    Also - it renders the image, but also renders a thumbnail which I find odd - couldn't find documentation to see why that does it, not a big deal - just thought that was weird. 

     

  • Last first: if the image is being saved to a Render Library folder DS will add a 91 pixel thumbnail, for use in the Render Library pane. Personally I don't like this so I have the render Library set to point to non-image folder and simply save to a named folder on disc rather than a library.

    As for the stack error, I don't know - usualy that refers, as I recall, to issues entering and leaving functions which you aren't doing. I would think it better not to keep using the getXMgr() functions, just do that once at the beginning and then keep referring back to it. Similarly, you are decalring the same variable as new (var whatever) mutliple times. Clearing those up might help, but that's a wildish guess.

  • Yeah, I noticed declaring the same variable over and over again - saw it in samples so I was thinking of cleaning those up as well.   Right now there are zero functions or function definitions in the script.  I believe practice is to at least place everything in a single function for scope purposes, so I might do that.  I'll give some of those changes a try and see what happens.

Sign In or Register to comment.