• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adobe Illustrator Tags

Valorous Hero ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

I have noticed the tags object is available to the document object, the pageitem object. Does anybody use these, and is there an example of using the 'tag' which someone would be willing to share for common knowledge of this obscure scripting asset?

TOPICS
Scripting

Views

8.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

Hi SV, here you go, select a couple of objects before running

// tag usage, carlos canto

// https://forums.adobe.com/thread/1710632

var idoc = app.activeDocument;

var sel = idoc.selection;

for (j=0; j<sel.length; j++) {

    var pgItem = sel;

    pgItem.name = 'selection ' + j;

    var itag = pgItem.tags.add();

    itag.name = "myPageItemTypename";

    itag.value = pgItem.typename;

}

//alert(pgItem.tags.length);

$.writeln ('document tag count ' + idoc.tags.length + '\n----------------------');

for (i=0; i<idoc.tags.length; i++) {

  var itag = idoc.tags;

  $.writeln(itag.name);

  $.writeln(itag.value);

  $.writeln(itag.parent.name);

    $.writeln(itag.parent.typename);

  $.writeln("----------------------------");

}

alert('done');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 19, 2015 Feb 19, 2015

Copy link to clipboard

Copied

Thank you for this info.

I have also analyzed a document of mine and discovered there were already some existing tags "BBAccumRotation", which are auto-created when a placed file is placed into the document, apparently. The rotation of the placed item is recorded here in radians.

This makes me wonder if the tags can be read by other software outside of Illustrator.


Also, giving a tag a name with a space character in it will give an error.

I also added a tag to a page item via script (is there any other way?) and then ran a line to write the tags in the document, in a subsequent run, which output the new tag. I even closed and opened the document and restarted AI, the tag is still there, so it must stay with the document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

I also did a quick test to see if our AI tags were the same as Acrobat Pro tags, and they unfortunately are not.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 12, 2015 Aug 12, 2015

Copy link to clipboard

Copied

To add what I've learned over last year- "BBAccumRotation" tags are added by Illustrator automatically for placed items and text items, that I know of. The purpose is to record the bounding box rotation, and that's how you can tell if a text frame is rotated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

Silly-V  wrote

To add what I've learned over last year- "BBAccumRotation" tags are added by Illustrator automatically for placed items and text items, that I know of. The purpose is to record the bounding box rotation, and that's how you can tell if a text frame is rotated.

Sorry, I have to revive this old thread.

Since I'm fairly new to Illustrator scripting I discovered property tag today and did some primitive tests with rotating a rectangle.

I learned:

1. A never rotated objects is missing a tag named BBAccumRotation.

2. Tag named BBAccumRotation will be added as soon a object is rotated.

3. The value of BBAccumRotation is the accumulation of rotation actions, so its value could be also 0.

4. One could edit the tag by scripting. That has an impact what the user is seeing as read out for the rotation angle in the UI.

E.g. in the Properties panel and in the Transformation panel ( there is a difference, though )

Some screenshots from my German Illustrator CC 2019 on Windows 10 where I tested this:

NoTagOnUnrotatedObject.PNG

RotatedObject-TagApplied-BBAccumRotation-value-0.785398.PNG

Now I assigned the value 0 to the tag:

app.selection[0].tags[0].value = 0;

The UI is reflecting this here and ( not ) there:

RotatedObject-TagApplied-BBAccumRotation-value-assigned-0.PNG

Properties panel:

RotatedObject-TagApplied-BBAccumRotation-value-assigned-0-PropertiesPanel.PNG

Never trust the value of BBAccumRotation, I'd say 😉

I also tested method add() with object tag. I did just that:

var myNewTag = app.selection[0].tags.add();

Without giving any properties. No value for "name", no value for "value".

Results:

For property name Illustrator added the string "AdobeTempTagName1".

For property value Illustrator set the value to an empty string.

I did not expect this. I expected an empty string by default in both cases.

So let's repeat this little experiment where we assign an empty string as value for "name" and "value". Result in both cases: An empty string will be assigned:

var myNewTag = app.selection[0].tags.add();

myNewTag.name = "";

myNewTag.value = "";

$.writeln( "myNewTag.name: "+myNewTag.name ); // Now an empty string is returned.

$.writeln( "myNewTag.value: "+myNewTag.value ); // Result as expected: An empty string.

If we now do the first experiment again with the same selected object, Illustrator is naming the new tag "AdobeTempTagName2".

Do it again with an untagged object, "AdobeTempTagName1" is added as name. Remove the tag and do it again, "AdobeTempTagName1" will be added as name again. So Illustrator is keeping track of the number of tags and its names.

It's also possible to add a tag named "BBAccumRotation" and a value like "0.9" to an unrotated object.

The surprising result for a user would be:

Tag-named-BBAccumRotation-assigned-to-unrotated-rectangle.PNG

That imposes the question if we could add quite another tag with the same name.

My tests are showing this is no problem at all. So we should be very careful when adding tags to objects!

First test if the tag with a specific name is already there. Best loop all the applied tags, because:

tags.getByName("Name")

will only get the first tag with that specific name in the collection of tags added for an object.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

If you are coming from the InDesign side of scripting don't try something like that:

var myNewTag = app.selection[0].tags.add( { name : "myNewTag" , value : "0" } );

Method add() has no argument. If you try to provide an object like the one above as you are used to with InDesign, you'll make Illustrator CC 2019 hang ( and perhaps finally crash ).

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

LATEST

Great findings!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 01, 2015 Oct 01, 2015

Copy link to clipboard

Copied

Aha! I finally found an intended use for these "tags", though it may have been obvious to others, and may have been what you were trying to tell me, Carlos:

So apparently you can't just willy-nilly add custom properties to document items as you can with scriptUI elements.

However, you can to the document selection, though.

    var doc = app.activeDocument, item;

    for(var i=0; i<doc.pathItems.length; i++){

        item = doc.pathItems;

        item.myProp = item.fillColor.red +"," + item.fillColor.green + "," item.fillColor.blue;

    }

    for(var i=0; i<doc.pathItems.length; i++){

        item = doc.pathItems;

        alert(item.myProp); // undefined

    }

    var doc = app.activeDocument, item;

    for(var i=0; i<doc.selection.length; i++){

        item = doc.selection;

        item.myProp = item.fillColor.red +"," + item.fillColor.green + "," + item.fillColor.blue;

    }

    for(var i=0; i<doc.selection.length; i++){

        item = doc.selection;

        alert(item.myProp); // 255,255,255

    }

So when using pathItems, a tag can be added as a means of recording some custom property.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2015 Oct 01, 2015

Copy link to clipboard

Copied

hmm, cool dude, but myProp is a js property, not a Tag

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 01, 2015 Oct 01, 2015

Copy link to clipboard

Copied

Well duh! The above is an example of myProp not working as an example of where a tag can be used instead

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 30, 2015 Oct 30, 2015

Copy link to clipboard

Copied

Hello together

I'have the same problem that the reference say that tag are available for documents and page items. All samples above who the use with page items which i already use. But now i need Tags for the document and all I've tried failed. (Using Applescript, not Javascript.)

So had anyone had success to add a tag to the document itself?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 02, 2015 Nov 02, 2015

Copy link to clipboard

Copied

Quick test in javascript confirms that Illustrator does not allow tags to be added to the document object. You could use the XMP string, perhaps, but it only appears tags are for pageItems.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2015 Nov 02, 2015

Copy link to clipboard

Copied

Thanks for approving this. So it seems that the documentation ist simply wrong since years / versions...

Currently I've saved my data to a separate folder. Perhaps sometimes I will try the XMP string way.  But now, my data have to live in it's own file 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 02, 2015 Nov 02, 2015

Copy link to clipboard

Copied

If you already to go extent of saving a file in a folder for pure data, why not add a hidden pageItem to your document for the purpose of adding a tag?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2015 Nov 02, 2015

Copy link to clipboard

Copied

I needed a fast way. Really fast. So I took the shortest way. And by writing the data to a file it was compatible to an extra which I wrote for Freehand 🙂

Hint: I'm saving layer name, visible and locked state to files. By reading it back it's possible to restore whole Sets of layers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 08, 2015 Nov 08, 2015

Copy link to clipboard

Copied

Hello!

I have recently had the privilege of spending several hours bumping my head on the wall, trying to figure out the way to fetch data from the XMP data.

If I thought the ExtendScript's XML(string) function and its related methods to traverse and XML document was un-intuitive, the XMP API makes that look like child's play!

Anyways, I finally was able to use the advice on this forum (By Ten A‌) along with others, to produce the following function which actually reads the data from the "Description" field of the first section of the XMP.

function ReadXMPviaLibrary(targetFile){

  if(ExternalObject.AdobeXMPScript == undefined) {

      ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

  }

  var fNm = targetFile, obj;

  var xmp = new XMPFile( fNm.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

  obj = xmp.getXMP();

  xmp.closeFile();

  var descriptionString = "";

  try{

    descriptionString = obj.getLocalizedText(XMPConst.NS_DC, "description", null, "en");

    return descriptionString;

  } catch(e){

    return null;

  }

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 09, 2015 Nov 09, 2015

Copy link to clipboard

Copied

Hi Silly-V,

thanks for sharing your approach to store ans reload data into a Illustrator document.  Perhaps I will gone sometimes the same road but shortly I will stay with my current solution because it's already working for me.

By the way, the documentation about tags directly attached to the document seems to be a long time bug. With in the documentation or implementation of Illustrator. Who knows.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2015 Nov 10, 2015

Copy link to clipboard

Copied

Hi,

I have some solutions that store some information in custom metadata. Here is a script version:

//Meta Memo Ver.0.1.0beta

//AI & ID CC CS5 and later.

idmeta ={

  ns : "http://ns.chuwa.sytes.net/idcomment/1.0/",

  prefix : "ID_meta:",

  f : app.activeDocument,

  win : function(){

  if (!app.activeDocument.saved){

  alert("You need to save before write memo.");

  return;

  }

  var n = this.getLen();

  var w = new Window('dialog', 'meta memo', undefined);

  if (n==0){

  var pn = w.add('panel',undefined,'add memo');

  var tx = pn.add('edittext',[5,10,350,60],'',{multiline:true});

  var b = pn.add('button',undefined,'update');

  var cl = w.add('button', undefined, 'cancel', {name:'cancel'});

  b.onClick = function (){

  idmeta.write("memo1", tx.text);

  }

  }

  else {

  for (var i=1;i<n+1;i++){

  eval("p"+ i +"= w.add('panel',undefined,'memo" + i + "');");

  eval("t"+ i +"=p"+ i +".add('edittext',[5,10,350,60],'',{multiline:true});");

  eval("t"+ i +".text=this.read('memo"+i+"');");

  eval("bt"+ i +"= p"+ i +".add('button',undefined,'update"+i+"');");

  eval("bt"+i+".onClick=function (){"

  +"idmeta.write('memo" + i + "',t" + i + ".text);}");

  }

  pn = w.add('panel',undefined,'add memo');

  tx = pn.add('edittext',[5,10,350,60],'',{multiline:true});

  b = pn.add('button',undefined,'update');

  b.onClick = function (){

  idmeta.write("memo"+i++, tx.text);

  }

  var cl = w.add('button', undefined, 'Close', {name:'cancel'});

  }

  w.show();

  },

  read : function(prop){

  if(xmpLib==undefined) var xmpLib = new ExternalObject('lib:AdobeXMPScript');

  var xmpFile = new XMPFile(this.f.fullName.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

  var xmpPackets = xmpFile.getXMP();

  var xmp = new XMPMeta(xmpPackets.serialize());

  return xmp.getProperty(this.ns, prop).toString();

  },

  write : function(prop, val){ //f:fileObject, val1:String, val2:String

  if(xmpLib==undefined) var xmpLib = new ExternalObject('lib:AdobeXMPScript');

  var xmpFile = new XMPFile(this.f.fullName.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

  var xmp = xmpFile.getXMP();

  var mt = new XMPMeta(xmp.serialize());

  XMPMeta.registerNamespace(this.ns, this.prefix);

  mt.setProperty(this.ns, prop, val);

  if (xmpFile.canPutXMP(xmp)) xmpFile.putXMP(mt);

  xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

  },

  getLen : function(){

  if(xmpLib==undefined) var xmpLib = new ExternalObject('lib:AdobeXMPScript');

  var xmpFile = new XMPFile(this.f.fullName.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

  var xmpPackets = xmpFile.getXMP();

  var xmp = new XMPMeta(xmpPackets.serialize());

  try{

  var len = xmp.dumpObject().match(/memo\d/g);

  if (len==null) return 0;

  else return len.length;

  }catch(e){

  return 0;

  }

  }

  }

idmeta.win();

more information and CEP Extensions are available below, But Japanese only. Please use translate service like google translate.

http://chuwa.iobb.net/tech/archive/2014/02/metadata.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 26, 2016 Feb 26, 2016

Copy link to clipboard

Copied

Here's a fun exercise. This quite-slow script can be used to assign tags to art. It is also contained in one object which through much trial and error was honed to send itself through BridgeTalk so as to run itself from a palette button. One interesting thing is that without #targetengine "main", it would instantly disappear when not ran from ESTK.

Also, while it does seem to work when double-clicked to run in AI, it doesn't close - so doubleclicking is not recommended.

#target illustrator

#targetengine "main"

function ArtItemTagger(){

  var Tagger = {

  BridgeTalkActions : {

  asSourceStringObj : function(obj){

  return obj.toSource();

  },

  bridgeTalkEncode : function( txt ) {

  txt = encodeURIComponent( txt );

  txt = txt.replace( /\r/, "%0d" );

  txt = txt.replace( /\n/, "%0a" );

  txt = txt.replace( /\\/, "%5c" );

  txt = txt.replace(/'/g, "%27");

  return txt.replace(/"/g, "%22");

  },

  sendBTmsg : function(objStr, targetApp, resultFunc){

  var bt = new BridgeTalk;

  bt.target = targetApp;

  var btMsg = Tagger.BridgeTalkActions.bridgeTalkEncode(objStr);

    btMsg = "var scp ='" + btMsg + "'";

    btMsg += ";\nvar scpDecoded = decodeURI( scp );\n";

    btMsg += "eval( scpDecoded );";

  bt.body = btMsg;

  /*alert(bt.body);/*###*/

  if(typeof resultFunc == "function"){

    bt.onResult = resultFunc;

    /* resultFunc takes the (result) default argument that's implied.*/

  }

  bt.send();

  }

  },

  UI : {

  tabPalette : function(){

  var w = new Window("palette");

  w.margins = [0,0,0,0];

  var btn = w.add("button", undefined, "Tagger");

  btn.size = [100, 35];

  function writeDebugFile(contents){

  var f = File("~/Desktop/debug.txt");

  f.open('w');

  f.write(contents);

  f.close();

  };

  btn.onClick = function(){

  var str = "var Tagger = " + Tagger.BridgeTalkActions.asSourceStringObj(Tagger).toString().replace(/(^\(|\)$)/g, '') + "\rTagger.init();";

  /*writeDebugFile(str);*/

  /*return;*/

  Tagger.BridgeTalkActions.sendBTmsg(

  str,

  ("illustrator-" + app.version.substr(0, 2))

  );

  };

  w.show();

  },

  makeEditableReadonlyEdittext : function(parent, chars, defaultText){

  /* an edittext group which holds 2 inputs so that it can be toggled for editability*/

  defaultText = defaultText || "";

  chars = chars || 20;

  var stackGroup = parent.add("group");

  stackGroup.orientation = "stack";

  var readonlyEdittext = stackGroup.add("edittext", undefined, defaultText, {readonly : true});

  var editableEdittext = stackGroup.add("edittext", undefined, defaultText);

  readonlyEdittext.characters = editableEdittext.characters = chars;

  return {

    editable : editableEdittext,

    readonly : readonlyEdittext,

    getValue : function(){

      if(this.editable.visible){

        return this.editable.text;

      } else {

        return this.readonly.text;

      }

    },

    setValue : function(value){

      this.editable.text = this.readonly.text = value;

    },

    toggle : function(key){

      var elem;

      for(var all in this){

        elem = this[all];

        if(elem.hasOwnProperty("type") && elem.type == "edittext"){

          if(all == key){

            elem.visible = true;

          } else {

            elem.visible = false;

          }

        }

      }

    }

  };

  },

  makeInputControl : function(parent, elem, argsObj){

  /* { name : string(name) , value : string(value), helpTip : string(help-string), (processFunction : function) }*/

  var g = parent.add("group");

  var lbl = g.add("statictext", undefined, argsObj.name + ":");

  var e = this.makeEditableReadonlyEdittext(g, 20, elem[argsObj.name]);

  e.toggle("readonly");

  e.readonly.helpTip = argsObj.helpTip;

  var btn = g.add("button", undefined, "Edit");

  btn.onClick = function(){

  if(this.text == "Edit"){

  e.toggle("editable");

  e.editable.active = false;

  e.editable.active = true;

  this.text = "Set";

  } else {

  var textString = e.getValue();

  elem[argsObj.name] = textString;

  if(argsObj.hasOwnProperty("processFunction")){

  argsObj.processFunction(elem);

  }

  e.setValue(textString);

  e.toggle("readonly");

  this.text = "Edit";

  }

  }

  },

  displayTagsList : function(list, elem){

  list.removeAll();

  var itemTags = Tagger.documentActions.getTags(elem), thisTag, listItem;

  for (var i = 0; i < itemTags.length; i++) {

  thisTag = itemTags;

  listItem = list.add("item");

  listItem.text = thisTag.name;

  listItem.subItems[0].text = thisTag.value;

  }

  },

  tagDialog : function(tagObj, elem, purpose){

  /* { name : string(name) , value : string(value) }*/

  var w = new Window("dialog", "Tag Options");

  var g = w.add("group");

  var g1 = g.add("panel", undefined, "Tag Name");

  var e1 = g1.add("edittext", undefined, tagObj.name);

  e1.characters = 20;

  e1.onChanging = function(){

  this.text = this.text.replace(/[^\w\d_]/g, "_");

  };

  var g2 = g.add("panel", undefined, "Tag Value");

  var e2 = g2.add("edittext", undefined, tagObj.value);

  e2.characters = 20;

  var g_btn = w.add("group");

  var btn_ok = g_btn.add("button", undefined, "Ok");

  var btn_ccl = g_btn.add("button", undefined, "Cancel");

  if(w.show() == 2){

  return false;

  } else {

  var thisTag;

  if(purpose == "edit"){

  thisTag = elem.tags.getByName(tagObj.name);

  } else if (purpose == "add") {

  thisTag = elem.tags.add();

  }

  thisTag.name = e1.text;

  thisTag.value = e2.text;

  return true;

  }

  },

  mainDialog : function(){

  var w = new Window("dialog", "Tagger");

  w.spacing = 4;

  var g_props = w.add("panel", undefined, Tagger.selectedItem.typename + " Properties:");

  g_props.alignChildren = "right";

  for( var all in Tagger.propObj ){

  this.makeInputControl(g_props, Tagger.selectedItem, Tagger.propObj[all]);

  }

  var g_tagList = w.add("group");

  g_tagList.orientation = "column";

  var list = g_tagList.add("listbox", undefined, [], {

  numberOfColumns: 2,

  showHeaders: true,

  columnTitles: ["Tag Name", "Value"],

  columnWidths: [100, 200]

  });

  list.size = [340, 200];

  g_tagList.helpTip = "This list shows the Adobe illustrator tags assigned to art items." +

  "The 'tag' is a way to store custom data to an art object, and some tags get assigned automatically when a certain user action " +

  "is performed on specific art items, such as rotating a text box or a raster image. Other than auto-assignment, tags are only known " +

  "to be set by scripts, such as this one.";

  this.displayTagsList(list, Tagger.selectedItem);

  list.onDoubleClick = function(){

  if(this.selection == null){

  return;

  }

  var result = Tagger.UI.tagDialog(

  Tagger.selectedItem.tags.getByName(this.selection.text),

  Tagger.selectedItem,

  "edit"

  );

  if(result){

  Tagger.UI.displayTagsList(this, Tagger.selectedItem);

  }

  };

  var g_listBtn = g_tagList.add("group");

  g_listBtn.margins = [4,4,4,4];

  var btn_add = g_listBtn.add("button", undefined, "Add");

  btn_add.size = [160, 30];

  var btn_rem = g_listBtn.add("button", undefined, "Remove");

  btn_rem.size = [160, 30];

  btn_add.onClick = function(){

  var result = Tagger.UI.tagDialog({name : "NewTag", value : ""}, Tagger.selectedItem, "add");

  if(result){

  Tagger.UI.displayTagsList(list, Tagger.selectedItem);

  }

  };

  btn_rem.onClick = function(){

  if(list.selection != null){

  Tagger.selectedItem.tags.getByName(list.selection.text).remove();

  Tagger.UI.displayTagsList(list, Tagger.selectedItem);

  }

  };

  var g_btn = w.add("group");

  var btn_ok = g_btn.add("button", undefined, "Ok");

  w.show();

  }

  },

  documentActions : {

  getTags : function(elem){

  var arr = [], thisTag;

  for (var i = 0; i < elem.tags.length; i++) {

  thisTag = elem.tags;

  arr.push({

  name : thisTag.name,

  value : thisTag.value

  });

  }

  return arr;

  }

  },

  propObj : {

  name : {

  name : "name",

  value : "",

  helpTip : "The name of the art item inside the Layers panel."

  },

  note : {

  name : "note",

  value : "",

  helpTip : "The note for this art item, accessible inside the Attributes panel."

  },

  uRL : {

  name : "uRL",

  value : "",

  helpTip : "The URL for this art item, accessible inside the Attributes panel.",

  processFunction : function(elem){

  elem.selected = false;

  elem.selected = true;

  }

  }

  },

  selectedItem : undefined,

  init : function(){

  if(app.documents.length == 0){

  alert("Please open a document first.");

  return;

  }

  var doc = app.activeDocument, sel = doc.selection;

  if(sel == null){

  alert("Please select an item.");

  }

  if(sel.length != 1){

  alert("Please select only one item. Currently selected: " + sel.length + " items.");

  return;

  }

  this.selectedItem = sel[0];

  for( var all in this.propObj ){

  this.propObj[all].value = this.selectedItem[all];

  }

  this.UI.mainDialog();

  }

  };

  Tagger.UI.tabPalette();

};

ArtItemTagger();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

I also added a tag to a page item via script (is there any other way?)

do you mean manually using the UI? no that I know of, an alternative would be to use the Note Property

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

Hmm, perhaps through a custom UI, someone can have good control over a particular process with illustrator-generated PDFs and AI files. They are persistent, and you can put scripts in them to be activated by down-stream activity. Hmm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines