Material vs BaseMaterial



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/05/2012 at 12:35, xxxxxxxx wrote:

    Hy there,

    the Material Class has the following method:
    Material.GetChannelState()

    But I don't see any method that would get me back a Material, its always a BaseMaterial. So I can't check for the channel state ...

    So, how can I get a "Material"?

    Thank you,
    maxx



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/05/2012 at 13:35, xxxxxxxx wrote:

    not sure what you are trying to do, can you provide a more extensive code example ? 
    c4d.BaseMaterial.Material is just the class for mmatrial, or in other words it is the
    class to the interface system for displaying a c4d.BaseMaterial. so a Material is also
    always a BaseMaterial.

    if you want to access some material data it is done with the BaseContainer system,
    approached by the bracket syntax as always in python. check the ressource folder
    or the c4d console for the ids.

    a quick example for reading the color channel texture :

    myBaseShader = myBaseMaterial[c4d.MATERIAL_COLOR_SHADER]
    

    edit : eh, i got it you got a BaseMaterial and you want to access the channel state.

    myBaseMaterial[c4d.MATERIAL_USE_COLOR]
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/05/2012 at 13:58, xxxxxxxx wrote:

    Ok, nice, thanx.

    Cheers,
    maxx



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/05/2012 at 14:21, xxxxxxxx wrote:

    Can't test it right now, but I'm quite sure c4d.BaseMaterial(c4d.Mmaterial) returns an instance of the Material class, just as c4d.BaseObject(c4d.Ospline) returns a SplineObject instance. This is because you can not cast a type like in C++ (if (o->GetType() == Ospline) spl = (SplineObject* ) o;). Instead you get always the instance of it's "most bottom subclass".

    Cheers,
    Niklas



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2012 at 02:01, xxxxxxxx wrote:

    c4d.Material() has been deprecated because it was only useful to get channels state.
    And as littledevil alrteady mentioned it, it is possible to know if a channel is enabled or disabled by accessing the material's container entries : MATERIAL_USE_COLOR, MATERIAL_USE_ALPHA, MATERIAL_USE_SPECULAR etc.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2012 at 05:45, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Can't test it right now, but I'm quite sure c4d.BaseMaterial(c4d.Mmaterial) returns an instance of the Material class, just as c4d.BaseObject(c4d.Ospline) returns a SplineObject instance. This is because you can not cast a type like in C++ (if (o->GetType() == Ospline) spl = (SplineObject* ) o;). Instead you get always the instance of it's "most bottom subclass".

    Cheers,
    Niklas

    Hy there,

    yes, my first thought, I want to cast :)

    Originally posted by xxxxxxxx

    c4d.Material() has been deprecated because it was only useful to get channels state.
    And as littledevil alrteady mentioned it, it is possible to know if a channel is enabled or disabled by accessing the material's container entries : MATERIAL_USE_COLOR, MATERIAL_USE_ALPHA, MATERIAL_USE_SPECULAR etc.

    Could you put this into the Docs? Cause nothing says "deprecated" right now ... or maybe that was added in R13? I am still stuck with R12.

    Thank you,
    maxx



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2012 at 06:21, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    maybe that was added in R13? I am still stuck with R12.

    I think you may be able to get the state of a channel, by using the container method in R12 too. For example to check if the color channel is enabled or disabled in a material you may be able to call:

    mat[c4d.MATERIAL_USE_COLOR]
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2012 at 06:35, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Originally posted by xxxxxxxx

    maybe that was added in R13? I am still stuck with R12.

    I think you may be able to get the state of a channel, by using the container method in R12 too. For example to check if the color channel is enabled or disabled in a material you may be able to call:

    mat[c4d.MATERIAL_USE_COLOR]
    

    I actually meant, if the docs are already updated in R13 ;)

    It does work fine, also for R12.

    Thank you,
    maxx



  • On 01/05/2016 at 02:15, xxxxxxxx wrote:

    I know this is quite an old thread, but haven't found a more recent one discussing this topic.
    So, the old information mentions that c4d.Material() has been deprecated, and working with the base container was the way to go. But recently new methods have been added related to the reflectance channel (i.e. AddReflectionLayer and RemoveReflectionAllLayers).

    Working with the Material is fine, I have been able to create a new Material and add/remove layers, even manipulating the data per layer.
    But how to go about this when working with existing materials?
    When I do a doc.SearchMaterial( <mat name> ) all I get is a BaseMaterial. And since type casting is not an option, how do I go from a BaseMaterial to access the add/remove reflectance layer methods?
    Maybe a noob question, but haven't been able to figure that one out.

    Thanks in advance.



  • On 01/05/2016 at 02:22, xxxxxxxx wrote:

    Seems to be a bug in doc.SearchMaterial(). If you do doc.GetFirstMaterial(), you get a c4d.Material object. You gotta search for the material with the right name yourself then.



  • On 02/05/2016 at 02:14, xxxxxxxx wrote:

    Hi,

    That's a limitation of the Python API. Several functions only return a BaseMaterial. This issue will be reported.


Log in to reply