Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all 12845 articles
Browse latest View live

A script for replacing texts only in selected layer?

$
0
0

Hi all,

I have an illustrator document which has many text layers. I have found the script below that replace a text with another one in the document;

 

var doc = app.activeDocument;

var myTextFrames = doc.textFrames;

 

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

var myTF_ByI = myTextFrames[i];

var str = myTF_ByI.contents

var res = str.replace("word1", "word2");

myTF_ByI.contents = res

}


However, there is one problem that the script also replaces the text in other layers even though they are hidden or locked. Could you help me adjust this script to be effective only for the selected or unhidden layer?

 

Cheers,

Akin


Simple InDesign script -> Illustrator help

$
0
0

I have this script by Peter Kahrel that reverese the order of letters in InDesign.

 

I need an Illustrator version of it. Can anybody help?

 

---------------------

//ReverseText.jsx

//An InDesign Javascript that reverses the order of any selected text.

//If no text is selected with the Type tool, nothing happens.

//Written by Peter Kahrel for InDesignSecrets.com

//****************

 

#target indesign

if ( "TextWordLineParagraph".search ( app.selection[0].constructor.name ) < 0 )

    exit();

s = app.selection[0].contents;

s = s.split("").reverse().join("");

app.selection[0].contents = s;

-------------------

 

Mainly using this for Arabic text in CS 3 and 4 for clients that don't have new versions - and will never buy it apparently.

 

Works great in InDesign. I've been putting the text in ID and then copying it into Illustrator. But it would be nice to skip that step if possible.

 

Thanks in advance.

Find a specific Sublayer and move to top level layer

$
0
0

I have a lot of illustrator files that are organized by a template size. The layers are setup so that the top level layer is always Template. However the sublayer I need to move to the top level could be called 42 Pg Border or 30 Pg Border or 24 Pg Border.

Is there a way for a script to search through the layers and if it finds "42 Pg Border" or "30 Pg Border" or "24 Pg Border" in the sublayer Template it would move it to the top level but if it doesn't see one of those it doesn't give an error?

 

I'm still new to scripting so the extent of my knowledge on this is to scan all the layers and unlock them. Then look for a specific layer name. It's the sublayer and moving it to the top level that I am not sure of.

 

Here is my current code:

var doc = app.activeDocument;
var allLayers = doc.layers;
for (var i = allLayers.length-1; i >= 0; i--){    allLayers[i].locked = false;    if (allLayers[i].name == "42 Pg Border" || allLayers[i].name == "30 Pg Border" || allLayers[i].name == "24 Pg Border") {        alert("I found the " + allLayers[i].name + " layer")    } else {        alert("Not the right layer")    }
}

 

Any help would be greatly appreciated!

I am using CS4 on a Windows 64 Bit PC with JavaScript

can we create AI template that can be rendered into vectors

$
0
0

Hi Everyone.

 

Sorry if I am asking a repeated question.

 

I am trying to create a script ( or find a third party tool ) that will convert PDF/Image to vector for engraving.

Just like this page "Precision Bitmap To Vector Conversion Online- Vector Magic"

I have tried Inkscape for this but the SVG file generated by this tool is no good for engraving.

 

So now I am seeking solution in Adobe illustrator.

I know that this is feasible as people have done this.

 

Thanks in advance.

Edit Text onChange bug

$
0
0

Hi guys. I am experiencing a weird bug. Here's the code:

 

var myNumber = 3

var win = new Window( "dialog", "Slice it Up" );

 

var firstET = win.add("edittext", undefined, myNumber);

      firstET.characters = 5;

var secondET = win.add("edittext", undefined, myNumber);

      secondET.characters = 5;

 

firstET.onChange = function ()          { alert("Changed FIRST Edit Text");}

secondET.onChange = function ()    { alert("Changed SECOND Edit Text");}

win.show();

 

Thing is, when you change value in first Edit Text slot AND click with mouse button (or TAB) to activate second Edit Text, script calls secondET.onChange function before even calling firstET.onChange. Even though second Edit Text slot hasn't beed changed.


Is this a known bug? Tested on CS6 and CC, MacOS.

 

Am I doing something wrong here?

How do you recursively loop through sublayers and groups?

$
0
0

I've been fairly successful looping through an AI file, and was able to loop through layers and pull text Layers, to a specified layer. Problem being, that I also want to capture anything that's nested in groups, and depending on which way I put the try statements, it will only catch parts of the editorial in my file. The problem occurs within the traverseSubs function, I had both groupItems and layers in one loop, but it wasn't fully going through anything, so I set 2 different variables to loop through.

 

actDoc = app.activeDocument;

textLayerName = "Live Editorial"

layLen = actDoc.layers.length;

function catchText(grabTextFrom,whereTo) {

    try{textCatchLayer = actDoc.layers.getByName(whereTo)}

    catch(e){

        var textCatchLayer = actDoc.layers.add();

        textCatchLayer.name = textLayerName;

        textCatchLayer.printable = false;

        textCatchLayer.zOrder(ZOrderMethod.BRINGTOFRONT);

    }

    var tF = grabTextFrom.textFrames

    var tFL = tF.length;

    for ( i = 0; i < tFL; i++) {

       tF[i].duplicate(textCatchLayer, ElementPlacement.PLACEATEND);

    }

}

 

function traverseSubs(current) {

        catchText(current,textLayerName);

        for ( h = 0; h < current.groupItems.length; h++) {

            try{if(current.groupItems.length > 0) traverseSubs(current.groupItems[h])}

            catch(e) {$.write(e)}

        }

        for ( i = 0; i < current.layers.length; i++) {

            try{ if(current.layers.length > 0) traverseSubs(current.layers[h])}

            catch(e) {$.write(e)}

        }

}

 

for (j = 0; j < layLen; j++){

        curLay = actDoc.layers[j];

        if(curLay.name == textLayerName) continue;

        traverseSubs(curLay);

}

 

I also tried the below:

 

tF = app.activeDocument.textFrames

tFL = tF.length

  for(i=0;i<tFL;i++){

        tF[i].duplicate(app.activeDocument.layers.getByName("Live Editorial "), ElementPlacement.PLACEATEND);

}

 

But it only grabbed the same Text 5 times.

Convert .ai to .doc

$
0
0

Hi,

 

Can it be possible to convert .ai file into .doc file or any tool which will do this conversion.

 

Thanks,

Shail

Multiple artboards to multiple PDF's

$
0
0

I have over 300 different ai files with about 50 artboards in each one and need to export each artboard to a separate PDF file.  I'm on a windows machine so the script would have to be JavaScript.  Is this possible?

 

I found the following script on the forums, which is close, but I really need actual PDF files (not just "PDF compatible" ai files):

 

Thanks so much!

Tim



//splits the activeDocument Artboards into individual files

 

var doc = app.activeDocument;

 

var docName = doc.name;
var docPath = doc.path;
var fullName = docPath + "/" + docName;
var abRange = ""

 

for (i=1; i<=doc.artboards.length;i++)
    {
        abRange = abRange + i + ","
     }
IllustratorSaveOptions.saveMultipleArtboards = true;
IllustratorSaveOptions.artboardRange = abRange;

var newFile = new File(fullName);
app.activeDocument.saveAs (newFile, IllustratorSaveOptions);

alert ("Artboards Saved to current document's Folder", "Split Arboards");


Change overprint of color with Applescript

$
0
0

I want to overprint a PMS colors using Applescript. I though if I changed the property of the selected items fill color from (fill overprint:false) to (fill overprint:true) it would work. This doesn't seem to change a thing.

 

This is the script I am currently using:

 

script ChangeOverprint

    tell application "Adobe Illustrator"

       

        local docRef

        set docRef to current document

       

        tell docRef

            set fileName to name of docRef

            log fileName

           

            set pathItemProperties2 to properties of (path item 2 of layer 1 of docRef)

           

            set fill overprint of pathItemProperties2 to true

            log pathItemProperties2

           

            set pathItemProperties3 to properties of (path item 3 of layer 1 of docRef)

            log pathItemProperties3

        end tell

       

    end tell

   

end script

 

-- to test

run ChangeOverprint

 

This is the picture of a simple document I created. The elipse has fill overprint:true. The polygon has filr overprint:false. The original value for the property fill overprint was false. I changed it in the script to true. Which the log shows it changed.

 

Thanks

Rich

TestOverPrint_01.jpg

Can I get some value from user? (illustrator cs3 script)

$
0
0

I am Designer. But I have to write program.

 

I will making plugin about draw rectangle.

 

 

 

1. User run illustrator cs3.

 

2. User click File-Scripts-myDraw

 

3. Show dialog box. Dialog box have two inputField. User input values.(ex>53.32,   41.2)

 

4. click 'summit' button.

 

5. illustrator cs3 draw 53.32 * 41.2 size rectangle!!

 

 

 

I don't know How I made dialogbox...

 

Is it possible get value from user?

 

 

what is 'cin' code as illustrator javascript?  (cin : C++ style input code.)

 

 

please help me.

Move layers to new artboard

$
0
0

Hi everybody,

 

I'm trying to create a script via javascript for Illustrator.

 

My problem is :

I have a AI file with multiple layers, i want to create one artboard per layer, in order to export a multipage PDF ( each page contain 1 layer ).

 

The layers represents the differents type of print ( vernish, color, hot gold, pressure ... ) and/or color type ( Pantone, CMYK, cut, kisscut ... ).

My client want a PDF for see each type of print or color type per page.

 

I'm trying 2 ways :

 

1st solution : Create new artboards, and duplicate ( or move ) layers content on the new artboad, but the function move/duplicate don't work to move content on another artboard.

 

2nd solution : Create new document with the same number of layers as artboard and duplicate layer to the new artboard on the new document.

 

Can you help me to realize this script ?

 

Excuse me if my english is not good.

ungroup all groups on an active layer(JavaScript).

$
0
0

Does anyone know how one would go about ungrouping all groups on an active layer with JavaScript?

A Script to Find and Replace Layer Names

$
0
0

Are there any scripts to find and replace layer names?

 

There is an excellent script available for Photoshop which allows you to not only replace words in layer names, but also insert words as Prefixes, Suffixes and Sequential Numbers.

The illustrator version of this script only allows sequential numbering: It doesn't offer find and replacing of words.

 

Ideally, it would be great if there was something that could do multiple find and replaces in one go:

(e.g.

You have layers like this Car, Dog, Bat

You enter: car(Option1), dog(Option2), Bat(Option3)

Your layers then become: Option1, Option2, Option3).

)

Break text area into text lines

$
0
0

I want to break text area with line breaks in it into seperate text lines using return as delineator. for example

 

"Line 1

Line 2

Line 3"

 

I would like as

 

"Line 1"

"Line 2"

"Line 3"

 

I could probably write something but curious if someone already wrote it. I found a few similar ones like

http://forums.adobe.com/thread/321610

 

but they seem to be broken for CC here is the script in case you're curious

 

/////////////////////////////////////////////////////////////////
//Divide TextFrame v.2.2 -- CS and up
//>=--------------------------------------
// Divides a multiline text field into separate textFrame objects.
// Basically, each line in the selected text object
// becomes it's own textFrame. Vertical Spacing of each new line is based on leading.
//
// This is the opposite of my "Join TextFrames" scripts which
// takes multiple lines and stitchs them back together into the same object.
// New in 2.1 now right and center justification is kept.
// New in 2.2 better error checking, and now will run on more than one text frame at a time.
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
//copyright full text here:  http://www.wundes.com/js4ai/copyright.txt
//////////////////////////////////////////////////////////////////


var doc = activeDocument;
var genError= "DivideTextFrame must be run on a point-text text-frame. ";
var ret_re = new RegExp("/[\x03]|[\f]|[\r\n]|[\r]|[\n]|[,]/");
if(doc){
        var docsel = doc.selection;        var sel = [];    //remember initial selection set         for(var itemCt=0, len = docsel.length ;itemCt<len;itemCt++){             if(docsel[itemCt].typename == "TextFrame"){                  sel.push(docsel[itemCt]);             }         }            if(sel.length){  //alert(sel.length+" items found.");            for(var itemCt=0, len = sel.length ;itemCt<len;itemCt++){                divide(sel[itemCt]);            }             }else{                alert(genError +"Please select a Text-Frame object. (Try ungrouping.)");        }      
}else{    alert(genError + "No document found.");
};

function divide(item){
             //get object position    var selWidth = item.width;
if(item.contents.indexOf("\n") != -1){          //alert("This IS already a single line object!");
}else{           //getObject justification    var justification = item.story.textRange.justification;             //make array          var lineArr = fieldToArray(item);          tfTop = item.top;          tfLeft = item.left;          item.contents = lineArr[0];          //for each array item, create a new text line          var tr = item.story.textRange;          var vSpacing = tr.leading;    var newTF;          for(j=1 ; j<lineArr.length ; j++){                    newTF = item.duplicate(doc, ElementPlacement.PLACEATBEGINNING);                    newTF.contents = lineArr[j];                    newTF.top = tfTop - (vSpacing*j);        if(justification == Justification.CENTER)        {             newTF.left = (tfLeft + (selWidth/2)) - (newTF.width/2);        }    else            if(justification == Justification.RIGHT)        {            newTF.left = (tfLeft + selWidth) - newTF.width;        }    else    {           newTF.left = tfLeft;    }                    newTF.selected = false;          }
}


function fieldToArray(myField) {                     retChars = new Array("\x03","\f","\r","\n");                    var tmpTxt = myField.contents.toString();                    for (all in retChars )                    {            tmpArr = tmpTxt.split(retChars[all]);                    }                     return tmpTxt.split(ret_re);          }    }

Anything similar to javascript's setInterval in ExtendScript?

$
0
0

I need a way to poll my server for new jobs for the illustrator script to work on every few hours.

I tried with $.sleep(), but that is blocking, I need a non-blocking way to do this.

Any advice?

 

Thanks!

Kashmira


How can I find items which have crop marks effect?

$
0
0

Now, I am creating a script for Illustrator CS4, CS5, CC2014 with Japanese version in Windows.

I wish to find items which have Crop Marks Effect (which is created by Effect > Crop Marks) by Javascript or VBScript.

 

Is it possible?

Any help is appreciated.

How do I make a symbol from selection?

$
0
0

I've got the below script, but it's not working. I'm trying to select all the art in the document on different layers, and create a symbol. So far I have the first part down, but can't figure out how to reference what is selected. actDoc.selection comes out as undefined. I've also tried to use "actDoc.PageItem.selected = true" and a few other variants, but I'm coming up empty. Anyone have recommendations for this?

 

actDoc = app.activeDocument

var layerCount = actDoc.layers.length;

if(layerCount > 1) {

    for(i=0;i<layerCount;i++) {

    actDoc.layers[i].hasSelectedArtwork = true // selects all layers

    }

   actDoc.symbols.add(actDoc.selection); // <---------- Here's where the error is thrown

}

Problem with IllustratorSaveOptions not saving on Mac but work perfectly on Windows [extendscript]

$
0
0

Hey everyone- I am currently running Illustrator CS5 on Windows 7 using extendscript. My issue is this:

 

When testing this script on any Windows machine, my script runs as it should but when I try to run it on a Mac using Illustrator CS4, the PDFs save as they should, but the Illustrator file doesn't. The folder contains the PDFs but no Illustrator. I'm currently using CS5 and the IllustratorSaveOptions specify to save as a CS4 file. Any help would be appreciated. I've seen other posts showing IllustratorSaveOptions that  had  "+ 'ai'" and "+ '.pdf'" at the end of the file string. Could that have anything to do with it? The most important part of the script is towards the bottom. Here is my script:

 

 

#target illustrator
var myDoc = activeDocument;

var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
  timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
  timezoneClip = /[^-+\dA-Z]/g,
  pad = function (val, len) {
   val = String(val);
   len = len || 2;
   while (val.length < len) val = "0" + val;
   return val;
  };

// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
  var dF = dateFormat;

  // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
  if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
   mask = date;
   date = undefined;
  }

  // Passing date through Date applies Date.parse, if necessary
  date = date ? new Date(date) : new Date;
  if (isNaN(date)) throw SyntaxError("invalid date");

  mask = String(dF.masks[mask] || mask || dF.masks["default"]);

  // Allow setting the utc argument via the mask
  if (mask.slice(0, 4) == "UTC:") {
   mask = mask.slice(4);
   utc = true;
  }

  var _ = utc ? "getUTC" : "get",
   d = date[_ + "Date"](),
   D = date[_ + "Day"](),
   m = date[_ + "Month"](),
   y = date[_ + "FullYear"](),
   H = date[_ + "Hours"](),
   M = date[_ + "Minutes"](),
   s = date[_ + "Seconds"](),
   L = date[_ + "Milliseconds"](),
   o = utc ? 0 : date.getTimezoneOffset(),
   flags = {
    d:    d,
    dd:   pad(d),
    ddd:  dF.i18n.dayNames[D],
    dddd: dF.i18n.dayNames[D + 7],
    m:    m + 1,
    mm:   pad(m + 1),
    mmm:  dF.i18n.monthNames[m],
    mmmm: dF.i18n.monthNames[m + 12],
    yy:   String(y).slice(2),
    yyyy: y,
    h:    H % 12 || 12,
    hh:   pad(H % 12 || 12),
    H:    H,
    HH:   pad(H),
    M:    M,
    MM:   pad(M),
    s:    s,
    ss:   pad(s),
    l:    pad(L, 3),
    L:    pad(L > 99 ? Math.round(L / 10) : L),
    t:    H < 12 ? "a"  : "p",
    tt:   H < 12 ? "am" : "pm",
    T:    H < 12 ? "A"  : "P",
    TT:   H < 12 ? "AM" : "PM",
    Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
    o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
    S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
   };

  return mask.replace(token, function ($0) {
   return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
  });
};
}();

// Some common format strings
dateFormat.masks = {
"default":      "ddd mmm dd yyyy HH:MM:ss",
shortDate:      "m/d/yy",
mediumDate:     "mmm d, yyyy",
longDate:       "mmmm d, yyyy",
fullDate:       "dddd, mmmm d, yyyy",
shortTime:      "h:MM TT",
mediumTime:     "h:MM:ss TT",
longTime:       "h:MM:ss TT Z",
isoDate:        "yyyy-mm-dd",
isoTime:        "HH:MM:ss",
isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
dayNames: [
  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
  "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
  "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
return dateFormat(this, mask, utc);
};


var now = new Date();
var now_format = now.format("mmddyy");

/*with (myDoc) {
     for (var i = textFrames.length-1; i >= 0; i--) {
          textFrames[i].createOutline();
     }
     alert('Done…');
}
*/
function outlineDocText(  ) {

          if ( app.documents.length == 0 ) return;
 
  var myDoc = app.activeDocument;
 
          recurseLayers( myDoc.layers );
 
};

outlineDocText();

function recurseLayers( objArray ) {
 
          for ( var i = 0; i < objArray.length; i++ ) {
 
                    // Record previous value with conditional change
                    var l = objArray[i].locked;
                    if ( l ) objArray[i].locked = false;
 
                    // Record previous value with conditional change
                    var v = objArray[i].visible;
                    if ( !v ) objArray[i].visible = true;
 
                    outlineText( objArray[i].textFrames );
 
                    // Recurse the contained layer collection
                    if ( objArray[i].layers.length > 0 ) {
                              recurseLayers( objArray[i].layers )
                    }
 
                    // Recurse the contained group collection
                    if ( objArray[i].groupItems.length > 0 ) {
                              recurseGroups( objArray[i].groupItems )
                    }
 
                    // Return to previous values
                    objArray[i].locked = l;
                    objArray[i].visible = v;
          }
};

function recurseGroups( objArray ) {
 
          for ( var i = 0; i < objArray.length; i++ ) {
 
                    // Record previous value with conditional change
                    var l = objArray[i].locked;
                    if ( l ) objArray[i].locked = false;
 
                    // Record previous value with conditional change
                    var h = objArray[i].hidden;
                    if ( h ) objArray[i].hidden = false;
 
                    outlineText( objArray[i].textFrames );
 
                    // Recurse the contained group collection
                    if ( objArray[i].groupItems.length > 0 ) {
                              recurseGroups( objArray[i].groupItems )
                    }
 
                    // Return to previous values
                    objArray[i].locked = l;
                    objArray[i].hidden = h;
          }
};


function outlineText( objArray ) {
 
          // Reverse this loop as it brakes the indexing
          for ( var i = objArray.length-1; i >= 0; i-- ) {
 
                    // Record previous value with conditional change
                    var l = objArray[i].locked;
                    if ( l ) objArray[i].locked = false;
 
                    // Record previous value with conditional change
                    var h = objArray[i].hidden;
                    if ( h ) objArray[i].hidden = false;
 
                    var g = objArray[i].createOutline(  );
 
                    // Return new group to previous Text Frame values
                    g.locked = l;
                    g.hidden = h;
 
          }

};


var myPermission =confirm ("Are you sure you're ready to save?","","Save Script Execution")
if (myPermission){
var myFileName = prompt ("Enter Filename","");
if (myFileName){
var destFolder = Folder.selectDialog('Select which folder to save to Katie:');
}
else
alert ("Save cancelled");
}
if (destFolder) { 

/*Save as Illustrator CS4*/
var IFile = new File(destFolder + '/' + myFileName);              
var ISave = new IllustratorSaveOptions();
    with (ISave){
        compatibility = Compatibility.ILLUSTRATOR14;
          
}
   /*Save as standard PDF*/
    var IPreset = '[Illustrator Default]'
    var pdfSave = new PDFSaveOptions();
    var pdfFile = new File(destFolder + '/' + myFileName);
        with (pdfSave){
             pDFPreset = IPreset;
             viewAfterSaving = false;
             compatibility = PDFCompatibility.ACROBAT5;
            
}

/*Save as smallest PDF*/
var SmallestPDF = '[Smallest File Size]';
var pdfSaveOpts = new PDFSaveOptions();  
var pdfFileCompressed = new File(destFolder + '/' + myFileName +'%2e' + now_format);
    with (pdfSaveOpts){
        compatibility = PDFCompatibility.ACROBAT5;   
        pDFPreset = SmallestPDF;
        viewAfterSaving = false;
}
destFolder.execute()
myDoc.saveAs (IFile, ISave)
myDoc.saveAs(pdfFile, pdfSave) 
myDoc.saveAs(pdfFileCompressed, pdfSaveOpts)

}


else {
alert("Save cancelled!")  

}


Collecting Fonts For Output

$
0
0

I've got this bit of code from user moluapple - he was incredibly helpful in getting me started, but isn't going to continue working on this and I was wondering if anyone else would be willing to help further this bit of code.

 

The code works to collect fonts in an open Illustrator document. The issue I am having is that it only collects one font. Or sometimes it will collect a whole font family. But I haven't been able to get it to collect all of the fonts in the document.

 

I was hoping someone could put their finger on what I'm doing wrong.

 

 

function getUsedFonts (doc){

     var xmlString = new XML(doc.XMPString),

     fontFamily = xmlString.descendants("stFnt:fontFamily"),

     fontFace = xmlString.descendants("stFnt:fontFace"),

     ln = fontFace.length(), i = 0, arr = [];

     for (; i<ln; i++){arr.push(fontFamily[i] + '\t' + fontFace[i])};

     return arr;

}

alert(getUsedFonts(activeDocument));

 

function main() {

          var

                    doc = app.activeDocument,

                    docPath = doc.path,

                    arr = getUsedFonts (doc),

                    oFolder = new Folder(docPath + '/DocumentFonts'),

                    btMsg,

                    PackageFonts = function (string, oFolder) {

                              var arr = string.split(','), oPath, oFile, oName, i;

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

                                        oPath = app.fonts.itemByName(arr[i]).location;

                                        oFile = File(oPath);

                                        oName = oFolder + '/' + arr[i].replace ('          ', ' ').replace(' Regular', '') +

                                                  oPath.substring(oPath.lastIndexOf('.'), oPath.length);

                                        oFile.copy(File(oName), true);

                              }

                    };

          oFolder.create();

          btMsg = new BridgeTalk();

          btMsg.target = "indesign";

          btMsg.body = PackageFonts.toSource() + '("' + arr +'", "' + oFolder + '")';

          btMsg.onResult = function (resultMsg) {

                    $.writeln("Result = " + resultMsg.body);

          }

          btMsg.onError = function (errorMsg) {

                    $.writeln("Error = " + errorMsg.body);

          }

          btMsg.send();

}

 

 

main();

Script to select patterns in Illustrator Document

$
0
0

Kindly we need a script that select all pattern objects in the active document in illustrator.

Viewing all 12845 articles
Browse latest View live