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

Anyone know of a script to convert layers to artboards.

$
0
0

I don't suppose any one could point me in the direction of a script which would convert the layers in a document to artboards? At present I have a lot of documents with a couple of hundred layers on each of them, but I've decided to change the way that I organise my workflow and started using artboards instead. I don't really have the time to spend moving them individually from a layer over on to an artboard as there are a lot.

 

Any help or information would be greatly appreciated.

 

Many Thanks,

 

K


Batching In Illustrator??

$
0
0

In PhotoShop CS3, you can select File/Automate/Batch, and run an Action on an entire folder.  I don't see that option in Illustrator CS3?  Is there a way to run an action on an entire folder?

 

I'm attempting to save many EPS images as PNG images, and would really like to retain "vector attributes" - is any of this possible???

 

Thanks for any help.

Calling functions from UI palette

$
0
0

Hello,

From what I understand, you can't call complex functions from a scripted UI palette, only from "dialog" windows (which are usless in my case) because I need the persistance of a palette.

 

I have a series of scripts in use now that are  accessed from the usual "file-scripts folder" within Illustrator itself (about 27 of them).  I want to script a palette window so users can acces them without the usual mouse clicks down the menu system.

 

I'm able to call a simple "Hello World" type function using the "onClick()" method from a button of a scripted palette window, but I cannot use my regular working scripts inside a function that's called from the button.  In X-Code, I was able to write my scripts individually, then just add them to a main floating window via a separate function when they were completed.  But, I'm finding Javascript a little more tricky.

 

If I copy my other's script code into the function in the palette window script, it runs, but it runs before I click the button! --  After in runs, then the palette window is displayed(?).  If I try to use the execute() method with "onClick", the script just opens in the SDK, it will not and does run in Illustrator.

 

I take both of these as clear indications that I have no clue what I'm doing (or that I'm trying to do the impossible).

 

I did find someone with a similar problem, but they were scripting After Effects and were offered this solution:

 

system.callSystem ('afterfx -r "/C/Program Files/Adobe/Adobe After Effects CS3/Support Files/Scripts/GlobalVars.jsx"');

 

 

Is there anything I can do in Illustrator that will allow me to call (or execute) my other scripts/functions and have them execute within Illustrator?

 

Thanks for any and all help!

Assigning Text Fields Variables via VBScript

$
0
0

I'm looking to complete the first challenge of my project of repopulating text fields with translated text automatically.  To do this I need to pull the text down from an Ai file.  However, each text field must be identifiable so that it can be recorded into an excel spreadsheet.  So the spreadsheet would essentially contain the following data:

 

Column 1

 

File Name + Text1(this being variable name)

 

Column 2

 

English text pulled from that variable text field

 

Column 3

 

Translated text

 

So I need to code a script to batch through a folder of Ai files and assign each text field in the drawing a unique identifier or variable, i.e. "Text1", "Text2", etc...

 

I know that I can convert a text field to dynamic flash text which allows me to manually name a field, however doing this through script is less obvious to me, any help would be apreciated!

 

Furthermore, if there is already a unique identifier on textfields by default that I can tap into, that would be nice as well.  Otherwise I'd like to write a script that in the beignning of the code it steps through the number of fields and assigns each a unique identifier, copies that identifier to a spreadsheet, then next to that, copies in the text from the field into the spreadsheet as well.

 

Thanks,

-Chris

Illustrator Find And Replace

$
0
0

Hi there,

 

Can anybody tell me if it's possible to JavaScript Illustrators Find And Replace text function?

 

I know it's possible in InDesign but I can't find anything for Illustrator.

 

Many Thanks,

Nik

Scripting - Add Swatches

$
0
0

Hi! Hoping someone can help!

 

Is there a way to open a file and then start a action/script that will take all spot colors from the file and create small square patches in the file.  These square patches would be filled with the color of the swatches.  For example, if my file had 3 spot colors in it I would end up with 3 squares in my file each one of the spot colors used?

I'm currently doing this manually and hoping to automate some...


Thx!

Select an object in illustrator using extendscript

$
0
0

I have a drawn rectangle on an illustrator document. In the layers menu I have given it a specific path name (outerBox). I would like to select this item and return its particular properties eg height, width, colour etc. How would I do this.

 

Thanks

Bob

Is there any equivalent of Art Dictionary in extendscript?

$
0
0

Hi guys,

 

I am in process of converting c++ plugin code into html extension. I have came across below code snippet. I am not sure whether there is any equivalent of Art Dictionary in extend script. If there is any please point me there.

 

I have skimmed documents named "Illustrator Scripting Reference - JavaScript_CC2015", "JavaScript-Tools-Guide.pdf", "CEP_6.1_HTML_Extension_Cookbook.pdf" found on github/devnet etc.

 

Thanks in advance,

Dnyanesh


How to embed multiple images

$
0
0

Hello!

 

I have been tying to figure out how I could easily embed multiple linked images easily. I have some 1000 .svg  images which have about 1-7 .tif images linked in to them. I now need to get those links embedded and becouse of the amount of images I'm hoping to make an action out of it. I have a script to embed single image in .svg but haven't have luck with multiple embeddings.

 

Any ideas?

Spot colour and rasterize/export javascript

$
0
0

Need help with a couple of scripts

 

I've found scripts that can scrawl over the entire document and convert and spot colours to process colours but I need to convert any spots to RGB not process CMYK. Can this be done?

 

Also need another script to rasterize to document at 600dpi then export as a PSD (RGB, 600dpi, use artboards, art optimized) to a folder on my desktop called 'EXPORT'

Again found similar scripts on the forum but unable to make them work for me

Save multiple artboards to individual PDFs... All artboards still exist in AI

$
0
0

I'm rewriting some export scripts of mine and I've just come across something strange...

 

Part of my multi-export script saves a PDF for each artboard. The code looks something like this:

 

  for ( var i = starting_artboard; i < num_artboards; i++ ) {    starting_artboard = doc.artboards.setActiveArtboardIndex(i);    var saveOptions = new PDFSaveOptions();    saveOptions.compatibility = PDFCompatibility.ACROBAT6;    saveOptions.generateThumbnails = true;    saveOptions.preserveEditability = true;    saveOptions.artboardRange = i+1;    doc.saveAs( dest, saveOptions );  }

 

Now, this works perfectly, and I get a PDF for each artboard... until I open one of those PDFs back up in Illustrator and all the artboards are still there. So each PDF has all the artboards (not just the content of the artboards, but the actual artboards, still named and placed as they were). Weirdly the artboards don't exist *anywhere* else. They don't exist if I open the PDFs in Acrobat, Photoshop, any random PDF viewer, anywhere; only in Illustrator.

 

Any idea why and how I can fix this? I'm hoping I'm missing something obvious and I don't have to copy the artboard to a new temp doc and save that, but I can't find anything in PDFSaveOptions that should be causing this.

Script that worked now giving a 1302 error

$
0
0

I am getting an error with a script i have used before without any problems.

 

The script updates the only image at the bottom of a single page PDF and saves the changed PDF in another folder.

 

It asks me to locate the folder of PDFs to be modified.
It asks me to locate the folder where the modified PDFs will be saved.
It asks me to select the new image that will be used.
It will then update the image and resizes it and save the PDF in the specified folder.

 

I don't get this error on all PDFs but i get it at least once every 10 PDFs  (and there are over a 1,000 PDFs).


The error i get is this:

 

Error 1302:No such element
Line:27
->      rip=
doc.rasterItems[0].position;

 

I get this error regardless of whether the script is run in CS3 or CS5.


Additional info.
I ran this script in CS3 and it worked. At a later date i ran another script on the folder of modified PDFs in CS5 that deleted any

unnessesary elements outside the artboard, it selected All on the Artboard - then inversed the selection - and deleted any selected items

followed by save and close.
I have tried making sure the "new" image has the same name as the image being replaced but this made no difference.

I am using Illustrator on Vista.

 

The script is below:

 

#target illustrator

 

function replaceImage() {

 

          var i, doc, fileList, inFolder, outFolder, opts, pic, rep, rip, saveFile, uIL;

 

          inFolder = Folder.selectDialog( 'Please choose your Folder of AI PDFs…' );

 

          outFolder = Folder.selectDialog( 'Please choose a Folder to save AI PDFs in…' );

 

          pic = File.openDialog( 'Please choose your replacement Image…' );

 

          if ( inFolder != null && outFolder  != null && pic != null ) {

 

                    fileList = inFolder.getFiles( /\.pdf$/i );

 

                    if ( fileList.length > 0 ) {

 

                              uIL = app.userInteractionLevel;

 

                              app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

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

 

                                        doc = app.open( fileList[i] );

 

                                        rip = doc.rasterItems[0].position;

 

                                        rep = doc.placedItems.add();

 

                                        rep.file = pic;

 

                                        rep.move( doc.rasterItems[0], ElementPlacement.PLACEBEFORE )

 

                                        rep.position = rip;

 

                                        rep.resize( 31.414, 31.414, true, true, true, true, 100, Transformation.TOPLEFT );

 

                                        doc.rasterItems[0].remove();

 

                                        rep.embed();

 

                                        opts = new PDFSaveOptions();

 

                                        opts.pDFPreset = '[Illustrator Default]';

 

                                        saveFile = File( outFolder + '/' + doc.name );

 

                                        doc.saveAs( saveFile, opts );

 

                                        doc.close( SaveOptions.DONOTSAVECHANGES );

 

                              };

 

                              app.userInteractionLevel = uIL;

 

                    } else {

 

                              alert( 'This Folder contained NO Illustrator PDF files?' );

 

                    };

 

          };

 

};

 

replaceImage();

Saving documents via Scripts: Get current file name and set save path/file type

$
0
0

I am writing a script that will:

 

-Make all layers invisible

-Make a layer named "background" visible

-Delete all the invisible layers

-Save the docment as an EPS file (leaving the original document untouched)

 

I am new to scripts and so have based my script by copying code from other scripts.

 

Here is my code:

 

var doc = app.activeDocument;

var name = doc.name;

 

 

var hide = function (){ // hide all layers (based on http://forums.adobe.com/thread/644267)

     var L=doc.layers.length;

     for (j=0;j<L;j++){  doc.layers[j].visible=false; }

}

hide();

 

 

// loop through all layers

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

 

 

 

 

 

              // Create the illusrtratorSaveOptions object to set the AI options

    var saveOpts = new IllustratorSaveOptions();

 

    // Setting IllustratorSaveOptions properties.

    saveOpts.embedLinkedFiles = true;

    saveOpts.fontSubsetThreshold = 0.0

    saveOpts.pdfCompatible = true

 

 

 

 

 

 

//Set up Variable to access layer name

          var currentLayer = app.activeDocument.layers[i];

 

// Loop through the layers and make the back ground layer visible

          if (currentLayer.name == "Background") {

                    docName = name + currentLayer.name+".eps";

                    currentLayer.visible = true;

                    }

 

 

}

 

 

// Delete Invisible Layers (based on http://www.cartotalk.com/index.php?showtopic=7491)

var myDoc=app.activeDocument;

var layerCount=myDoc.layers.length;

for (var ii = layerCount - 1; ii >= 0; ii--) {

    var currentLayer = myDoc.layers[ii];

    currentLayer.locked = false;

    var subCount = currentLayer.layers.length;

    for (var ss =subCount -1; ss >= 0; ss--){

        var subLayer = currentLayer.layers[ss];

        subLayer.locked = false;

        if (subLayer.visible == false){

            subLayer.visible = true;

            subLayer.remove();

            }

        }

    if (currentLayer.visible == false){

        currentLayer.visible = true;

        currentLayer.remove();

        }

    }

 

// Save Out Document with New Name

 

var saveName = new File ( doc.path + "/" + docName );

doc.saveAs( saveName, saveOpts );

 

 

 

Everything works fine except:

1) It saves the document with the name AdobeIllustratorBackground as opposed to the name of the document

 

Also, I am not sure how to tell the script to save as EPS and to specify the save location.

 

Could some one give me some pointers?          Thanks!

Can javascript execute pathfinder commands?

$
0
0

Can javascript execute menu commands such as pathfinder options?

Group existing objects using Scripting API ?

$
0
0

Am I missing something, or is there no way to group existing objects using the scripting api ? You can add() to  GroupItems but that doesn't help you with existing objects.


text overflow + postFix

$
0
0

Hi,

 

Is there a way to select textframes containing text that overflows and to resize the frame to stop the overflow?

 

What is the use of the postFix parameter in the areaText and pathText method ?

 

Regards,

Lionel Barth

Event Listener equivalent in Illustrator

$
0
0

Hi everyone,

First of all thank you for all your support with my script so far, the information offered has been invaluable. I’m at the final hurdle but have hit quite a large problem.

 

Put simply my script is done, I want to put it in Illustrator Startup Scripts and do nothing. That is, until the user tries to save the document - then I need the script to run and do its thing before the save box opens.

 

InDesign has a ‘beforeExport’ event listener which achieves this.

 

Does anyone know an equivalent in Illustrator, or even a solution involving a plugin or workaround?

 

Thank you

How to get objects/images straightly which were rotated?

$
0
0

Hi Guys,

 

I am looking for a script which makes all the selected rotate objects/images should comes straight (without any rotate). I do have one script similar one. But that works only for rotated text frames. With that I can get the rotated text frame straight.

 

So same like this I am looking for all the object and images also.

 

If you guys have any idea to get that, please share with me.

 

Thanks in advance.

 

Here I am sending you that script which works for rotated text frames.

 

__________________________________________________________________________________________ ___________________________

 

 

var docRef=app.activeDocument;
if(docRef.selection.length>0){
    for(i=0;i<docRef.selection.length;i++){
        var objRef=docRef.selection[i];
        if(objRef.typename=="TextFrame"){
               
       
            var A=objRef.matrix.mValueA;
            var B=objRef.matrix.mValueB;
            var C=objRef.matrix.mValueC;
            var D=objRef.matrix.mValueD;
            if(B+C!=0){
                var currScale=(D/A)*100;
                alert(currScale);
                    objRef.width*=(D/A);
                //}while(B+C!=0);
            }

 

            do{
                var currSin=objRef.matrix.mValueC;
                var currDeg=Math.asin(currSin)*(180/Math.PI);
                objRef.rotate(currDeg,1,1,1,1,Transformation.CENTER);
            }while(objRef.matrix.mValueC!=0);
        }//end if
    }//end for
    redraw();
    alert("Now select Object > Transform > Reset Bounding Box to unrotate the textFrame bounding boxes.");
}//end if

 

__________________________________________________________________________________________ ___________________________

 

 

Regards

HARI

Illustrator Find And Replace

$
0
0

Hi there,

 

Can anybody tell me if it's possible to JavaScript Illustrators Find And Replace text function?

 

I know it's possible in InDesign but I can't find anything for Illustrator.

 

Many Thanks,

Nik

Illustrator CC Book Color vs Spot Color PANTONE+

$
0
0

Hi! Here's a question about a little detail regarding PANTONE+ spot colors.
I've got a script that makes PANTONE+ colors inside a document using the available scripting methods, which produce a spot color with the desired Lab color values, but when double-clicking and bringing up the swatch dialog it does not default to the grayed-out "Book Color" option in the Color Mode dropdown.

However, it does have the Book Color option in that dropdown and if it's selected and applied, the next time this swatch is double-clicked and dialog appears, the proper Book Color mode is selected and appropriate fields are grayed out.

 

My question is: considering the functions of spot colors in Illustrator, ink plating and appearance and anything else, does my script-made swatch bear any effect on the document that would make it in any way different than a regular document where the Book Color is shown as default in the swatch options dialog?

 

In Mordy Golding's explanation of Book Color mode for Pre-CS6 versions, he states that Book Colors came with hidden information which displays PANTONE-listed Lab values which relate to the Pre-CS6 CMYK-based PANTONE swatches. Now that we have PANTONE+, and Lab is the default base for the book swatches, I wonder if there is any other property that may not be considered by some function of the application if the swatch has the correct name and Lab values while not having the Book Color mode explicitly selected.

Also, if there's an undocumented property for setting the other Color Modes which can appear in this dropdown, that would also be useful information. Our current available options for SpotColorKind are just SPOTCMYK, SPOTLAB and SPOTRGB
Screen Shot 2015-10-04 at 6.57.46 PM.png

Lab-VS-Book.png

Viewing all 12845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>