Digital Art Zone

 
     
How to get DZMaterials in script to automatically change opacity?
Posted: 12 June 2013 05:58 AM   [ Ignore ]
Member
Rank
Total Posts:  46
Joined  2013-05-11

I’m trying to write a script that will automatically make the red DAZ Skeleton helper materials invisible during a render and then visible again after the render.

How do I do this? I’m unable to get the DZMaterials because the static DzMaterial.getMaterial() function does not appear to exist?

for(n=0n<DzMaterial.getNumMaterials(); n++)
  
{
  
var material=DzMaterial.getMaterial(n);
  print(
'material='+material.getMaterialName());
  
  if(
material.getMaterialName()=='Helpers')
   
material.setBaseOpacity(0);
  

TypeError: Result of expression ‘DzMaterial.getNumMaterials’ [undefined] is not a function
TypeError: Result of expression ‘DzMaterial.getMaterial’ [undefined] is not a function

How should this be done?

Profile
 
 
Posted: 12 June 2013 06:13 AM   [ Ignore ]   [ # 1 ]
Member
Rank
Total Posts:  46
Joined  2013-05-11

It looks like the docs are wrong and there is no static DzMaterial.getMaterial() but you can get it using a dummy object:

var mat=new DzShaderMaterial(); 
 for(var 
n=0n<mat.getNumMaterials(); n++)
  
{
  
var material=mat.getMaterial(n);
  
  if(
material==null)
   
{
   
print('null material');
   break;
   
}
   
  
print(n+' material='+material.getMaterialName());
  
  if(
material.getMaterialName()=='Helpers')
   
material.setBaseOpacity(0);
  

However, I still can’t find the ‘Helpers’ material in that list. Here’s what it prints for my scene, I can’t tell which are the skeleton helpers and which are not:

0 material=DAZ Studio Default
1 material=Brick Material
2 material=AoA_Subsurface
3 material=DAZ Default Material
4 material=AoA_Subsurface
5 material=AoA_Subsurface
6 material=AoA_Subsurface
7 material=AoA_Subsurface
8 material=AoA_Subsurface
9 material=AoA_Subsurface
10 material=AoA_Subsurface
11 material=AoA_Subsurface
12 material=AoA_Subsurface
13 material=AoA_Subsurface
14 material=AoA_Subsurface
15 material=AoA_Subsurface
16 material=AoA_Subsurface
17 material=Custom
18 material=Custom
19 material=Custom
20 material=Custom
21 material=Custom
22 material=Custom
23 material=Custom
null material

How can I sort out which is the right material?

Profile