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

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.


sendScriptMessage

$
0
0

Hey yall, 

In the CS6 reference it states:

 

Scripting plug-ins

The CS6 JavaScript scripting interface allows for limited scripting for plug-ins. A plug-in can define a command, with an event and notifier, and a handler that performs some action. A JavaScript script can then use the app.sendScriptMessage() method to send parameters to that plug-in-defined command, and receive a plug-in-defined response.

For example, the Adobe Custom Workspace plug-in defines a command "Switch Workspace". A script can invoke this command with the following code:

result = app.sendScriptMessage("Adobe Custom Workspace" , "Switch Workspace", '<workspace="Essentials" >');

In this case, the value that the plug-in returns is the string "<error=errNo>".

 

 

 

Does anybody know where or how I can find out the native plug-in commands and what parameters they accept?

 

Thank you for any ideas!

AppleScript moving certain colours to new layers

$
0
0

Hi all. This is my first question here. I'm attempting to use AppleScript to organize the layers of my art files.

 

What I am looking to do is have all objects with a fill color that is a specific CMYK value moved to a new layer. I don't know enough about how AppleScript and Illustrator's scripting interface works to make this function.

 

In my mind, I want to write something like this:

select all objects with fill color CMYK:100,80,0,0

move selection to Layer 2

 

AppleScripts always seem to be far more complicated than I initially envision them. Any thoughts on how this might actually be written?

 

Thanks so much.

David

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.

CS6 placedItems relink method, sometimes producing Error: 376('x ')

$
0
0

Hi,

 

I am creating a script on illustrator CS6 that will loop through all the images and relink these images to there current location, it is used to update all of the links in the file. However sometimes when i run this script i will get the error 376('x ') i have searched for the meaning of this and cannot find it anywhere. It is being written in extendscript, the code i am using is shown below:

 

// execute the main function

main();

 

// Construct the main function

function main() {

 

        var retVal = "OK";

       

        // Check the app is CS6 or above

        if ( parseFloat ( app.version ) < 16 ) {

 

                alert("You must run this script in CS6 or above.");

                return "Script must be run in CS6 or above.";

        }

 

        //check for open document

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

 

           

 

                  //show error when nothing is open.

                alert("Please have at least one document open");

                retVal = "Error";

        }

   

        //check for images within document 

        if (app.activeDocument.placedItems.length == 0) {

           

                //show error when there is no images

                 alert("No images in document");

                 retVal = "Error";

        }

   

        else {

 

                //active document variable

                var ActiveFile = app.activeDocument;

               

                // Declare array for the documents original layer states.

                var originalLockedLayerStates = [];

           

                // Declare array for the documents original layer states.

                var originalVisibleLayerStates = [];

 

 

                // Loop through the docs layers and capture the locked states of each one.

                for ( var j = 0 ; j < ActiveFile.layers.length; j++ ) {

 

                        // Capture statues here

                        originalLockedLayerStates.push ( ActiveFile.layers[j].locked);

                        originalVisibleLayerStates.push ( ActiveFile.layers[j].visible);

                       

                        // Unlock/Unhide layers here

                        ActiveFile.layers[j].locked = false;

                        ActiveFile.layers[j].visible = true;

                       

                }

               

                // Create array variable for all placed images

                var placedFiles = [];

               

               

               

                // for every image in the active doc....

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

 

                        // try and...

                        try {

                                // add the full image path to the array

                                placedFiles.push(ActiveFile.placedItems[i].file.fullName);

 

                                // then update the link in the active doc.

                                ActiveFile.placedItems[i].relink (ActiveFile.placedItems[i].file);

                        }

                       

                        // If the relink fails catch it here

                        catch (e) {

                                // push the object name of the link that wouldn't update into this array.

                                retVal = "Error";

                        }

                }

 

                // If this array is empty, then nothing went wrong and....

                if ( retVal == "Error" ) {

                       

                        // alert the user showing them the name of the problem link.

                        alert("Some image(s) could not be updated");

 

                }

 

                // otherwise there were issues and...

                else if ( retVal == "OK" ){

                       

                        // alert a success message

                        alert("Successfully updated " + placedFiles.length + " link(s)");       

                       

                }

       

        // Once the links have been updated, set the layers states back to how they were

        for ( var k = 0 ; k < ActiveFile.layers.length; k++ ) {

 

                // Put layer back to it's original state.

                ActiveFile.layers[k].locked = originalLockedLayerStates[k];

                ActiveFile.layers[k].visible = originalVisibleLayerStates[k];

 

        }

       

        // Once all the links have been updated, refresh the page.

        app.redraw()

       

        }

   

    return retVal;

}

 

if anyone has any suggestions as to why this may be happening i would be very greatfull.

 

Thanks,

Tom

Recreate gradient thru script

$
0
0

I'm trying to recreate a gradien thru script... but i can't seem to use the following functions:

 

GradientColor ---> hiliteAngle, hiliteLength, length, matrix and origin.

 

Please help!

 

I've enclosed some jpg and the script sofar:

 

var omf = 2.834645;
var x=0;
var y=0;
var verschuivingx = 0;
var verschuivingy = 0;

 

var size= 0;

 

docPreset = new DocumentPreset;
docPreset.width = 100*omf;
docPreset.colorMode = DocumentColorSpace.CMYK
docPreset.previewMode = DocumentPreviewMode.OverprintPreview;
docPreset.rasterResolution = DocumentRasterResolution.HighResolution;
docPreset.title = "testgradientfile";
docPreset.rulerUnits = RulerUnits.Millimeters;
docPreset.height = (100*omf);
docPreset.name = "testgradientfile";
var doc = app.documents.addDocument(DocumentColorSpace.CMYK,docPreset);
app.activeDocument.layers[0].name = "testgradientfile";

 

var line = doc.pathItems.add();
line.setEntirePath(Array(Array(((x+185.561154924162+verschuivingx)*omf),((y+141.7774260533 51+size - verschuivingy)*omf)),Array(((x+79.7277966023964+verschuivingx)*omf),((y+141.777426053351+ size - verschuivingy)*omf)),Array(((x+79.7277966023964+verschuivingx)*omf),((y+247.610784375116+ size - verschuivingy)*omf)),Array(((x+185.561154924162+verschuivingx)*omf),((y+247.610784375116+ size - verschuivingy)*omf))));
line.pathPoints[0].leftDirection = Array(((x+185.561154924162+verschuivingx)*omf),((y+141.777426053351-verschuivingy)*omf));
line.pathPoints[0].rightDirection = Array(((x+185.561154924162+verschuivingx)*omf),((y+141.777426053351-verschuivingy)*omf));
line.pathPoints[1].leftDirection = Array(((x+79.7277966023964+verschuivingx)*omf),((y+141.777426053351-verschuivingy)*omf));
line.pathPoints[1].rightDirection = Array(((x+79.7277966023964+verschuivingx)*omf),((y+141.777426053351-verschuivingy)*omf));
line.pathPoints[2].leftDirection = Array(((x+79.7277966023964+verschuivingx)*omf),((y+247.610784375116-verschuivingy)*omf));
line.pathPoints[2].rightDirection = Array(((x+79.7277966023964+verschuivingx)*omf),((y+247.610784375116-verschuivingy)*omf));
line.pathPoints[3].leftDirection = Array(((x+185.561154924162+verschuivingx)*omf),((y+247.610784375116-verschuivingy)*omf));
line.pathPoints[3].rightDirection = Array(((x+185.561154924162+verschuivingx)*omf),((y+247.610784375116-verschuivingy)*omf));
line.closed = true;
line.stroked= false;
line.filled= true;
var newGradient = app.activeDocument.gradients.add();
newGradient.name = "NewGradient0";
newGradient.type=GradientType.RADIAL;
var itemColor1 = new CMYKColor();
itemColor1.cyan = 100;
itemColor1.magenta = 0;
itemColor1.yellow = 100;
itemColor1.black = 49;
newGradient.gradientStops[1].color = itemColor1;
newGradient.gradientStops[1].rampPoint=100;
newGradient.gradientStops[1].midPoint=50;
var itemColor0 = new CMYKColor();
itemColor0.cyan = 47;
itemColor0.magenta = 0;
itemColor0.yellow = 100;
itemColor0.black = 0;
newGradient.gradientStops[0].color = itemColor0;
newGradient.gradientStops[0].rampPoint=0;
newGradient.gradientStops[0].midPoint=50;
var colorOfGradient = new GradientColor();
colorOfGradient.gradient = newGradient;
line.fillColor = colorOfGradient;
line.fillOverprint = false;
line.rotate(0,false,false,true,false);
var grdntstop = doc.gradients.getByName("NewGradient0").gradientStops.add();
var itemColor1 = new CMYKColor();
itemColor1.cyan = 86;
itemColor1.magenta = 0;
itemColor1.yellow = 100;
itemColor1.black = 19;
grdntstop.color = itemColor1;
grdntstop.rampPoint=74;
grdntstop.midPoint=50;

 

var illustratorversion = app.version;
var illustratorversionarray = illustratorversion.split(".");
if(illustratorversionarray[0]>13){
    app.activeDocument.artboards[0].artboardRect = app.activeDocument.visibleBounds;
}
zet_nulpunt();
zoomcenterpage()

 

function zoomcenterpage(){
    var myView=app.activeDocument.views[0];
    myView.centerPoint = [(app.activeDocument.width/2),(app.activeDocument.height/2)];
    myView.zoom = 1
    myView.screenMode.FULLSCREEN;
}

 

function zet_nulpunt(){
    // zet nulpunt linksonder
    app.activeDocument.pageOrigin = Array(0,0);
    app.activeDocument.rulerOrigin = Array(0,0);
}

 

Want to create:

Want to create.png

Script creates:

Script creates.png

Cheers Daniel

JPEG Export options in Javascript

$
0
0

Cutting a circle

$
0
0

Hi all,

 

I need to make shapes like this based on a value for graph purposes - usually I would just create a cutting shape based on trig (this shape representing around 60%) and subtract it from the path - I have about 30 graphs to do and I need to base it on a variable, and I want to use script - I'm sure there must be a better way, and I'm hoping you guys have the answer.

 

Thanks in advance

 

Dave

cut.png


How can I place image into an .ai file using java?

$
0
0

I am working on my school's Yearbook project. For last few years we have done it all using python to generate png files for all the pages but now that I have discovered adobe's scripting, I wanted to make it properly and generate vector files.

My problem is that I can not place images in file and references are... not that clear.

 

I would be very happy if anyone from community could help me out either through illustrator scripting or any other way.

 

Thank you in advance.

Split Text into Layers

$
0
0

I was wondering if anyone is aware of a script that is able to do the same as this photoshop one http://www.agasyanc.ru/text-splitter, I would use that one in photoshop but its not working in CS6.

 

I  was hoping to find a script that will seperate the text into layers  ready for export to After Effects to be used in Kinetic Typography  pieces

 

thank you

Remove Horizontal Scale on circular characters only

$
0
0

Lino's CrTronic used to have a command to set horizontal scaling to 100% for these 3 characters, and leave the rest alone.

® circle R

© circle C

• bullet

 

Because those 3 characters are circles we often want them proportional even if the rest of the copy is horizontally scaled.

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.

Importing Color to Swatch Library from Text File

$
0
0

Hi,

I have a large list of custom colors in Excel that has the color name and CMYK breakdown of each color. I'm looking for a way to import this information to create a custom Color Swatch Library. That will have the name of the color and the CMYK breakdown. So that I can easily use in Illustrator and Photoshop. Is there any way or application in doing this with out manually entering the information and creating a new library?

 

Thanks!

Batch export .ai files to pdf

$
0
0

Hi guys, I found a script that does the job, export tones of ai files to pdf, but I have some files which are in sub folders, and I was trying to find a way to modify this script to include subfolder, but no luck.

 

Would appriciate if anyone colud help.

 

Thanks.

 

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

 

 

ADOBE SYSTEMS INCORPORATED

Copyright 2005-2006 Adobe Systems Incorporated

All Rights Reserved

 

 

NOTICE:  Adobe permits you to use, modify, and

distribute this file in accordance with the terms

of the Adobe license agreement accompanying it. 

If you have received this file from a source

other than Adobe, then your use, modification,

or distribution of it requires the prior

written permission of Adobe.

 

 

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

 

 

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

 

 

Export to PDFs.jsx

 

 

DESCRIPTION

 

 

This sample gets files specified by the user from the

selected folder and batch processes them and saves them

as PDFs.

 

 

Edits by Patrick Mineault:

- only .ai files processed

- files saved in same folder as the input files

- export files have name (oldname).pdf

- PDF settings: editable / acrobatLayers=true

      for maximum compatibility with Preview

 

 

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

 

 

// Main Code [Execution of script begins here]

 

 

// uncomment to suppress Illustrator warning dialogs

// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

 

var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts;

 

 

// Select the source folder.

sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator .ai files you want to convert to PDF');

 

 

// If a valid folder is selected

if ( sourceFolder != null )

{

    files = new Array();

    fileType = "*.ai"; //prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );

 

 

    // Get all files matching the pattern

    files = sourceFolder.getFiles( fileType );

 

 

    if ( files.length > 0 )

    {

        // Get the destination to save the files

        //destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted PDF files.', '~' );

        destFolder = sourceFolder;

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

        {

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

 

 

            // Call function getNewName to get the name and file to save the pdf

            targetFile = getNewName();

 

 

            // Call function getPDFOptions get the PDFSaveOptions for the files

            pdfSaveOpts = getPDFOptions( );

 

 

            // Save as pdf

            sourceDoc.saveAs( targetFile, pdfSaveOpts );

 

 

            sourceDoc.close();

        }

        alert( 'Files are saved as PDF in ' + destFolder );

    }

    else

    {

        alert( 'No matching files found' );

    }

}

 

 

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

 

 

getNewName: Function to get the new file name. The primary

name is the same as the source file.

 

 

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

 

 

function getNewName()

{

    var ext, docName, newName, saveInFile, docName;

    docName = sourceDoc.name;

    ext = '.pdf'; // new extension for pdf file

    newName = "";

 

 

    for ( var i = 0 ; docName[i] != "." ; i++ )

    {

        newName += docName[i];

    }

    newName += ext; // full pdf name of the file

 

 

    // Create a file object to save the pdf

    saveInFile = new File( destFolder + '/' + newName );

 

 

    return saveInFile;

}

 

 

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

 

 

getPDFOptions: Function to set the PDF saving options of the

files using the PDFSaveOptions object.

 

 

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

 

 

function getPDFOptions()

{

    // Create the PDFSaveOptions object to set the PDF options

    var pdfSaveOpts = new PDFSaveOptions();

 

 

    // Setting PDFSaveOptions properties. Please see the JavaScript Reference

    // for a description of these properties.

    // Add more properties here if you like

    pdfSaveOpts.acrobatLayers = true;

    pdfSaveOpts.colorBars = false;

    pdfSaveOpts.colorCompression = CompressionQuality.AUTOMATICJPEGHIGH;

    pdfSaveOpts.compressArt = true; //default

    pdfSaveOpts.embedICCProfile = true;

    pdfSaveOpts.enablePlainText = true;

    pdfSaveOpts.generateThumbnails = true; // default

    pdfSaveOpts.optimization = true;

    pdfSaveOpts.pageInformation = false;

    pdfSaveOpts.preserveEditability = true;

 

 

    return pdfSaveOpts;

}

Placing registration marks on the corners of document

$
0
0

I have to process a lot of files to be router trimmed which requires them to have very specific registration marks.  There are 2 different marks we have to use.  The first mark is at the top left corner of the image contains 2 .25" dots separated vertically by a 1" gap.  The other mark is one .25" mark that is in the top right, bottom right, and bottom left corners.  I have both of these registration marks saved as symbols (or just AI files).  I want to be able to have the script automatically place the appropriate marks in the corners.  How can this be done?

 

Thanks!

Chris


How to Log data to a consol file or elsewhere

$
0
0

When I use Javascript in Apples Quartz Composer application, it has a Log command I can inspect the state of my code with

 

eg: Log("Give Feedback" + variables)

 

the Log statements appear in the QC app exceptions/Log info drawer and also I can see them in OS X's consul application.

 

What can I use Adobe software since Log is not a know function. Note I'm aware of Alert command but do not want to have to confirm every Log statement with an interaction the way alert does.

Storing a persistent variable with scripting?

$
0
0

Hello --

 

is it possible to store the value of a variable via scripting after a script has been executed or does it only exist during runtime? The use case here would be to store a user entry between multiple executions of a script, e.g. the name of an artboard.

 

thanks in advance,

patrick.

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

UI (Window, dialog, palette etc) reference info for AI scripting

$
0
0

I'm looking for standard reference info on UI elements like popup windows (dialogs, palettes etc). I've been through the Illustrator CS6 Javascript Scripting reference guide and also the CS6 Scripting guide, checking every mention of the words "Window", "Dialog", "Palette" etc (there aren't many), plus related terms like "edittext" and "slider" (which seemingly don't exist in these documents at all), and can't find what I'm looking for.

 

----------

 

I'm trying to script a simple info box that contains information generated by a script that doesn't need to be closed before the user continues working.

 

All I'm trying to find out is the basics. From looking at other scripts I've figured out that you can create a popup box like this:

 

var box = new Window('dialog', 'Some title');

var panel = box.add(panel, undefined, 'Panel title');
panel.add('edittext', undefined, 'Default value');
panel.add('slider', undefined, /*Default numeric value*/,/*min*/,/*max*/);

var group = box.add(group, undefined, 'Group title');
group = area_len_box.add('group', undefined, 'Title (not displayed)');
group.orientation='row';
group.closeBtn = group.add('button',undefined, 'Close', {name:'close'});
group.closeBtn.onClick = function(){
  box.hide();  return false;
}

...which is enough for a very rudimentary input system, but one which has to be closed before the user can return to their work - and I can't find any resource that gives the full options:

 

  • What are the other options for 'new Window'? I'm aware of 'palette' which appears to need an array of four co-ordinates like [20,20,100,100], but it clearly needs something else too as every palette I've made instantly closes. And what else is there beyond Window and Palette?
  • What other input devices are there beyond edittext and slider, and what parameters do they each need?
  • What can go in the "undefined"s I see everywhere these are used?
  • etc etc

 

There must be a reference to this somewhere, but I can't find it.

Set unit preferences (Javascript)

$
0
0

I can't find a way to set the unit preferences for Illustrator CS6/CC using JavaScript.

 

I found that this works (setting units for stroke):

var units = 2; // 0-inches, 1-milllimeters, 2-points

app.preferences.setIntegerPreference("strokeUnits", units)

 

But I want to set the ruler units ("General" in the interface), and this does not work:

app.preferences.setIntegerPreference("rulerUnits", units)

 

Any help?

Peter

Viewing all 12845 articles
Browse latest View live


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