Hi fellow developers,
I try to achieve a list/set/map of art work objects, paths specificaly.
I tought that the art handle is unique to every object. It seemed so untill i discovered that when an artboject is changed, the art handle(a pointer adress basicly) is different. Even a small move causes the old handle to be invallid. So not usable to achieve somekind of std::vector or std::map wathever with this art handles.
I tried using the UID suite... but again after the slightest possible change in the artwork, the UID of the object is renewed again making it rather useless to achieve a list of uniqueness. Also Handles would be better then unique id's.
Its seems that the only thing that keeps being attached to an art pobject is its dictionary. This is very usable but also creates some overhead of checking. Again Unique handles in a list would be ideal.
So does anybody has some experience with uniqueness in art object a the abbility to list/map/set/whatever them for later use?
Thx for any hint! 🙂
Have you tried the UUID? I have a plugin that stores the UUID for some objects and they have remained valid after the document has been edited, and even closesd and re-opened.
Hi Rick, thx for the quick suggestion.
I quicktested the UUID suite. (wich is not production ready according to the manual... 🙂 )
It seems the the UUID's keep there link with the object in a session.
But for example when i swap objects in the layerstack. After save restart and reload. The UUID's are re-assigned in order of the stack. So the ID's are not saved within the file itself. And arent save to store as they could be swapped after one session to the next.
This is frustrating behavoir and weird that there is no straight forward sollution ready to use.
The swatches also have the same behavoir when changed the handles change...
It will probably end in creating something myself to counter this behavior.
The dictionaries are my best bet right now as they are kept exactly the same after saving...
Maybe things are handled differently in CORE, which is how I write Illustrator plugins. I misspoke, I use UID, not UUID, but I just tested it and it works, even after moving things around, changing layers, quitting and restarting Illustrator. First the plugin saves a UID entry in the document dictionary, along with a unique ID string (key/value pairs). Then it exports the text contents of selected text objects into a text file, along with the ID for each item. When it imports the edited text, it uses the ID string to fetch the corresponding UID entry in the dictionary and uses its .art() method to get a shared pointer to the CORE Art object (not an AIArtHandle).
You might want to download my TextSync plugin to test for yourself what its limits are, at least with text objects. If you can't make it work that way with the SDK, you can download CORE for free at http://hotdoorcore.com for storing UIDs in the dictionary and still use SDK suites in addition to CORE classes.
thnks for the link to the hot door core lib.
It looks nice. I looked upped the UI id part but in the documentation they state this:
So i don't know why, but this gives me the feeling that they are using the same UID's as the SDK wich arent stable all the time. It worked for you so it might for me... 🙂
Did you test it with 10k+ art objects and a big file?
It needs to be fast and stable even with very high counts of objects.
Thx again in any case for your replies! It at least got me the UUID's wich are allready more usable then the handles and the out of the box UID's from the SDK.
No, I've never tried it with more than a hundred or so callouts on a map. You can download the plugin and test it to see how well it does with thousands of text art objects. I'd be curious to hear what you find...
I should add that most CORE classes are simply thin wrappers on one or several SDK suites that add a few enhancements, occasional workarounds for Adobe bugs, and gives consisten syntax so one code base can be compiled for many versions of Illustrator for both Mac and Windows. The last CORE release compiled for AI 16 through 25, but currently supports 23 thrhough 26.
For best reliability, though, I agree with your suggestion for IDs stored in object dictionaries. If you go that route, I hope it doesn't slow Illustrator down much when parsing (tens of) thousands of art objects.