Skip to main content
Inspiring
June 20, 2022
Question

Art object uniqueness.

  • June 20, 2022
  • 1 reply
  • 565 views

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! 🙂

 

Doubl3

This topic has been closed for replies.

1 reply

Rick E Johnson
Inspiring
June 20, 2022

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.

Doubl3Author
Inspiring
June 20, 2022

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...

 

 

Rick E Johnson
Inspiring
June 20, 2022

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.