THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/07/2007 at 23:07, xxxxxxxx wrote:
Cinema 4D Version: 10.111
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
I'm wondering if there is a way to get a unique identifier for an object in the scene (like an internal Object ID). I'm assuming there must be because C4D allows allows objects of the same name and recognizes which one is referred to in the link boxes.
Besides referring to an object by name, what other options do I have to avoid same-name confusion? I tried the GetMarker() command, but unfortunately, those markers expire after closing the application. It looks like the container changes names, as well.
On 30/07/2007 at 05:23, xxxxxxxx wrote:
There is no unique indexing system in COFFEE.
On 28/11/2007 at 20:53, xxxxxxxx wrote:
Ok. Same question, C++ this time. I have an external text file that I'm referencing to change object states in Cinema 4D. How can I avoid same-name conflicts? The only unique ID (GetUniqueIP()) I've found in the sdk looks like it is more for particle systems than identifying objects.
I've though about creating an invisible tag that I can assign random IDs to and using that to identify the objects. Just wondering if there is already a function built in that I can get an ID from to store in a text file and recall at a later time.
On 28/11/2007 at 23:00, xxxxxxxx wrote:
GetNodeID()? I don't know if these ID's are unique to every item in the document (objects, tags, materials, etc.).
If that doesn't work, I think that you are left with your mentioned option. It is interesting that dialog elements (to be useful beyond adding to the dialog) require unique IDs. You have c4d_symbols.h with tons of them for a plugin and either dialog h/res files or enums in the code for the same purpose.
On 01/12/2007 at 12:36, xxxxxxxx wrote:
Thanks, Robert. I'll look into it.
On 01/12/2007 at 18:21, xxxxxxxx wrote:
Looks like GetNodeID() returns values that are specific only to the type of object, not the specific object being queried.
I can easily put id's in my tags, my only question would be how to know if an object has been copied and pasted back into the scene so I can find it and assign a new ID to it? I'm basically just looking for a message that tells me something has been pasted into the scene. If it's pasted into the object browser, it will be active, and I can just sort through the active objects and replace values at that point.
I would do it in tag assignment, but I'm not having any luck assigning new ID's in init() or in alloc(). Whatever values were in the originals just get copied when the new object gets pasted back into the scene.
On 01/12/2007 at 20:59, xxxxxxxx wrote:
Okay, that sorts out GetNodeID().
There are no messages to indicate something like that. At best, you'll get a bunch of messages that could signify any of a number of things happening in the document.
I think that the best way to do this with your plugin tag is to implement CopyTo()/Read()/Write() - unfortunately, you have to implement all three if any. You can leave Read/Write to just return TRUE.
The disadvantage here is that CopyTo() is called not only on copy&paste; but also when cloning documents for caches (rendering and such). This shouldn't make a difference but could come into play in particular circumstances.
So, in CopyTo(), you are going to assign the new ID - as this is only called when the tag is being copied. How are you tracking 'used' IDs to get valid available ones? Since the copy could be pasted into the same document or a new document multiple times, you'll need to guarantee uniqueness of the ID. This could be accomplished with a separate singleton class (or plugin) for each document. A scenehook would work here - but use it wisely if you must.
On 01/12/2007 at 22:43, xxxxxxxx wrote:
Thank you, I'll investigate that.
As for how I'm tracking ID's, I have a static counter in my tag class that keeps track of the number of my tags in the scene. This number is used to generate a new seed for the random number generator that assigns values to my tag (so, I'm not really tracking the IDs at the moment). The uniqueness of the IDs only matter with respect to objects in the same document. If an object from another document that already has my tag on it gets pasted into my scene, I'm hoping to catch it (somehow) and assign it a new ID.
What do you think? Terrible idea? Probably somewhat flawed, at best?