Mobile app version of vmapp.org
Login or Join
Fox8063795

: Embedding data in Illustrator objects I'm trying to use illustrator to add string or numeric data to various elements (groups,paths, etc.) Is there a way to do this in Illustrator? With inkscape

@Fox8063795

Posted in: #AdobeIllustrator #IllustratorScripting #Plugin

I'm trying to use illustrator to add string or numeric data to various elements (groups,paths, etc.)

Is there a way to do this in Illustrator?

With inkscape I can use the XML Editor, it's a bit cumbersome, but it is easy and it is possible.



will result in...

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Fox8063795

1 Comments

Sorted by latest first Latest Oldest Best

 

@Shanna688

Unfortunately, InkScape is much more advanced in this regard than Illustrator. There are 3 ways, to my current understanding, that an art shape can have string data attached to it. None of them solve your question well, or nearly well as InkScape.


Typing in a custom name in the layers panel for the art item will result in an id attribute. However, not all is well, as Illustrator will go ahead and convert some characters for you without so much as a polite warning. Ex: an art name of "My_Rect" resulted in an id of "My_x5F_Rect".
Using the "image map" feature of the Attributes panel to input a URL string will wrap the art shape in an anchor tag, and the string appears as an xlink:href attribute of that anchor tag.
Using the SVG interactivity panel, it's possible to write in some pieces of javascript and have them execute such that your custom attribute is appended via javascript when this file is opened in a browser. While this would actually be the best ("best" used here as a relative term) workaround for adding a custom data string from inside the Illustrator UI, it would certainly require javascript. However, while that is the case, it does provide a means for adding the custom string via the Illustrator UI, and it is completely within the realm of possibility that a post-export script of some kind could go through the SVG text and change up the text to yank the desired string and attribute name out of whatever format you choose, and place them as real attributes.


For example, here is an instance where I made a rectangle and assigned this function to it via SVG interactivity panel: addAttr({data_id : "my-data-id"})
The idea is that there is a javascript file to be included in this document, and it will have a function that adds this string as this attribute to this shape when loading occurs. (I selected the "onload" event from the panel's dropdown list) But, in this case, it would actually serve as a tacky temporary housing for the custom strings.
And this is the resulting SVG:

<rect id="My_x5F_Rect" x="270.1" y="55.2" onload="addAttr({data_id : &quot;my-data-id&quot;})" fill="#90FFFF" stroke="#000000" stroke-miterlimit="10" width="213.3" height="213.3"/>


As you can see, it went ahead and converted the quotes to html entities also, because it's just so so helpful. So, basically, if you really had to, you could take the exported svg and use some script or even find & replace with regexps to go through the text and change addAttr({data_id : "my-data-id"}) into data_id="my-data-id"
That's it, that's all I got :(
And yes, they totally could stand to add some real SVG features to AI.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme