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

Illustrator Macros/Scripting

$
0
0
Hey guys is it possible to create macros in illustrator, or how would this be achieved via the scripting.

Basically i have a c# application that contains alot of pictureboxes all with images in them. i want to be able to right click an image and select vectorise. Which will send the image to illustrator live trace the image, resize it, then copy the resulting image back into my c# app.

How would this be best done

thanks
r

How to automate the flatten transparency in illustrator?

$
0
0

How to automate the "Flatten Transparency option" in illustrator via javascript. Please share with me.

 

Thanks

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.

Script execute Action?

$
0
0
How in gods name do you execute a Action with a script?

I found this is sometimes easier than trying to script my copy paste crazyness. The illustrator script docs say, oh you can call a action, but they don't say how! I am going crazy...

Batch replace color without using swatch as source

$
0
0

I've searched these forums and the rest of the web trying to find a method to do this... Actions don't cut it (if Actions were able to record the "replace color" dialoge it would be fine) so I've turned to scripts, but I have almost no knowlege on this.

 

I checked out this thread:

http://forums.adobe.com/message/2588737

 

and it is very close, except that it assumes that there is a named swatch as the source color - which there isn't.

 

The script I tried was .JS

 

I'm trying to have the script run on a bunch of .eps files in a folder:

- Select object which has specified CMYK value (0,7,34,10)

- Replace fill color of the selected object with another CMYK value (5,19,36,0)

- Save over the existing .eps

- Close

- Make coffee (optional)

 

Also, any books you can recommend for learning this stuff? For a noob.

Dimension Illustrator CS6

$
0
0

Does anyone know of a script that will automatically put dimensions on rectangular shapes in Illustrator CS6?

Change font in Illustrator cs4 js

$
0
0

I need to assign specific font to my text and it doesn't work. What am I doing wrong:

 

 

var my_OUTSIDE_TextFrame = myInstrLayer.textFrames.add();
my_OUTSIDE_TextFrame.geometricBounds = ["1.6 in", "1 in", "1.85 in", "2.75 in"];
my_OUTSIDE_TextFrame.contents = "OUTSIDE";

var myParagraph = my_OUTSIDE_TextFrame.paragraphs.item(0);
try{
myParagraph.appliedFont = app.fonts.item("Myriad Pro");

}
catch(e){}
try{
myParagraph.fontStyle = "Bold";
}
catch(e){}

myParagraph.pointSize = 30;

 

And it's not placing it where I want it either.

 

Thank you very much for your help.

Yulia

Extracting data from Excel To Illustrator javascript or vbscript

$
0
0

Hi all-

I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that.  What I would like to do is pretty much the opposite:

 

1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.

2. Run script(VBSCRIPT,Javascript, doesn't matter)

3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.

4, Save each to a PDF file and name file with text from Excel Column1(Filename)

 

In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI. I hoped I explained this well enough without causing too much confusion. Thanks in advance.

 

FilenameReplacement Text

test1.pdf

DWG01
test2.pdfDWG02
test3.pdfDWG03
test4.pdfDWG04

AI_Ex..PNGAI_Ex2.PNG


Batch combine files into one illustrator document - how to open target document?

$
0
0

I am making a script which will:

 

1) Open a folder of Illustrator files

2) Open each file in the folder (these files are called the source files)

3) Select all the contents of the source file

4) Copy the contents of the source file

5) Paste these contents into a target file as a new layer

6) Ensure the new layer has the same name as the old source file

 

 

However, I don't know how to tell Illustrator where my target file is. How can I do this?

 

Also, when I paste, how can I turn off paste rembers layers. (So the layers get pasted into the new layer that has the same name as the old document).

 

Here is my code:

 

 

// JavaScript Document

 

 

//Set up vairaibles

var destDoc, sourceDoc, sourceFolder;

 

 

// Select the source folder.

sourceFolder = Folder.selectDialog('Select the folder with Illustrator files that you want to mere into one', '~');

 

 

// If a valid folder is selected

if (sourceFolder != null) {

          files = new Array();

 

 

          // Get all files matching the pattern

          files = sourceFolder.getFiles();

 

 

          if (files.length > 0) {

                    // Get the destination to save the files

                    destDoc = document.selectDialog('Select the final saved document', '~');

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

                              sourceDoc = app.open(files[i]); // returns the document object

 

                              var myLayers = sourceDoc.layers; // All layers in Active Document

 

 

                              //Go through all layers of source document and copy artwork

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

                                        myLayers[i].hasSelectedArtwork = true;

                              };

 

 

                              with(sourceDoc) {

                                        var count = pageItems.length;

                                        for (var i = 0; i < count; i++) {

                                                  pageItems[i].selected = true;

                                        }

                                        redraw();

                                        copy();

                                        for (var i = 0; i < count; i++) {

                                                  pageItems[i].selected = false;

                                        }

 

 

                              }

 

 

                              //Create a new title variable that has the title of the source document

                              var title = sourceDoc.name;

                              var title = title.substring(0, title.length - 4); //(remove extension from name)

                              //Close the Source Document

                              sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

 

 

 

 

                              //Open the Destination Document and create a new layer in it that is named after the title variation

                              var newLayer = destDoc.layers.add();

                              newLayer.name = title;

 

 

                              //Paste into this new layer

                              destDoc = app.paste();

 

 

                    }

          }

          else {

                    alert('No matching files found');

          }

 

}

 

Thanks in advance for any help   

 

Edit: Also, when pasting, how can I paste in place instead of just pasting.

1346458189 ('MARP') Error: Unlocking layers

$
0
0

Hi all,

 

I have a script that is used to tidy up a file before it is sent out. As a part of this i need to be able to unlock layers and make them visible, i have used this sample script that I have below without problems in the past but i am suddenly getting these errors, could someone please explain why?

 

function UnlockLayers(){

   

    // Loop through the docs layers and capture the locked states of each one.
                for ( var i = 0 ; i < app.activeDocument.layers.length; i++ ) {
                        // Unlock/Unhide layers here
                        app.activeDocument.layers[i].locked = false;
                        app.activeDocument.layers[i].visible = true;

                       

                }
}


Thanks to anyone that has any suggestions,

Tom

Extracting unique identifier for illustrator layers

$
0
0

Hi All,

 

Multiple layers in an illustrator file can have the same name. So the layer name cannot be a unique identifier for layers. Is there a way to extract a unique identifier for layers through scripting? I saw that if the 'Identify Objects by' property (inside Preferences -> Units) is set to XML ID, all layer names, even identical ones are replaced by some unique ids. Can we extract these ids via scripting without manually changing the 'Identify Objects by' property. Basically, extraction of any unique identifier for illustrator layers would serve the purpose. I am really stuck with this and need help urgently. Any help would be highly appreciated.

 

Thanks in advance.

Script: rename layers?

$
0
0

Hi, is there a quick way how to renumber or batch rename all layers in a file so they would be named in consequent numbers? Doesn't have to start from exact number, I was wondering if maybe there is some sort of script that would help me with that? Thanks Pavel

How to bring palette (progress bar) to the front?

$
0
0

Hi all,

 

I am having a problem where my progress bar for my script will not display correctly, i believe this is because it is not the focused window.

I was wondering if there is anything in illustrator scripting similar to the window.focus method in javerscript? Or any other way of achieving this.

 

The progress bar will work fine in CS6 even though it is not the focus, but i need the script to be able to run on both 5 and 6.

 

The progress bar code is as follows:

 

    var win = new Window("palette", "Progress bar", [150, 150, 600, 260]);  

    win.pnl = win.add("panel", [10, 10, 440, 100], "Script Progress"); 

    win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], 0, 100); 

    win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], "Collecting images... 0%"); 

    var task = "collecting images..."

    win.show(); 

    win.pnl.progBar.show();

 

                    while(win.pnl.progBar.value < win.pnl.progBar.maxvalue) 

                    {  win.update();

                              win.pnl.progBar.show();

                              if (win.pnl.progBar.value == 0){

                                  imageCollection();

                                  task =  "Saving AI file...";}

                              if (win.pnl.progBar.value == 20){

                                  SaveAI();

                                  task = "Outlining text...";}

                              if (win.pnl.progBar.value == 40){

                                  OutlineText (app.activeDocument.layers);

                                  task = "Saving Outlined File...";}

                              if (win.pnl.progBar.value == 60){

                                  SaveAIOutlined();

                                  task = "Saving PDF...";}

                              if (win.pnl.progBar.value == 80){

                                  SavePDF();}

                             

                             

                              win.pnl.progBar.value = win.pnl.progBar.value + 20;  

          win.pnl.progBarLabel.text = task + win.pnl.progBar.value+"%"; 

                    } 

                task = "Script Complete. "

    win.pnl.progBarLabel.text = task + win.pnl.progBar.value+"%"

  win.update();

  app.activeDocument.close();

    alert("Script Complete");  

 

win.close();


Im using Mac OS 10.6.8, any help at all would be appreciated.

 

Regards,

Tom

Document preset & New document - Illustrator - Applescript

$
0
0

Hi !

Here is the problem i would like to resolve with appelscript.
I want to make a new file with units (millimeters)

I know i need to make a preset before making a new document ; but i don't know how to do !

 

Here is a part of the code i tried to do :

 

tellapplication "Adobe Illustrator"

 

activate

setdocument unitsofdocument presettomillimeters

makenewdocumentwith properties {width:297, height:210}

endtell

 

Thanks for your help !

Sorting Layers

$
0
0

I have a map of the US that is broken down into counties.  Each state has its own layer and the counties are sublayers.  I am currently going through and naming all of the counties, but I need to be able to alphabetize them.  Is there a way to do this?

 

Thanks


Change Folder.current to location of script (.jsx) file?

$
0
0

All,

 

I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.

For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:

 

var w = new Window ("dialog");
var f = new File ('~/Desktop/transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();

 

However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:

 

var w = new Window ("dialog");
var f = new File ('../../../transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();

 

But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.

I say that because when I do this:

 

alert(Folder.current);

 

The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.

 

So, is there a way of setting Folder.current to the location of the actual script?

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.

How do I make a custom shape using Javascript?

$
0
0

I would like to create a trapezoid shape and be able to color it in, just like I'm able to do with the PathItems (e.g. rectangle, ellipse). I would like to be able to do this in Javascript.

 

I was thinking it might have to do with PathPoints, but Adobe's Scripting Reference Guide does not make it clear.

 

If anyone could give me some quick sample code on how to do this, I'd be much appreciative. Or just a description would be great.

 

THANK YOU VERY MUCH

Create a guideline

$
0
0

Is there a way to make a guideline with script that is the same as the ones you drag off the ruler?

 

The ones you drag from the ruler are the width or height of the whole pasteboard and can never be dragged away from the edges of the pasteboard.

If you create a line and turn it into a guide, it will not behave the same..

Avoiding "PDF Modification Detected" blocking dialog

$
0
0

Hello,

 

I am working on an Illustrator script opens an AI or PDF file, extracts some information, then converts it to a JPEG.  It is designed to run unattended in batch mode, and sometimes is used to process PDF files which were not created by us, but were submitted from the Internet.  The script is working properly for most documents.

 

However, we sometimes end up with PDF files that cause this warning dialog to pop up:

 

PDF Modification Detected
This document has been modified outside of Adobe Illustrator.
How do you want to proceed?

[ ] Discard changes, preserving Illustrator editing capabilities
[ ] Keep changes, reducing Illustrator editing capabilities

Cancel; OK

 

The dialog is blocking, and so prevents our unattended script from running until a user walks to the console and presses "OK" or "Cancel".

 

The script is in JavaScript, and contains this line, which I thought would prevent this sort of dialog from coming up:

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

Does anybody have suggestions for avoiding this dialog?  I would prefer for it to just select "OK" automatically, but even failing would be much better than blocking.

 

Alternatively, any suggestions for detecting documents that are likely to trigger this warning beforehand?

 

Thanks!

 

-----Scott.

Viewing all 12845 articles
Browse latest View live


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