Digital Art Zone

 
     
How to write script to automate rendering several images for offline compositing?
Posted: 15 May 2013 12:24 PM   [ Ignore ]
Member
Rank
Total Posts:  59
Joined  2013-05-11

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?

Profile
 
 
Posted: 15 May 2013 02:58 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  7535
Joined  2006-03-19

Moved to the appropriate forum

 Signature 

ARTCollaborations Store on DAZ3D    ARTCollaborations on Facebook

*****Mad Chemistry Lab*****  

 

Profile
 
 
Posted: 15 May 2013 04:34 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13654
Joined  2003-10-09

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 options

var items Scene.getNodeList();
var 
names [];
var 
renderName;
var 
nm;
var 
inUse;
var 
extra;
renderMgr App.getRenderMgr();
renderOptions renderMgr.getRenderOptions();

// Hide everything
for ( 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 ]
.setVisiblefalse );
 
}
}

// Render
for ( var 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 ].setVisibletrue );
  
  
// Get the name, and check for uniqueness
  
renderName items[ n ].getLabel();
  
inUse false;
  
extra 1;
  do 
{
   
for ( 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".argextra );
     
extra++;
    
}
   }
  } 
while ( inUse );
  
names.pushrenderName );
  
renderOptions.renderImgFilename renderName;
  
renderMgr.doRenderrenderOptions );  
  
  
// hide the item
  
items[ n ].setVisiblefalse );
 
}
 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 15 May 2013 09:25 PM   [ Ignore ]   [ # 3 ]
Member
Rank
Total Posts:  59
Joined  2013-05-11

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!

Image Attachments
scr.jpg
Profile
 
 
Posted: 15 May 2013 09:31 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  8425
Joined  2007-11-06

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

 Signature 

PostgreSQL CMS FAQ

Product Updates: Non-Genesis/G2 DIM Zips starting July 2013
Non-Genesis Items with Metadata
Plugin Version Numbers for DS 4.5
Updated Genesis Products

Profile
 
 
Posted: 15 May 2013 11:29 PM   [ Ignore ]   [ # 5 ]
Member
Rank
Total Posts:  59
Joined  2013-05-11

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.

Image Attachments
scr2.jpg
Profile
 
 
Posted: 15 May 2013 11:35 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  8425
Joined  2007-11-06

They’ll show up under Unassigned.

 Signature 

PostgreSQL CMS FAQ

Product Updates: Non-Genesis/G2 DIM Zips starting July 2013
Non-Genesis Items with Metadata
Plugin Version Numbers for DS 4.5
Updated Genesis Products

Profile
 
 
Posted: 16 May 2013 06:00 AM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13654
Joined  2003-10-09

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

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile