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

Can you execute an action from the command-line using AI?

$
0
0

I need to do a form of automation, but wanting to execute this from another process (self-made application). Adobe Photoshop has this mechanism called "Droplets" that are executables based upon Actions defined in Photoshop (as far as I can understand). Is it possible to let AI do some work for you from an external application as with Photoshop (assuming you are able to execute the executable once it has been created)?

 

Kind Regards,


Changing locations of text in a figure

$
0
0

Hi,

 

I want to change the location of texts in plots derived from Rstudio and change their location.

 

I was wondering to know if this is possible and if it is please direct me how.

 

Thanks for your helps

Sina

Help Automating Batch

$
0
0

Disclaimer: I can't write in javascript or any other language, I understand the concept of scripting but have no ability to actually write a script.

 

I am trying to automate my work with large numbers of files and Actions are no longer cutting it for me. Currently I use an action which is designed to help me save large batches of files for print. The action currently selects everything in my document, outlines all fonts, and saves a pdf with a specific preset for our RIP. Because we often use a flatbed i-cut machine, I also need to have layers in my document for outside cut paths, holes and inside cut paths, scoring paths, and registration marks. I need to be able to write an action which will turn of layers by name before saving pdfs, but currently Illustrator doesn't have a way to select layers by name through actions. Currently I have to save files with the layers either turned on or off and then manually save cutting paths and proof/print pdf.

 

My dream would be something that does this:
Select All
Create Outlines
If there are any Layers named "Outside Cut", "Holes-Inside Cut", "Score", or "regmarks" Save file as a pdf in a folder named "epson", and append filename with "_e"
Hide Layers named "Outside Cut", "Holes-Inside Cut", "Score"
Save file as a pdf in a folder named "print files"
Show Layers named "Outside Cut", "Holes-Inside Cut", "Score"
Delete any layer which isn't named "Outside Cut", "Holes-Inside Cut", "Score", or "regmarks"
Save file as a pdf in a folder named "icut", and append filename with "_icut"

 

Can anyone point me in the right direction of the tools I'll need to assemble this, or help me with writing it? I have a sample file which shows what I'm working with and looking for.

How to output the values in a loop?

$
0
0

I'm trying to make a bunch of swatches between a color range.

 

I made this function:

 

function colorSwatch(color) {    var newGrayColor = new GrayColor();    newGrayColor.gray = color;    var newSwatch = app.activeDocument.swatches.add();    newSwatch.name = ' " ' + color + ' " ' ;    newSwatch.typename = GrayColor;    newSwatch.color = newGrayColor;  };

 

Which works if I call it like this....

colorSwatch(0.00);
colorSwatch(0.01);
colorSwatch(0.02);
colorSwatch(0.03);
colorSwatch(0.04);
colorSwatch(0.05);
colorSwatch(0.06);
colorSwatch(0.07);
colorSwatch(0.08);
colorSwatch(0.09);
colorSwatch(0.10);

 

I've been trying to figure out if I can use an array in place of possibly hundreds of lines of colorSwatch(color);

 

I made this array:

function colorNumbers() {    var colorNums = []    for (i = 0; i <= 100; i += 1) {    colorNums.push(i / 100);    }    return colorNums;
}

 

And now I'm stuck.  I thought I could do something like this..

function getColorNumber (){    var color = colorNumbers();    for (var i=0; color.length; i++) {        return color[i];    }
}

 

Then I call

colorSwatch (getColorNumber ());

 

but I only get one swatch made.  Then I tried revising this function

function getColorNumber (){    var color = colorNumbers();    for (var i=color.length; i < 2; i++) {        return color[i];    }
}

 

did the same call

colorSwatch (getColorNumber ());

 

and I get an error saying that in my colorSwatch() function newSwatch.color = newGrayColor; that "Numeric Value is Expected"  I'm using Adobe ExtendScript Toolkit CS6 to test my script.

Scripts that copy the width/height of the object to the clipboard

$
0
0

Could you create two scripts that copy the width/height (only a fractional number without "px") of the selected object (or group of objects) to the clipboard?

use "object -> path -> divide objects below" via script & make selections?

$
0
0

Hi all,

 

I've really tried to seek out existing answers before posting, but I've had some difficulty in finding answers to these two. I saw one, but it didn't make sense to my newly-scripting mind.

If it's of importance, I'm using javascript.

 

I have my script selecting a particular line to use the "object --> path --> divide objects below" menu item with, which works fine in the AI GUI.

Scripting, however, I can't find a way to call that. Even creating an action doesn't seem to 'record' selecting that menu item.

Is there a way to have this ran via scripting?

I know there are PathFinder alternatives, but the results I was getting (especially with Divide) wasn't the result I'm needing in a 'razor' cut.

 

And secondly,

Once sliced, I'd really like to select a range of objects within certain x,y coordinates and group them, especially since layer names get dropped when you divide them. I'm not sure if this can be done either?

 

I have the javascript reference manual, but am having a difficult time finding my way to the right commands...and at times getting the syntax to stick.

 

Thank you for your help...and I hope this isn't horribly fundamental or dumb sounding!

 

John

Auto targeting for Illustrator in ESTK

$
0
0

Since the default script target in ESTK is ESTK itself, is it possible to target for Illustrator in script code?

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


Get broken file path of rasterItem

$
0
0

Hello there,

 

I made a little script to create an artboard for each selected image. The artboard should have the name of the image and should be in its position.

Everything is working fine for embedded and non embedded images. The problem I have, is that I don't know how to get the file path for embedded images (rasterItems) that have a broken link.

Those items do have the path property somewhere, since the ui shows them

and also the ai file contains them (Not quite sure if I can access that):

I read over here that the information is only stored in XMP, but I don't understand how to access it.

 

My script on Github

 

Relevant code:

var rasterItems = docRef.rasterItems;
for(var i = 0; i < rasterItems.length; i++) {    var item = rasterItems[i];    if(item.selected) {                    var filename = "RasterItemArtBoard";        try {            filename = item.file.name;        }        catch(e) {            // File does not exist            // TODO: Get name otherwise        }        filename = filename.substr(0, filename.lastIndexOf("."));        var artboard = docRef.artboards.add (item.geometricBounds);        artboard.name = filename;    }
}

 

So in the end, I need the filename of a broken file path and I have no idea how to access it.

I tried:

  • item.name
  • item.displayName
  • item.parent.name
  • item.note
  • item.uRL
  • reading the value from the error message

Split a string into multiple lines based on length

$
0
0

I am allowing the user to input a description. What I am needing is to split up the string they input based on 27 characters.

 

So if their description is less than 27 characters....

It is a single string and needs to alert them of that.

 

If their description is more than 27 but less than 54 characters....

I need it to find the space closest to the 27th character, then split the string into 2 lines

 

If their description is more than 54 but less than 81 characters....

I need it to find the space closest to the 54th character, then split the string into 3 lines

 

If their description is more than 81 but less than 108 characters....

I need it to find the space closest to the 81st character, then split the string into 4 lines

 

If their description is more than 108 characters....

Alert that it is really long

 

Here is a section of code I am working with

 

                for (z = 0; z < theDocVariables.length; z++) {                    // Start finding variables here                    if (theDocVariables[z].name == "coverPageDecriptionLineOne") {                        if (getText(titleDescription).length < 27){                            alert("single line");                            }                        if (getText(titleDescription).length > 27 && getText(titleDescription).length < 54){                            alert("two line");                            }                        if (getText(titleDescription).length > 54 && getText(titleDescription).length < 81){                            alert("three line");                            }                        if (getText(titleDescription).length > 81 && getText(titleDescription).length < 108){                            alert("four line");                            }                        if (getText(titleDescription).length > 108){                            alert("that's a long freakin description");                            }                        alert("Your title is " + getText(titleDescription).length + " characters in it");                        }

(JS) Checking if a folder exists

$
0
0

Hi everyone!

 

I would like to check if a folder exist. I was trying with this code but doesn't work.

I will thank you in advanced if you know a better way to do this.

 

Best regards_

 

- Code not working

path = Folder.desktop + "/MyFiles";
var folder = new Folder(path);
if(!folder.exists){  alert("Folder doesn't exists");
}else{   alert("Folder Exist");
}

Saving to a Relative Subfolder

$
0
0

Currently working on a script while saves variations of a file for me. Problem I'm having is that I can't get it to save the new files anywhere except the same directory as the original file. I need it to save in specific subfolders but nothing I've tried is working

 

Currently the code looks more or less like this (large chunks omitted to save reading):

 

var pdfOption1 = 'Print pdf'; // <--- in here put the name of your PDF settings for EPSON
var pdfOption2 = 'Print pdf'; // <--- in here put the name of your PDF settings for printing
var pdfOption3 = '[Illustrator Default]'; // <--- in here put the name of your PDF settings for ICUT


var pdfFolder1 = 'epson/';
var pdfFolder2 = 'print%20file/';
var pdfFolder3 = 'icut/';


var pdfSuff1 = '_e.pdf'; // Suffix for  EPSON PDF
var pdfSuff2 = '_print.pdf'; // Suffix print PDF
var pdfSuff3 = '_icut.pdf'; // Suffix ICUT PDF

function saveCopyAsPDF (setPDF, placePDF, namePDF) {
        var doc = app.activeDocument;        var options = new PDFSaveOptions ();            options.pDFPreset = setPDF;            options.viewAfterSaving = false;        var targetFile = null;            targetFile = app.activeDocument.fullName.toString().replace(".ai", namePDF);           doc.saveAs (new File (placePDF + targetFile), options);        doc.close ();        }

saveCopyAsPDF(pdfOption1, pdfFolder1, pdfSuff1);

 

What I think is supposed to happen is it should save the file as "originalfilename_e.pdf" and place it in the epson folder (which already exists). What happens though is that illustrator simply brings up an empty save as dialogbox. What am I doing wrong in trying to place these pdfs in a subfolder? When naming the pdfFolder variables I have tried '../epson/' '/epson/' and 'epson/' but nothing is working to save to a subfolder relative to the original.

Anti-aliasing Type Optimized/Art Optimized on PNG export

$
0
0

Hello there,

 

I'm modifying a javascript that makes an export of each layer contained in an Illustrator document and I want to specify the method used for anti-aliasing (either Type Optimized or Art Optimized). Similarly to the option under the "Image size" tab in the "Save for the Web" panel.

 

I didn't find any antiAliasingMethod property in the ExportOptionsPNG24 properties (only an antiAliasing property that accepts boolean). So I wonder if it is actually possible to do it through scripting?

 

Many thanks,

D

Resolution check in illustrator

$
0
0

How to check the raster image resolution in illustrator through script?

Scripting Variable Fonts in Illustrator

$
0
0

Hy there,

 

How can I set the parameters for a variable font?

The TextFont.axisVector is 'Read Only'

 

Greetings, Akiem


Text Replacement script

$
0
0

Hello all,

 

I am very new to the scripting world but have an issue that I was unsuccessful in resolving myself through googling and searching around. It may be impossible due to illustrator's set up but I am looking for a script to find and replace strings of text throughout a document. I realize in indesign this would be easy as all get out, but due to other limitations I am forced to use Illustrator.

 

I would need the script to search and find strings in both text boxes and text objects (or 2 scripts could work). I would be looking for something to find and replace as well as style for instance, find AA and replace with AA(registration mark) and superscript the registration mark. I would need to be able to do this for multiple instances of this string on a document. Is something like this possible?

 

Thanks in advance!

Illustrator UI down while script is running.

$
0
0

Hi!

 

I've made a script that helps me tremendously every day doing heavy repetitively work (moving around layers, grouping items etc.). There is one thing that's bugging me. While the script runs I can see whats happening on the screen, a layer moving here, moving there, making a group here and so on but after 2-3 seconds all of the illustrator UI turns black and then I can't see anything until the script is finished.

 

This can be a problem because I want to know the progress of the task that the script is doing to determine if it's running at all or if it stopped/hanged etc.

 

The only solution I have is to do a Window.alert("I'm alive"); once in a while but that requires me to always sit in front of the computer to press the "OK" button to dismiss the window.

 

Any ideas?

End of story

$
0
0

Hello all. I have a finnicky problem whereby I've created a script to clean up some text and the result is that in some instances I end up with a blank space preceding the end of story. I wish to find this blank space and delete it. The problem is in identifying the end of story, which you all know is the hashtag symbol. But of course you can't search a hashtag. I've tried \$, but that doesn't work because there are multiple elements selected and it only does the last one. I've tried \n, but that doesn't work. I've tried \r but that doesn't seem to work either.

 

Any thoughts?

 

Marcrest

Creating Multi-Page PDF from a Layerd Illustrator file (script)

$
0
0

Often times when designing a logo I create different versions and variable options on layers. This can result in several layers in one Illustrator file. Is there an easy way or an existing script that will allow me to (with one click) create a multi-page PDF consisting of all the layers within my .ai file? The current method is turning on each layer, performing a save-as (PDF), then turning off said layer and turning on the next layer and repeating the task and so-on-and-so-forth, etc … It becomes tedious and quite often I save over the previous version, forgetting to re-name it or forget to perform a save on a certain layer. Can anyone help with some advice? I have never written my own script before but am not opposed to trying, where do I begin?

Any help is appreciated.

How would I count the number of cells of a certain color using grids?

$
0
0

I am playing around with some pixel art.  5bf438da3a41ba9358f0ea49dc83910e.png

 

I am using the grid system to design my image, like the mushroom above. Once the image is done, or in the process of making it, I would like to have a tally at the end that says 24 white; 45 red; 18 black (or whatever the correct number is).

 

Any suggestions on how to do that?

Viewing all 12845 articles
Browse latest View live


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