Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all 3671 articles
Browse latest View live

Scripting a PostScript File directly to folder no user interaction

$
0
0

Hey guys hoping you might be able to point me in the right direction here. I'm a noob at scripting Illustrator and have been racking my brain over this script for a few days now.  What i would like to achieve is creating a script that will print a Postscript file to a designated folder with no user interaction. This folder will be on an external volume but just trying to get it to a folder on my desktop at this point... so this is what i started with initially :

 

var myDoc = app.activeDocument;

 

var options = new PrintOptions();

options.printPreset="PS_print";

 

myDoc.print(options);

 

Simple, and it works except that i still have to designate the folder in which the PostScript will be saved..  so i did some digging and came across this code Muppet Mark created on a thread called " Script: print to PostScript" here Re: Script: print to PostScript .  i ran it through ExtendScript and it executed once fine only thing i need to change is where the file is saving.   So i edited it and came up with this:

 

printPostScript();

 

function printPostScript(){

    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; 

   

    var docPath, docs, opts, psPath;

   

    jobOpts = new PrintJobOptions(); 

         

        opts = new PrintOptions(); 

          

        opts.printPreset = 'PS.print'; 

         

        opts.jobOptions =  jobOpts;

   

   

    docPath = decodeURI( app.activeDocument.fullName ); 

         

            psPath = new File( "~/Desktop/TEST" ); 

         

            jobOpts.file = File( psPath ); 

     

            app.activeDocument.print( opts ); 

     

            app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );

   

   

   

     app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS; 

   

   

}

 

problem is every time i use the userinteractionLevel command illustrator throws me an error  for the line where its supposed to execute the actual printing
"app.activeDocument.print( opts );"  Or at least im assuming the userinteractionLevel command is the culprit as Illustrator throws me the same error with the script   that i started with now when it didnt before.   If any of you guys could help me out here it would be appreciated!

 

Thanks


Illustrator 2017 script for creating layers from spot colors in document

$
0
0

Hello, i have script that I use in my workflow everyday but with new Illustrator 2017 I get an error.

The script is trying to find 4 spot color in document (Cut, Crease, Reverse crease and Outside bleed) and put every single color in own layer named as follows:

Spot color "Cut" > layer "Thru-cut"

Spot color "Crease" > layer "Crease"

Spot color "Outside bleed" > layer "Bleed"

Spot color "Reverse crease" > layer "Crease"

 

Script that I have used in old Illustrator is this:

 

#target Illustrator
//Apply to myDoc the active document
var myDoc = app.activeDocument;
//define firts caracter and how many layers do you need
var layerIniName =65;
var numberOfLayers=2;

//Create the layers
for(var i=0; i<=numberOfLayers; i++) {
var layerName = String.fromCharCode(layerIniName)
var myLayer = myDoc.layers.add();
myLayer.name = layerName
layerIniName++

// JavaScript Document 
var doc = app.activeDocument; 
// name indexed object 
var layernames = { 
'A':'Bleed / Grafika', 
'B':'Crease', 
'C':'Thru-cut' 
}; 
// loop through all layers 
for (var i = 0; i < doc.layers.length; i++) 

//Set up Variable to access layer name 
var currentLayer = app.activeDocument.layers[i]; 
if (layernames[currentLayer.name]) 

  currentLayer.name = layernames[currentLayer.name]; 




var doc = app.activeDocument;
var paths = doc.pathItems;
var destLayer = doc.layers.getByName ("Thru-cut");


for (var g=0; g<paths.length;g++){
    if (paths[g].strokeColor.typename == "SpotColor" && paths[g].strokeColor.spot.name == "Cut") {
        paths[g].move(destLayer, ElementPlacement.PLACEATBEGINNING);
    };
};

var doc = app.activeDocument;
var paths = doc.pathItems;
var destLayer = doc.layers.getByName ("Crease");


for (var g=0; g<paths.length;g++){
    if (paths[g].strokeColor.typename == "SpotColor" && paths[g].strokeColor.spot.name == "Crease") {
        paths[g].move(destLayer, ElementPlacement.PLACEATBEGINNING);
    };
};

var doc = app.activeDocument;
var paths = doc.pathItems;
var destLayer = doc.layers.getByName ("Bleed / Grafika");


for (var g=0; g<paths.length;g++){
    if (paths[g].strokeColor.typename == "SpotColor" && paths[g].strokeColor.spot.name == "Outside Bleed") {
        paths[g].move(destLayer, ElementPlacement.PLACEATBEGINNING);
    };
};

var doc = app.activeDocument;
var paths = doc.pathItems;
var destLayer = doc.layers.getByName ("Crease");


for (var g=0; g<paths.length;g++){
    if (paths[g].strokeColor.typename == "SpotColor" && paths[g].strokeColor.spot.name == "Reverse crease") {
        paths[g].move(destLayer, ElementPlacement.PLACEATBEGINNING);
    };
};

 

Can anybody help me resolve this script with new Illustrator?

Thanks

Denis

 

Sample file and script link:

https://www.dropbox.com/sh/hiffbk7yd3lspjg/AACdWhCbuMf2QC3fET8dd4mta?dl=0

Check if objects are smaller than 1mm

$
0
0

Hi.

 

I have a very common and boring task here: check in a file full of text for all characters smaller than 1mm hight (need it before sending some package design to print due to local regulation). To make it easier I assembled the script below, but the problem is when texts are converted to outline, the script will check even the holes inside the characters, and will count them if they are smaller than 1mm.

 

I've tried to maybe select a word and Pathfinder / Unit it, to make sure all holes will me merged, but didn't find a way.

 

Does someone has a better idea?

 

Thanks,

Luiz

 

 

tellapplication "Adobe Illustrator"

  telldocument 1

  setlayers'svisibletofalse

 

-- Select all text and put in a new layer

makelayerwith properties {name:"1_LayerTextosMenores"

  setmyTexttoeverytext frame

  duplicatemyTexttolayer "1_LayerTextosMenores"

 

-- Convert those texts to Outlines.

  telllayer "1_LayerTextosMenores"

  repeatwithxfrom (counteverytext frame) to 1 by -1

  telltext framex

  try

  convert to paths

  endtry

  endtell

  endrepeat

  endtell

 

 

-- make all Stroked part of the text, to avoid it to not be counted in height

  tellapplication "Adobe Illustrator"

  activate

  tellapplication "System Events" tokeystroke "a" usingcommand down

  tellapplication "System Events" tokeystroke "g" usingcommand down& shift down

  tellapplication "System Events"

  clickmenu item "Outline Stroke" ofmenu "Path" ofmenu item "Path" ofmenu "Object" ofmenu bar item "Object" ofmenu bar 1 ofprocess "Adobe Illustrator"

  endtell

 

  endtell

 

-- create layer to put all text that it's not important to me: bigger than 1mm

 

  makelayerwith properties {name:"2_LayerTextosMaiores"}

 

  setTcounttocountofeverypath item

  repeatwithifrom 1 toTcount

 

  setCHtothe (heightofpath itemi) / 28.3439902

 

  ifCH> 0.1 then

  try

  movepath itemitolayer "2_LayerTextosMaiores"

  endtry

 

 

  endif

  endrepeat

  endtell

endtell

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

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

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

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!

Script to convert all "Book Color" swatches to CMYK?

$
0
0

Hi all,

 

Trying to help speed up the work flow for a specific task at work. We use Pantone colors as a reference point for color, but we have to change the "Color Mode" from "Book Color" to "CMYK" for printing. I'm hoping it's possible to write a script to do this automatically for all Pantone swatches in an Illustrator document.

 

For clarity:

Untitled-1.jpg

 

This is all we need to do. It'd just be easier if we could click a script and it happens to all the Pantone swatches at once!

 

Thanks!


"File/Folder Expected" Error

$
0
0

I cannot seem to debug an error I am getting from an Applescript that is adapted from the business card template that ships with Illustrator. Specifically, at the line "updatedatasetiofdocumentcurrentDoc" I am getting an error "File/Folder expected." I am happy to post the entire script but, before doing so, does anyone see anything obviously wrong with the below which may be causing this error?

 

Thank you in advance for any assistance:

 

 

  tellapplication "Adobe Illustrator"

  activate

  setmysetcounttomyindex - 1

  repeatwithifrom 1 tomysetcount

  import variablesdocumentcurrentDocfromaliasXMLfilePath

  setpathTexttoitemioffilePaths

  updatedatasetiofdocumentcurrentDoc

  setmynewfiletoexportFolder& "CaseNo" & i& "-productsource.pdf" asstring

  setmyfiletofile pathofdocumentcurrentDoc

  savedocumentcurrentDocinfilemynewfileaspdf

  closedocument 1 savingno

  openmyfile

  endrepeat

  endtell

  endif

endbatchExport

Illustator - select pathItems based on fill color

$
0
0

I am seeking a vbscript to select all pathItems based on its fillcolor.  Here's what I have but obviously wrong but I think I am on the right "path", ha!  I can't figure out how to say "if the pathitems fill color match my fillcolor, then select it and move on to the next"

 

Here's what I have:

 

Set FSO = CreateObject("Scripting.FileSystemObject")

Set App = CreateObject("Illustrator.Application")

Set SourceFolder = FSO.GetFolder("C:\SOCAL\Section_31\LandCover")

Set FillColor = CreateObject("Illustrator.RGBColor")

     FillColor.Red = 28

     FillColor.Green = 99

     FillColor.Blue = 48

 

If (App.Documents.Count > 0) Then

        Set DocPathItems = App.ActiveDocument.PathItems

        If (DocPathItems.Count > 0) Then

            For Each CurrentPath in DocPathItems

               If CurrentPath.PathItems = FillColor Then

                    CurrentPath.Selected = True

              Else

              End If

          Next

       End If

End If

Select by (spot) color, remove certain spot color

$
0
0

Hi,

 

I want to remove a certain object with a specific spot color from my document. Is it possible to select it by script?

 

Select by Spot Color? Convert certain spot color to CMYK Color?

 

Thanks!

 

Christoph

SVG File to XML conversion code for special characters

$
0
0

i need your support for svg file to xml conversion example

enter image description here

THIS IMAGE IS SVG FILE created with group name with auto A/C

NOW xml CODE

<gid="With_auto_A_x2F_C">
  
<texttransform="matrix(0.9965 0 0 1 447.8486 12.79)"fill="#13110C"font-family="'Helvetica'"font-size="5.9999">With auto A/C</text>
  
</g>
</g>

With auto A/C

why for group name g id is creating like "With_auto_A_x2F_C"> for special characters like "/" changed to x2F and " " characters changed to "_" why can anybody help me to solve this issue.

also can you provide me all special characters conversion for xml code.

Thanks,

Yogesh.v

Digital Printing Workflow - Automation Advice needed

$
0
0

Hi all,

 

I am hoping to enlist the help of an adobe expert to help me figure out an efficient workflow for my sticker printing business.

 

Background and Current Workflow:

We have over 300 sticker designs in our online store. We print and cut them into three unique shapes, we can call them shape A, shape B, and shape C.

Customers pick the sticker design they want and then select the shape (A, B, or C). We receive an order with the sticker design and shape they selected.

 

For production, we take the design files from customer orders and place them on a sheet in a grid with 6 rows and 6 columns in illustrator.

We place the designs in this grid - and then place the shape they selected on top in a separate layer to use as a cutting line.

 

So as a result of the above, we have a 6x6 grid with 36 different designs, and a layer on top of each design with various shapes (A, B, or C) that the customer selected

(i.e Layer 1: Design 4 + Layer 2: Shape A)

 

We hide the shapes layer (Layer 2) and send the grid of designs to the printer,

Once it is printed, we then hide the design layer, leaving only the shape outline, which we then send to the plotter to cut.

 

The result is 36 stickers printed with the customers design and cut out in the shape they selected.

 

Now, we are trying to speed up this process. The idea would be to save 3 versions of each design for each shape.

1. Design 1 - Shape A

2. Design 1 - Shape B

3. Design 1 - Shape C

 

and we would do this for all of the 300 designs.

 

When orders come in, we would drag all the matching files into a folder, which illustrator would then pull from and place into the 6x6 grid.

We could then select the layers to show the Designs only, which we can then send to print.

Following that we could select just the Shape layer and send that to the plotter to cut.

 

This would reduce the time-consuming process of manually placing each file into the grid and then placing a shape on top. We could simply place all the files that match the orders into a folder, and then our print ready files would be created.

 

Sorry in advance for the lengthy post. Any advice to improve/change this workflow is greatly appreciated. Let me know if I can clarify anything!

 

Thank you

Javascript for Illustrator : Copy a document on another specific document issue

$
0
0

Hi,

I've managed to select elements on a source file but it fails when copying. The selection should be copied on targetFile.

There is like 5 to 10 files by sourceFolder (there is an error in opening each file but this is not the matter for now - only the first one is openend)

 

var targetFile = app.documents.add();                                   //this is my output file - it works

 

folder = Folder.myDocuments;                                               //this paragraph works for now

sourceFolder = folder.selectDlg("source");

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

     var sourceDoc = app.open(files[i]);

     var doc = app.activeDocument;

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

                doc.pageItems[i].selected = true;

    }

 

     var mySel = app.activeDocument.selection;          //this paragraph need rework

     newItem = mySel[0].duplicate();                              //mysel.duplicate() is not a function

}

 

Thanks I copy a document, resize it and place it then I print the output

Is there a way to select pathItems base on stroke size and spotcolor?

$
0
0

Hi Everyone,

 

I am a entry level scriptor and I am currently stuck on this one specific step. I am trying to have a script loop through pathItems and select a path that matches these criterias:

 

  • Stroke is using spotcolor name "BLACK" with No Fill
  • Stroke is size at 2pt

 

I have found a script that loops through pathItems and selects paths with a specific point size, but I am having trouble add the part where it selects a path with the assign color "BLACK" on the stroke. Can anyone help me with this script?

 

// script.name = selectPathsThisSize.jsx; 
// script.description = selects pathItems that have the same supplied stroke width; limited to 3 decimals; 
// script.required = a document with at least one path item; 
// script.parent = CarlosCanto // 6/5/11; 
// script.elegant = false;  
var idoc = app.activeDocument; 
var strokewidth = 2

//prompt ("Enter Stroke Width in points of paths to be selected", 0.361, "Select Paths this size:___");  
for (i=0 ; i< idoc.pathItems.length; i++) {             var ipath = idoc.pathItems[i];                if ((ipath.strokeWidth).toFixed(3) == Number(strokewidth).toFixed(3)) {                                                                  ipath.selected = true;                     }      }  
app.redraw(); 

why group id is not cr

$
0
0

Hello every one ,

 

I have written a script to change Group name based on the text inside the group.

 

 

this text is broken in to two lines but same text , it is inside the group

 

i have written the code to change group name in to

 

 

 if( count_text_len==2)                               {                                  groups.groupItems[text2].textFrames[text3].parent.name= groups.groupItems[text2].textFrames[text3].parent.textFrames[1].contents+                                  "-"+groups.groupItems[text2].textFrames[text3].parent.textFrames[0].contents.slice(1,groups.groupItems[text2].textFrames[text3].parent.textFrames[0].textRange.characters.length)                                    file_output.writeln( groups.groupItems[text2].textFrames[text3].parent.name+","+sourceDoc.name);                                  }

but it is changing , while saving svg file if i keep in preserve illustrator editing capabilities  true group name remains the same but group id is not generated in svg code

 

if i keep preserve illustrator editing capabilities  false , group gets ungrouped

 

 

can anybody tell me why it is happening in svg file

 

 

with regards,

yogi

Change file name while saving with actions/macros.

$
0
0

Hey all,

 

I'm setting actions in Illustrator to save multiple file formats of the same file to streamline workflow.
Is there any way to add to a filename using/while using the actions?

 

Ex:

 

Saving business card designs I need to save five PDF files:
Front
Front w/o crop marks

Back

Back w/o crop marks

and Full art.

 

Is there a way to add the description to/modify the file name within actions?

 

So if the original name is:
Client_BC

 

I can run the action and it will auto save
Client_BC_Front.pdf

Client_BC_Front_NoCrop.pdf

Client_BC_Back.pdf

Client_BC_Back_NoCrop.pdf

and
Client_BC.pdf

 

??

 

Does that make sense?

 

Any and all help is very appreciated.

 

Thanks!

Use applescript to delete text based on point size

$
0
0

I need to create a script that will delete all text in an Illustrator document that is larger than 70 points. All of my attempts have resulted in errors saying the item can not be deleted or adobe illustrator "can't get size"

 

I found a script in another forum (Select Objects based on font size or other criteria? )that creates a dialogue box asking for a point size range. When you put in the range it selects type within the range. This works really well but I need to run this script on a large number of files and manually inputting the size range each time is time consuming.

 

Any help would be appreciated. Thanks so much

Excel data to construct illustrator object

$
0
0

Problem:

How to read real number data from selected columns in an Excel spreadsheet into an illustrator javascript array variable, so that then I can use this information to construct an illustrator polygon. 

 

Further information:

I am new to javascript (and not much of a programmer in the best case, but do have some basic knowledge using ancient languages like FORTRAN 88). I am sure I am just missing an important step here despite all morning browsing with Google for answers (something to do with variable definition I assume?). I have some survey data defining the outline of features in map view listed in a string of point (x,y) values in adjacent columns in excel (these x,y point values calculated from GPS data using a commercial program to converted 3D position to a 2D x,y by geoid projection, and then in excel to re-scale point locations to illustrator’s artboard).  What I am trying to do is select columns of x,y value pairs in an excel spreadsheet, copy these values to the clipboard, and then develop an IA JavaScript to draw a polygon through the specified set of x,y points. It seems easy enough to script illustrator to draw the polygon once I get the values from the clipboard are in a javascript array (lots a good tips here http://scriptographer.org/tutorials/), but pulling in the clipboard data seems to be beyond me. I have tried populating a defined array with various combinations of array declarations and app.paste(); or windows.clipboardData.getData('text/plain'); with no satisfaction. I then had the idea to try to pull in the clipboard to one long continuous string, place that in a text box (see see its structure), andthen read and split up the text in a loop to populate the JavaScript array…but that deposited a complex illustrator table object into my text box, and several attempts to force the clipboard to paste text did not work (again probably having problems understanding variable type declaration).

 

Thanks very much for any suggests….and to be clear, I would be happy to find any method of scripting the pull of the selected on an excel spreadsheet for use in an Illustrator script…so if I am making this all harder than it needs, be I would be grateful to know that also!

Select pathitem by name and remove it.

$
0
0

So I have a script that will calculate the distance between print impressions when something is printed using whichever cylinder I choose. If I move the repeat line to a different cylinder marker, the script will copy the first impression and create a duplicate and place it exactly where that impression would start printing again depending on where the repeat line is placed. Also, it calculates the distance between prints and writes it on the artboard. If I am changing a proof and there is already measurements it will delete the existing measurements and create new ones. That all works fine.

 

What I've yet to get it to do is to delete the copied impression called "repeat impression" so that the new altered artwork can take it's place. Currently I just click and delete the repeat impression before I run the script, but I figure since it is always named "repeat impression" I could just have the script check and see if that object exists and delete it first before running. Not sure what I'm missing...

 

 

//Delete existing Measurements layer and repeat impression to make way for new ones in cases when proof had to be adjusted/changed.

 

function mLayerCreate() {

 

          var mLayerNotExists = true;

 

try {

    app.activeDocument.layers.getByName("Measurements").remove();

} catch (e) {};

 

 

try {

    app.activeDocument.pathitem.getByName("repeat impression").remove();

} catch (e) {};

 

 

// Create Measurements Layer

if(mLayerNotExists){

mLayer = myDocument.layers.add(); // not using var to declare makes it global

mLayer.name = "Measurements";

}

}

 

function releaseLayer(){

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

                    if(activeDocument.layers[i].name == "plate") {

                              activeDocument.layers[i].locked= false;

                              activeDocument.activeLayer = activeDocument.layers[i];

}

}

 

}

Viewing all 3671 articles
Browse latest View live