How to write script to automate rendering several images for offline compositing?

What SDK functions would you use to write a plugin that does this:

1.) Gets a list of the objects in the scene

2.) For each object, make it visible, make the others invisible

3.) Render the scene with just that object to a file named '<objectname>.png'. (Probably DzRenderer::render() used for this?)

The idea being that you can then composite the images together in gimp or whatever.

Are there any existing scripts that do something similar to this or can you suggest which SDK functions would be used for these steps?

Comments

  • frank0314frank0314 Posts: 8,790
    edited December 1969

    Moved to the appropriate forum

  • Richard HaseltineRichard Haseltine Posts: 19,962
    edited May 2013

    Well, I am having trouble with the folder name for saving the renders - it keeps coming up blank when the script it run, even if I've defined it in in render options. I think the fix for this may have been to actually go in and address the values in render Settings, but I'm not sure. Anyway, if you render to a window (set your options first) this will do what you want I think, and if someone fixes the path issue it will even save to disc:

    // Render items// Copyright (c) Richard Haseltine, May 2013// Render separate nodes one per image// Uses existing render optionsvar items = Scene.getNodeList();var names = [];var renderName;var n, m;var inUse;var extra;renderMgr = App.getRenderMgr();renderOptions = renderMgr.getRenderOptions();// Hide everythingfor ( n = 0 ; n < items.length ; n++ ) { // Skip bones of figures, lights and cameras if ( items[ n ].inherits( "DzBone" ) ) {  continue; } if ( items[ n ].inherits( "DzLight" ) ) {  continue; } if ( items[ n ].inherits( "DzCamera" ) ) {  continue; } // Hide only items with geoemtry if ( items[ n ].getObject() ) {  items[ n ].setVisible( false ); }}// Renderfor ( var n = 0 ; n < items.length ; n++ ) { // Skip bones of figures, lights and cameras if ( items[ n ].inherits( "DzBone" ) ) {  continue; } if ( items[ n ].inherits( "DzLight" ) ) {  continue; } if ( items[ n ].inherits( "DzCamera" ) ) {  continue; } // Render only items with geoemtry if ( items[ n ].getObject() ) {  // Show the item  items[ n ].setVisible( true );    // Get the name, and check for uniqueness  renderName = items[ n ].getLabel();  inUse = false;  extra = 1;  do {   for ( m = 0 ; m < names.length && ! inUse ; m++ ) {    if ( names[ m ] == renderName ) {     // Name is in use already so add a number to it     // and increment the number for next time     inUse = true;     renderName = renderName + " %1".arg( extra );     extra++;    }   }  } while ( inUse );  names.push( renderName );  renderOptions.renderImgFilename = renderName;  renderMgr.doRender( renderOptions );      // hide the item  items[ n ].setVisible( false ); }}

    Post edited by Richard Haseltine on
  • edited May 2013

    That's awesome, thanks a lot! Sorry for such a basic question but I can't find the help on how to install a script like this.

    I named it "renderSeparate.dsa" and put it in a directory that had other dsa script in it at C:\Users\owner\Documents\DAZ 3D\Studio\My Library\Scripts\Utilities\MoveScripts but it doesn't seem to show up in the list in DAZ. I noticed that if I renamed one of the scripts that it becomes orphaned in DAZ but doesn't appear again with the new name. ("Previous Siblingx.dsa" becomes an orphan.)

    Is there a page that shows how to load this script?

    Thanks very much!

    scr.jpg
    1912 x 1040 - 345K
    Post edited by whitefrozenturkey on
  • FixmypcmikeFixmypcmike Posts: 12,355
    edited December 1969

    You need to "Scan Known Directories for Content" before it will show in categories.

  • edited May 2013

    Thanks, I tried that and it did some work but the script doesn't appear in DAZ. In experimenting with how it works I'd renamed "Previous Sibling.dsa" to "Previous Siblingx.dsa" which caused it to become orphaned, when I renamed it back to "Previous Sibling.dsa" and scanned for changes, Previous Sibling.dsa no longer appears in DAZ, nor does the new script.

    The "Only New Items" checkbox didn't seem to make a difference. Is there documentation on how this works? I've been searching but can't find anything.

    scr2.jpg
    1912 x 1040 - 335K
    Post edited by whitefrozenturkey on
  • FixmypcmikeFixmypcmike Posts: 12,355
    edited December 1969

    They'll show up under Unassigned.

  • Richard HaseltineRichard Haseltine Posts: 19,962
    edited December 1969

    Look under DAZ Studio Formats>My Library>Scripts>Utilities>MoveScripts, the scripts should all appear there.

Sign In or Register to comment.
Rocket Fuel