Material Distinct ID



  • On 13/09/2015 at 05:03, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R16 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Greetings !

    I have created 50 materials of a Material Data plugin.

    I need each one of them to use a different ID (in a member variable). 
    Can i use the Material Pointer as ID ? is it safe ?
    GetNodeID returns the ID of the plugin

    Is there any message that is triggered on Material create or destroy ?

    Thank you.



  • On 13/09/2015 at 07:31, xxxxxxxx wrote:

    Depends on your requirements. When the scene is loaded from disk,
    the address is certainly a different one. If you're using the addrss. use 
    the address of the associated BaseMaterial.



  • On 14/09/2015 at 02:58, xxxxxxxx wrote:

    Hello,

    as Niklas said, the best solution depends on what exactly you want to do. If you already have a unique ID in a member variable stored any you want to access that data from the outside you can implement GetDParameter() and SetDParameter() to make it available.

    If you want to compare materials inside a document you could use the marker returned from GetMarker(). You can also add custom unique data by simply storing it in the material's BaseContainer. There is also AddUniqueID() which is typically used in I/O workflows.

    If you ask when to set the unique ID you might want to check the message MSG_MENUPREPARE to configure your new material.

    Best wishes,
    Sebastian


Log in to reply