Object Unique identifier?
-
On 31/05/2013 at 01:03, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14 Std
Platform: Windows ;
Language(s) : C++ ;---------
How can I recognize / identify an object among other object where all have the same name?
For example, I have a Cube, and have added 3 Constraint tags. All automatically get the same name "Constraint". But I want to identify the tag right in the middle.I know C4D knows who is who (I hope so).
What I want is an unique ID for each tag.
I have looked at SetMarker and the like, but in other development environments, I am used to all objects getting an unique ID, which I can access by a property or method.
And if possible, I do not want any interaction on my behalf, by doing a SetMarker or the like. I just want to access the unique LONG id or whatever that makes one particular object(tag) special (its memory address for example). -
On 31/05/2013 at 01:54, xxxxxxxx wrote:
I used the two numbers obtained from
void BaseList2D::GetMarkerStampEx(ULONG* l1, ULONG* l2).
As a pair, i believe it is unique for as long as c4d runs. They are not stored on disk AFIK so they are different each time a scene is loaded.
I would not use a memory pointer as identifier because an object might be created at exactly the same location as a previously deleted object.
-
On 31/05/2013 at 02:43, xxxxxxxx wrote:
You could also use LULONG BaseObject::GetGUID().
-
On 31/05/2013 at 02:45, xxxxxxxx wrote:
Ok I will look into this. Actually, I need something that is persistent, the same after C4D is restarted and project reloaded.
-
On 31/05/2013 at 04:18, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Ok I will look into this. Actually, I need something that is persistent, the same after C4D is restarted and project reloaded.
Create a hidden numeric field in your description, then set that to some number that you know is unique when the tag is created. When you save and load the file that unique number will be retained, so it's always the same in that file.
It's getting that unique number that's the pain. To do that you could simply iterate through all your tags in the scene, get the highest number in use between all of them, and assign the new tag that number + 1.
-
On 31/05/2013 at 05:11, xxxxxxxx wrote:
A good idea! But actually, it is other tags I want to have a unique ID to, not my own tag.