Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Unique ID of BaseMaterial

    SDK Help
    0
    4
    406
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 30/01/2016 at 14:39, xxxxxxxx wrote:

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

      ---------
      Hello Cinema community,

      How to get unique ID of BaseMaterial? I need it in some complex system that tracks updates of individual materials based on dirty bits of BaseMaterial and mapping between BaseMaterials and objects to which material is assigned. I construct this mapping structure traversing the scene graph when geometry or tags are updated.

      I used pointer to BaseMaterial as identifier in this mapping structure.
      Everything was fine except that sometimes the address of BaseMaterial is changed:

      // this code works for each EVMSG_CHANGE
      BaseDocument * doc = GetActiveDocument();
      for (BaseMaterial * mat = doc->GetFirstMaterial(); mat; mat = mat->GetNext())
      {
      	printf("\n material ID %10d", int(mat));
      }
      

      As you see I print the addresses of BaseMaterials. When I edit them they remain constant and it is what I need. When I click Ctrl+Z the system changes the address of material which should be changed and I can't track my changes based on adresses of BaseMaterials used as unique keys.
      How to get unique ID for each material? This ID should live as long as material lives.

      Thanks,
      Anton

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 31/01/2016 at 04:12, xxxxxxxx wrote:

        Give the MAXON_CREATOR_ID a try. It's a 16 byte ID that you can
        retrieve with FindUniqueID().

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 31/01/2016 at 10:28, xxxxxxxx wrote:

          Are there any examples, how to use it? I don't understand Cinema ID system.

          Probably, I have to track such cases as delete-add (i.e. topology change) and reconstruct that mapping hierarchy anyway.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 01/02/2016 at 01:31, xxxxxxxx wrote:

            Hello,

            BaseMaterial is based on BaseList2D so you should be able to use GetMarker() to receive an unique GeMarker object that can be compared with other marker objects. The information stored in that GeMarker object is the same information that is received by using FindUniqueID() with MAXON_CREATOR_ID.

            See also "Unique identification of objects"

            best wishes,
            Sebastian

            1 Reply Last reply Reply Quote 0
            • First post
              Last post