Studio4.5 scripting: how to deal with DUF material presets?
Sylva1n
Posts: 0
Hello,
I've written a script which load a material preset. it's quite easy to do it with a material preset DSA file.
But since the DSA are deprecated, I would like to use the new DUF format.
But I don't know how to parse it.
How can I load a material preset DUF file in a script?
best regards,
Sylvain
Comments
App.getContentMgr().openNativeFile( presetName, true );
How would you actually save a native file, i.e. save a .duf?
Draft versions of the DS4 'Save a Material(s) Preset' and 'Save a Shader Preset' script samples are up.
Edit: sorry, those samples are still for writing DSA files!
Yes, but it's quite straightforward to convert those into SDK.
I'm wondering how to detect if a DzNode DzProperty is a standard one (rotate,translate,scale etc.) or is a morph. I'm sure there must be a way...
EDIT: probably something like DzProperty->inherits("Dzsomething")...
In a script, DzProperty.hasControllers() wil tell you if a property is a slave. I'm not sure there's a simple way of telling if it's a master though.
Thanks Richard, that worked just fine.
Take a look at this example.
Replace the main loop with the following:
-Rob
You were right the first time... The DzAssetIOFilter subclasses are for writing DSON format files. The DzSaveFilter subclasses are for writing DAZ Script based presets, but were never fully exposed to the script API and are now deprecated.
-Rob
I'm trying to convert the .dsa as kindly provided by Rob, but I've some troubles.
The .dsa getGroupProperties is this:
function getGroupProperties( oGroup, bTraverse, bRecurse )
{
// Declare an array to hold properties
var aProperties = [];
// If a group isn't passed in
if( !oGroup ){
// We're done, return an empty array
return aProperties;
// If a group is passed in
} else {
// Get the number of proeprties in the group
var nProperties = oGroup.getNumProperties();
// Pre-size the properties array
aProperties = new Array( nProperties );
// Iterate over the properties, setting each element in the array
for( var i = 0; i < nProperties; i += 1 ){
aProperties[ i ] = oGroup.getProperty( i );
}
// If we are recursing
if( bRecurse ){
// Concatenate the properties array from child groups
aProperties = aProperties.concat( getGroupProperties( oGroup.getFirstChild(), bTraverse, bRecurse ) );
}
// If we are traversing
if( bTraverse ){
// Concatenate the properties array from sibling groups
aProperties = aProperties.concat( getGroupProperties( oGroup.getNextSibling(), bTraverse, bRecurse ) );
}
}
// Return the array of properties
return aProperties;
}
I tried to convert it into a SDK function and used the DzTArray to return group properties. However, I get errors in the highlighted lines (concat and GetFirstChild do not exist in SDK). Any chance to get some help? Thanks.
DzTArray getGroupProperties( DzNode *oGroup, bool bTraverse, bool bRecurse )
{
// Declare an array to hold properties
DzTArray aProperties;
// If a group isn't passed in
if( !oGroup ){
// We're done, return an empty array
return aProperties;
// If a group is passed in
} else {
// Get the number of proeprties in the group
int nProperties = oGroup->getNumProperties();
// Pre-size the properties array
aProperties = DzTArray (nProperties) ;
// Iterate over the properties, setting each element in the array
for( int i = 0; i < nProperties; i += 1 ){
aProperties = *oGroup->getProperty(i);
}
// If we are recursing
if( bRecurse ){
// Concatenate the properties array from child groups
aProperties = aProperties.concat( getGroupProperties( oGroup->getFirstChild(), bTraverse, bRecurse ) );
}
// If we are traversing
if( bTraverse ){
// Concatenate the properties array from sibling groups
aProperties = aProperties->concat( getGroupProperties( oGroup->getNextSibling(), bTraverse, bRecurse ) );
}
}
// Return the array of properties
return aProperties;
}
I could use a .append to concatenate values into the array, and getFirstChild() may be replaced by getNodeChild(0) ?
But I'm not sure the approach I used is the correct one...
I also would like to ask something that confuses me.
In the example above, DzProperty->name() returns the expected name if it's a DzModifier/Pose.
In the case it's a DzModifier/Shape, the name() returned is always "Value", while I'd expect to return the controller name, such as "FBMBasicFemale" for the Genesis Female Modifier/Shape.
Am I wrong?
Should you perhaps get the value channel and then the name of that?
The oGroup argument should be a DzPropertyGroup pointer, not a DzNode pointer.
If the owner of a property inherits DzMorph, get the name of the modifier... not the name of the valueChannel (which will be named "Value"), that is used to apply the morph.
-Rob
Thanks Rob, I think I finally have a clear idea of how all those properties are linked...