Need help opening a *.duf file, rendering it a couple of times, then closing it.

whoacowboywhoacowboy Posts: 28

Hi,

I could use some help.

I like to do is the following and I have gotten most the way there:

1. Present the user with a folder dialog and have them select one.

2. The script then opens the first *.duf file in that folder.

3. The script sets the render settings.

4. Renders the scene, manipulates a node and renders the scene again (this happens a few times).

5. I'd then like to close the *.duf file without saving and open the next file in the folder.

6. The script sets the render settings back to how they were.

I have been able to get all of the items working except 2 and 5, I can't find anywhere how you open and close the *.duf files. I can manipulate text files without issue.

My other questions is this the best way to do this. Can you script Daz do step 4 without actually opening the *.duf file?

Thanks in advance,

james

UPDATED

So I found this, which looked promising, but it gives me an error. Immediately after running the script I am able to manually open the 002.duf file.

var path = '/Users/james/Documents/002.duf';
var err = Scene.loadScene(path,Scene.OpenNew);
print(getErrorMessage(err));

console

File Format Invalid

I tried using the options bleow as well with no luck:

Scene.DefaultMethod
Scene.MergeFile

Post edited by whoacowboy on

Comments

  • Richard HaseltineRichard Haseltine Posts: 97,268
    edited December 1969

    If you want to load each as a separate scene then this should, I think, work:

    // Create a directory object for the chosen folder
    // myDirName is the folder name - replace with whatever you used
    var myDir = new DzDir( myDirName );
    
    if ( myDir ) {
     // get the list of .duf files it holds using
     // the entryList function to loog for .duf files (not folders etc.)
     var files = myDir.entryList( "*.duf" , DzDir.Files );
     }
    else {
     // If we couldn't get a directory object there are no files
     var files = [];
    }
    
    // Get the content manager from the application
    var cntMgr = App.getContentMgr();
    
    // Assuming we succeeded
    if ( cntMgr ) {
     // got through the files one-by-one
     for ( var n = 0 ; n < files.length ; n++ ) {
      // try to open the nth file
      // Setting the merge paramter to false will replace the current scene
      if ( cntMgr.openFile( myDirName + "/" + files[ n ] , false ) ) {
       // your operations go here
      }
      
     }
    }
  • whoacowboywhoacowboy Posts: 28
    edited December 1969

    That worked great thanks!

Sign In or Register to comment.