Digital Art Zone

 
     
Studio4.5 scripting: how to deal with DUF material presets?
Posted: 16 July 2012 06:02 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13619
Joined  2003-10-09

App.getContentMgr().openNativeFile( presetName, true );

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 15 September 2012 11:04 AM   [ Ignore ]   [ # 4 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

How would you actually save a native file, i.e. save a .duf?

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 17 September 2012 10:41 AM   [ Ignore ]   [ # 5 ]
Active Member
Avatar
RankRank
Total Posts:  455
Joined  2007-09-01

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!

 Signature 

Website: UnrealImperfect | Freebies: Renderosity, ShareCG | ‘Art’: DeviantArt | Blog: Blogger
(aka Pete Williams)

Profile
 
 
Posted: 17 September 2012 10:52 AM   [ Ignore ]   [ # 6 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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”)...

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 17 September 2012 02:10 PM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13619
Joined  2003-10-09

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.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 17 September 2012 03:20 PM   [ Ignore ]   [ # 8 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27
Richard Haseltine - 17 September 2012 02:10 PM

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.

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 17 September 2012 04:03 PM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRank
Total Posts:  312
Joined  2003-10-09

Take a look at this example.

Replace the main loop with the following:

/*********************************************************************/
// Get the primary selection
var oNode Scene.getPrimarySelection();
// If something is selected
if( oNode ){
 
// Get the properties available to the user by way of the selected node
 
var aProperties getNodePropertiesoNodetruetrue );
 
// Declare variables we'll be using as we iterate
 
var oPropertyoOwneroPresentation;
 
// Iterate over all properties
 
for( var 0aProperties.length+= ){
  
// Get the "current" property
  
oProperty aProperties[ i ];
  
// Get the owner of the property
  
oOwner oProperty.getOwner();
 
  
// Get the property's presentation
  
oPresentation oProperty.getPresentation();
  
  print( 
"----------"oProperty.name":"oProperty.getLabel(), "----------" );
  
  if( 
oPresentation && oPresentation.type == "Modifier/Pose" ){
   
print( "Used for posing" );
  
else if( oPresentation && oPresentation.type == "Modifier/Shape" ){
   
print( "Used for shaping" );
  
}
  
  
// If the property inherits DzNumericProperty
  
if( oProperty.inherits"DzNumericProperty" ) ){
   
var nXYZInterest oProperty.getXYZInterest();
   switch( 
nXYZInterest ){
    
case 1// X_INTEREST
    
case 2// Y_INTEREST
    
case 3// Z_INTEREST
    
case 4// ALL_INTEREST
     
print( "Influences transforms" );
     break;
    case 
0// NO_INTEREST
    
default:
     print( 
"Does not influence transforms" );
     break;
   
}
  }
  
  
// If the property inherits DzFloatProperty
  
if( oProperty.inherits"DzFloatProperty" ) ){
   
var nTransformType oProperty.getTransformType();
   switch( 
nTransformType ){
    
case 1//  SCALE
     
print( "Influences scale" );
     break;
    case 
2// TRANSLATE
     
print( "Influences translation" );
     break;
    case 
3// ROT_FIRST_AXIS
     
print( "Influences rotation on the first axis" );
     break;
    case 
4// ROT_SECOND_AXIS
     
print( "Influences rotation on the second axis" );
     break;
    case 
5// ROT_THIRD_AXIS
     
print( "Influences rotation on the third axis" );
     break;
    case 
0// NON_TRANSFORM
    
default:
     break;
   
}
  }
  
  
print( String"Owned by a %1\n").argoOwner.className() ) );
 
}


-Rob

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 17 September 2012 04:35 PM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRank
Total Posts:  312
Joined  2003-10-09
3dcheapskate - 17 September 2012 10:41 AM

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!

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

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 18 September 2012 03:30 AM   [ Ignore ]   [ # 11 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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<DzProperty> getGroupProperties( DzNode *oGroup, bool bTraverse, bool bRecurse )
{
    // Declare an array to hold properties
    DzTArray<DzProperty> 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<DzProperty> (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 <DzTArray>.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…

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 18 September 2012 04:54 AM   [ Ignore ]   [ # 12 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27

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?

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile
 
 
Posted: 18 September 2012 06:17 AM   [ Ignore ]   [ # 13 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  13619
Joined  2003-10-09

Should you perhaps get the value channel and then the name of that?

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 18 September 2012 07:53 AM   [ Ignore ]   [ # 14 ]
Administrator
Avatar
RankRank
Total Posts:  312
Joined  2003-10-09

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

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 19 September 2012 02:48 PM   [ Ignore ]   [ # 15 ]
Power Member
Avatar
RankRankRank
Total Posts:  1242
Joined  2009-10-27
rbtwhiz - 18 September 2012 07:53 AM

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…

 Signature 

Real Plants Collection 1: Fallen Trees, Ivy and Vines”
Blog
LAMH FB

Profile