Forum: DAZ|Studio


Subject: Script for Executing a Series of Presets

Cobbler3D opened this issue on Jul 16, 2022 ยท 8 posts


Cobbler3D posted Sat, 16 July 2022 at 2:52 PM

Hi all,

Is there a way in the script IDE to execute a preset (shader/pose/morph etc...) ? Like how a Windows/DOS .bat or Unix shell script can execute a series of OS commands in one fell swoop?

If so what does the syntax look like? I could just make a preset or scene subset to capture a series of changes to an object but i would like to automate the process for different Genesis characters by an automated script.

For example, can a DAZ script to apply a certain skin shader, then change the eye color using a different eye material preset and then execute the height preset of a character when a certain G3F in the scene is selected?

I've used the scripting language to traverse the bones of a figure and do much more complex object behavior manipulation but I don't know how to call a preset to execute from within a simple script. Can someone please share an example or even let me know if it can be done?

Thanks all!

RHaseltine posted Sat, 16 July 2022 at 3:42 PM

If you have the file names you just need DzContentMgr, specifically openNativeFile( filepath ) http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/contentmgr_dz#a_1a43e46e9be7ac632990125dcd40721b1b


Cobbler3D posted Sat, 16 July 2022 at 3:59 PM

RHaseltine posted at 3:42 PM Sat, 16 July 2022 - #4441386

If you have the file names you just need DzContentMgr, specifically openNativeFile( filepath ) http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/contentmgr_dz#a_1a43e46e9be7ac632990125dcd40721b1b

Ooohhhh thanks! I will give that a try!



Cobbler3D posted Sat, 16 July 2022 at 4:50 PM

Looks like it doesn't work, I tried both DzContentMgr.openNativeFile(Filepath in "", merge=true) and openFile(Filepath in "", merge=true) . I also had selected the G8F figure in the scene before I ran the script...

syntax:

DzContentMgr.openNativeFile("D:\DAZ 3D Content Library\People\Genesis 8 Female\Characters\Madeline\Materials\Eyes\Eyes 02.duf", true)

Error:

Script Error: Line 1

TypeError: Result of expression 'DzContentMgr.openNativeFile' [undefined] is not a function.
Stack Trace: ()@:1
Error executing script on line: 1
Script executed in 0 secs 1 msecs.
-------------------------------
Do I need to make an instance of the DzContentMgr first?

RHaseltine posted Sun, 17 July 2022 at 2:29 PM

You need to get the DzContentMgr (there can be only one) -

oContentMgr - App.getContentMgr();

This is mentioned at the top of the page, but of course my link went part way down - sorry.


Cobbler3D posted Sun, 17 July 2022 at 10:38 PM

Thanks Richard,

I will give it a shot. I'm actually trying to fix my faves list and starting over for the umpteenth time but will try and instantiate a DzContentMgr objext

Thanks!


Cobbler3D posted Mon, 18 July 2022 at 7:40 PM

Works like a charm after I instantiated the DzContentMgr class into an object!

Thanks Richard!


RHaseltine posted Tue, 19 July 2022 at 9:34 AM

Glad it helped.