Unique ID of BaseMaterial
-
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 -
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(). -
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.
-
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