Materials of a DzMaterialSelectionSet?

I can get the materials of a shape via DzShape.getNumMaterials().

I can get the selection sets of a shape via DzShape.getMaterialSelectionSets() (recursive).

But how to get the materials assigned to a selection set (DzMaterialSelectionSet.getMaterials(oShape) will return all materials of the shape, not only the assigned)?

I work with DS 4.24. Any ideas?

Comments

  • If I understand what you're asking, it ounds like you want to iterate over all the materials in the shape. Did you try using the getMaterial() method? 

    Something like this?

    var aMaterials = []

    for (var x = 0; x < shape.getNumMaterials(); x++) {

      aMaterials.push (shape.getMaterial(x));

    }

     

  • kabexefkabexef Posts: 93

    sidcarton1587 said:

    If I understand what you're asking, it ounds like you want to iterate over all the materials in the shape. Did you try using the getMaterial() method? 

    Something like this?

    var aMaterials = []

    for (var x = 0; x < shape.getNumMaterials(); x++) {

      aMaterials.push (shape.getMaterial(x));

    }

    Thanks for reply. What I need is information about which material is assigned to which selection set.

  • Ah. Sorry, I misread your ask. 

    So out of curiosity, I don't see the DzShape.getMaterialSelectionSets() in the API docs? Is that an undocumented method?

     

  • kabexefkabexef Posts: 93

    sidcarton1587 said:

    Ah. Sorry, I misread your ask. 

    So out of curiosity, I don't see the DzShape.getMaterialSelectionSets() in the API docs? Is that an undocumented method?

    Yes, it is.

  • OmnifluxOmniflux Posts: 427

    DzMaterialSelectionSets is undocumented and therefore subject to change...

    DzMaterialSelectionSets.getMaterials(DzShape*, bool)

    The boolean parameter appears to be whether or not to recurse, and defaults to true if not specified.

     

    Using Genesis 8.1 Female:

    var oShape = Scene.getPrimarySelection().getObject().getCurrentShape();
    var oMaterialSelectionSets = oShape.getMaterialSelectionSets();
    for (var i = 0; i < oMaterialSelectionSets.getNumChildren(); i++)
    {
    	var oMaterialSelectionSet = oMaterialSelectionSets.getChild(i);
    	var oMaterials = oMaterialSelectionSet.getMaterials(oShape, false);
    	print (oMaterialSelectionSet.name);
    	oMaterials.forEach(function(x)
    	{
    		print (" " + x.name);
    	});
    }
    
    Executing Script...
    Default Templates
    Skin
     Body
     Face
     Ears
     Legs
     EyeSocket
     Arms
     Head
    Nails
     Fingernails
     Toenails
    Skin-Lips-Nails
     Body
     Face
     Lips
     Ears
     Legs
     EyeSocket
     Arms
     Fingernails
     Toenails
     Head
    Genesis 8 Legacy
    Result: 
    Script executed in 0 secs 8 msecs.
  • kabexefkabexef Posts: 93

    Omniflux said:

    DzMaterialSelectionSets is undocumented and therefore subject to change...

    DzMaterialSelectionSets.getMaterials(DzShape*, bool)

    The boolean parameter appears to be whether or not to recurse, and defaults to true if not specified.

     

    Using Genesis 8.1 Female:

    var oShape = Scene.getPrimarySelection().getObject().getCurrentShape();
    var oMaterialSelectionSets = oShape.getMaterialSelectionSets();
    for (var i = 0; i < oMaterialSelectionSets.getNumChildren(); i++)
    {
    	var oMaterialSelectionSet = oMaterialSelectionSets.getChild(i);
    	var oMaterials = oMaterialSelectionSet.getMaterials(oShape, false);
    	print (oMaterialSelectionSet.name);
    	oMaterials.forEach(function(x)
    	{
    		print (" " + x.name);
    	});
    }
    
    Executing Script...
    Default Templates
    Skin
     Body
     Face
     Ears
     Legs
     EyeSocket
     Arms
     Head
    Nails
     Fingernails
     Toenails
    Skin-Lips-Nails
     Body
     Face
     Lips
     Ears
     Legs
     EyeSocket
     Arms
     Fingernails
     Toenails
     Head
    Genesis 8 Legacy
    Result: 
    Script executed in 0 secs 8 msecs.

    Thanks a lot. Works well also with Genesis 9.

Sign In or Register to comment.