Author Topic: Some Illustrator 10 Javascripts I use  (Read 2705 times)

0 Members and 1 Guest are viewing this topic.

Offline markuso

  • Newbie
  • *
  • Posts: 44
  • Karma: 0
Some Illustrator 10 Javascripts I use
« on: February 07, 2008, 11:17:32 AM »
Hi, All!

Since this forum has been helpful, I thought I would post some of the AI10 javascript I've used:

===========
// Delete each embedded image
countOfRasterItems = activeDocument.rasterItems.length;
for (r=countOfRasterItems-1; r>=0; r--) {
   var targetItem = activeDocument.rasterItems[r];
   targetItem.remove();
}
===========
// List all active fonts - one at a time
for (i=0; i<textFaces.length; i++) {
   var fontToTest = textFaces;
   alert("Font " + i + " is " + fontToTest);
}
===========
// Unlock all visible layers
countOfLayers = activeDocument.layers.length-1;
for (j=countOfLayers; j>=0; j--) {
   targetLayer = activeDocument.layers[j];
   if (targetLayer.visible == true) {
      targetLayer.locked = false;
   }
}
===========
// save all open documents as flash documents

numDocuments = documents.length;

for (i = 0; i < numDocuments; i++) {
   aDocument = documents;
   theDocumentName = aDocument.name;
   
   flashOptions = new ExportOptionsFlash();

   flashOptions.curveQuality = 10;
   flashOptions.generateHTML = true;
   flashOptions.jpegQuality = 10;
   flashOptions.readOnly = true;
   flashOptions.replacing = SaveOptions.SAVECHANGES;
   flashOptions.resolution = 300;

   docPath = aDocument.path;
   docPathStr = docPath.toString();

   if (docPathStr.length > 1)    {
      documentPath = docPath + "/" + aDocument.name;
   } else {
      // This is a brand new file and doesn't have a path yet,
      // so put it in the illustrator application folder.
      documentPath = path + "/" + aDocument.name;
   }

   theFile = new File(documentPath);
   aDocument.exportFile(theFile, ExportType.FLASH, flashOptions);
}
===========
// Find and Remove all text strings
countOfTextItems = activeDocument.textArtItems.length;
for (e=countOfTextItems-1; e>=0; e--) {
   var targetText = activeDocument.textArtItems[e].contents;
   if (targetText == "Redneck") {
      targetItem.remove();
   }
}
============

I'll post more later . . . duty calls!

Mark

Offline markuso

  • Newbie
  • *
  • Posts: 44
  • Karma: 0
Re: Some Illustrator 10 Javascripts I use
« Reply #1 on: February 07, 2008, 02:47:51 PM »
If anyone is interested, I'll post more . . . .

Mark

Offline norbert_ds

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Some Illustrator 10 Javascripts I use
« Reply #2 on: May 11, 2008, 10:11:20 PM »
Hi Mark,

Do you have an export to JPEG where all the otions available in illustrator's user interface have been scripted?

Regards
Norbert

Offline markuso

  • Newbie
  • *
  • Posts: 44
  • Karma: 0
Re: Some Illustrator 10 Javascripts I use
« Reply #3 on: June 10, 2008, 02:44:57 PM »
Hi.

Here are the possibilities for 10 & CS2...

antiAliasing - Boolean (default true)
artBoardClipping - Boolean (default false)
blurAmount - number from 0.0 to 2.0 (default 0.0)
horizontalScale - number (default 100%)
matte - boolean (default true
matteColor - RGBColor object (default white)
optimization - Boolean (default true)
qualitySetting - number from 0 to 100 (default 30)
saveAsHTML - Boolean (default false)
typename - string (read only)
verticalScale - number from 0 to 100 (default 100)

Hope this helps!

Mark