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

Package Illustrator file

$
0
0

Hi

 

I want to package a illustrator file using "executeMenuCommand". I tried its trigger the dialog box for the further selection. I want to execute the command without the dialog box.

 

 

app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;

app.executeMenuCommand ("Package Menu Item");

 

 

Thanks in Advance.


Java Script to Save ai to PDF with password...

$
0
0

Hi folks.  My goal is to have a script carry out the following functions:

 

1. grab the active document name

2.  save as a PDF using the active doc name with password lock in the same directory the *.ai file is located

 

I have started fiddling with some code but I don't know what I'm doing...newbie.

Here is the code I'm currently using.

 

var curDoc = app.activeDocument;
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts;
//var destName = "~/Desktop/Testpassword1.pdf";
var destName = targetFile
saveFileToPDF(destName);
//sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PDF', '~' );
//saveFileToPDF(destName);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( sourceFolder != null )
{    //files = new Array();    //fileType = '*.ai';    //fileType = 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.', '~' );        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( 'Saved' + destFolder );    }    else    {        alert( 'No matching files found' );    }
}
 ///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 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;
}
///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function saveFileToPDF (dest) {

var doc = app.activeDocument;

if ( app.documents.length > 0 ) {

var saveName = new File ( dest );
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5;
saveOpts.generateThumbnails = true;
saveOpts.optimization = true;
saveOpts.preserveEditability = true;
saveOpts.bleedOffsetRect = [2,2,2,2];
saveOpts.trimMarks = true;
//=======================  COMPRESSION ===========================
saveOpts.colorCompression = CompressionQuality.JPEGMAXIMUM;
saveOpts.colorDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
saveOpts.colorDownsampling = 300;
saveOpts.colorDownsamplingImageThreshold = 450;
//-----------------------------------------------------------------------------------------------------------
saveOpts.grayscaleCompression = CompressionQuality.JPEGMAXIMUM;
saveOpts.grayscaleDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
saveOpts.grayscaleDownsampling = 300;
saveOpts.grayscaleDownsamplingImageThreshold = 450;
//-----------------------------------------------------------------------------------------------------------
saveOpts.monochromeCompression = MonochromeCompression.CCIT4;
saveOpts.monochromeDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;
saveOpts.monochromeDownsampling = 1200;
saveOpts.monochromeDownsamplingImageThreshold = 1800;
//====================  END OF COMPRESSION =======================
saveOpts.colorConversionID = ColorConversion.COLORCONVERSIONREPURPOSE;
saveOpts.colorDestinationID = ColorDestination.COLORDESTINATIONWORKINGCMYK;
///
saveOpts = new PDFSaveOptions();
saveOpts.requirePermissionPassword = true;
saveOpts.permissionPassword = "pink";
saveOpts.pDFAllowPrinting = PDFPrintAllowedEnum.PRINT128LOWRESOLUTION;
doc.saveAs( saveName, saveOpts );
}
}
saveOpts.pDFAllowPrinting = PDFPrintAllowedEnum.PRINT128LOWRESOLUTION;
doc.saveAs( saveName, saveOpts );
}
}

GREP like targeting of specific characters

$
0
0

Hello, I'm looking for a solution very much like InDesign can use a GREP style to recognise a repeating character, isolate it and treat it with a special character style.

I have multiple lines of live text that when ever a "+" sign is inserted a baseline shift needs to be actioned to bring it down past the baseline. I have a character style to achieve this but need to automate the process so it can be used in conjunction with a data-set.

Thanks

Need script to batch convert vector .eps to .png images with scale

$
0
0

Hi,

 

I'm looking for a script/program that if you run it, all the .eps files in a folder will batch convert to a png-24 with 250% scale.

 

Erdem

Scripting a repetitive save as command?

$
0
0

Hello, 

 

I would like to automate(script) a workflow which saves my current file as pdf.

as it is, here are my current mouse clicks:

1-Go to file: Save as

2-Select, if not selected, pdf format.

3-Check to save in the same location as the original folder

4-Select the pdf options which are a pdfx-1a hybrid.

   Done.

 

I would love to simplify those steps with one click.

I tried it with actions but it keeps saving new files into the original folder that originated the action.

 

Can the above be done withe Javascript?

 

Thanks,

 

Freddie

A way to call an Illustrator File/Script from another script?

$
0
0

If I have a script inside Illustrator's File/Script menu I would like to run from a script outside Illustrator.

 

The only code I found that might be related is:

 

app.executeMenuCommand("script name here?");

 

I'll take any examples in either VBscript or JavaScript. 

 

Thx,

Clutch

Illustrator scripting bug list.

$
0
0

Hello dear friends, the time has come... to assemble a list of bugs we want to have eliminated.

I've come into contact with an engineer on LinkedIn and he has this to say in a private email exchange:

 

Me: "I have a variety of issues I can provide you with, including cases provided by other scripters around the world. Would you want to focus on any specific issue at first, or do you wish to get the entire catalog of reports?"


Him: "Entire catalog in a prioritized list will be great. I can then get into a conversation with developers with this doc. Also, anything you can do to help me explain why fixing something “non obvious” is important will also help me."

 

Okay, so let's put some list together to send him and hopefully it can start some ball rolling.
I think we should come up with a format to document each "situation" , as these bugs are not typical user bugs and are sometimes more elusive.

Script to Rename Artboards Based on Layers (and Reverse)

$
0
0

A couple of years ago I had some awesome help making a couple of scripts to rename layers based on the containing artboard (Re: Script to Rename Artboards with Layer Names). One problem posed (and solved) was:

 

- Each artboard has a name.

- Each layer NEEDS a name.

- There are an equal number of layers and artboards.

- Only one layer "exists" on each artboard. (i.e. They share coordinates.)

- I would like to name the layer with the same name as its encompassing artboard.

 

The solution was:

 

function artboardLayerNameMatch() {     if (app.documents.length == 0) {         alert("No Open / Active Document Found");     } else {         var doc, i, l, ab, sel, n;         doc = app.activeDocument;         for (i = 0, l = doc.artboards.length; i < l; i++) {             ab = doc.artboards[i];             doc.artboards.setActiveArtboardIndex(i);             doc.selectObjectsOnActiveArtboard();             sel = doc.selection[0];             sel.parent.name = ab.name;             doc.selection = false;         }     } 
} 
artboardLayerNameMatch();

 

Now, I'm wondering if the reverse is also possible?

 

The new scenario is:

  • Each layer has a name.
  • Each artboard NEEDS a name.
  • There are an equal number of layers and artboards.
  • Only one layer "exists" on each artboard. (i.e. They share coordinates.)
  • I would like to name the artboard with the same name as the layer that resides “on” it

Qwertyfly's script function 'myTrace()', but can't find trace preset?

$
0
0

I found this script from a post 2 years ago from Qwertyfly.  Being so old I though I would post my issue in a new thread.  It appears to be exactly what want however when I run the script I always get the following error message "cannot find tracing preset that has been set in the script".  I have tried several of the default trace presets but always the same message.

 

What I am doing is using a VBscript to load a TIFF file, I make sure the document is selected then call the myTrace script.  I also tried the script by having it in the Illustrator's File/Scripts folder and running it directly.  Same error message.  FYI, I am using Illustrator CS6.

 

If Qwertyfly happens to see this or if someone can chime in that would be great.

 

Here's the script.  I commented out the lines of code that play an action.   Just want to trace for now.

 

function myTrace(){ 

    //-----User Set Variables------- 

    var Tracing_Preset = '16 colors';

    //var My_Action_Name = 'Rotate .5'; 

    //var From_Set_Name = 'MyActions'; 

    //-------------------------------------- 

    if(app.tracingPresetsList.indexOf(Tracing_Preset)<0){ 

        alert('cannot find tracing preset that has been set in the script'); 

        return; 

    } 

    var doc = app.activeDocument; 

    var sel = doc.selection; 

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

        //if(sel[i] == '[RasterItem ]'){              //This line was quoted as a mistake and new line is below it.

          if(sel[i].typename == 'RasterItem'){     

            var pic = sel[i].trace(); 

            pic.tracing.tracingOptions.loadFromPreset(Tracing_Preset);  

            pic.tracing.expandTracing().selected = true;  

        } 

    } 

    // no test to confirm the action is present. make sure action name and set name are correct. they are case sensitive. 

    //app.doScript(My_Action_Name, From_Set_Name);    // don't want this Action to happen so commented out.

 

 

// add indexOf prototype to Array's 

Array.prototype.indexOf = function(needle) { 

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

        if(this[i] === needle) { 

            return i; 

        } 

    } 

    return -1; 

}; 

 

 

myTrace(); 

Lot and expiry date script

$
0
0

Hi I was wondering if anyone could help me, I have zero experience with writing / using scripts but I need one for our printed documentation in work, i have saw similar requests on the forum but as ive said i have no experience so could not change these to suit our purpose.

 

The format is below, the document will be printed and shipped with the product, I need the LOT and EXPIRY date to update when the file is opened to be printed

 

LOT number = today's date (Format - ddmmyy)

 

Expiry number = Lot number + 5 years – 1 month (Format yyyy-mm)

 

I.e.

LOT – 150617

EXP – 2022-05

 

CE Insert script.jpg

 

If anyone could help me out with this it would be much appreciated

Help with Illustrator script

$
0
0

Hi,

I'm looking for help to write what (I think) should be a fairly simple script.

What I want to have the script do is, after I select some text:

1. Convert the text to outlines.

2. Change the fill to no color

3, Change the stroke to red (RGB 255)

3. Change the stroke weight to 0.0625 pt

 

Any thoughts on whether this is doable and how complex it would be?

Thanks for your time!

Jenn

Multiple artboards to multiple layers

$
0
0

Hello everyone, I have this script to convert multiple layers to multiple artboards, and also copy each layer name to artboards.

The problem is how to reserve the this script process?

I mean to converts artboards to layer and copy artboards name to layer. Thanks

 

#target illustrator  
main();  
function main() {              if ( app.documents.length == 0 ) { return; }            var doc = app.activeDocument;              doc.layers[0].hasSelectedArtwork = true;              doc.fitArtboardToSelectedArt( 0 );              doc.selection = null;            for ( var  i = 1; i < doc.layers.length; i++ ) {                        doc.artboards.add( [0,0,72,-72] );                        doc.layers[i].hasSelectedArtwork = true;                        doc.fitArtboardToSelectedArt( i );                        doc.selection = null;            };  
};

if (app.documents.length == 0) {
    alert("No Open / Active Document Found");
} else {    var doc = app.activeDocument;    if (doc.artboards.length == doc.layers.length && doc.layers.length == doc.artboards.length) {        for (var i = 0, l = doc.artboards.length; i < l; i++) {            var ab = doc.artboards[i];            ab.name = doc.layers[i].name;        }        alert("Finished:\nRenaming of Artboards to match Layer names is complete");    } else {        alert("Opps: This wont work!\n The number of Layers and Artboards do not match");    }
}

Data Merge in Illustrator?

$
0
0

Hi there, anyone knows if Illustrator has Data Merge function?

or InDesign Data Merge 'alike' function in Illustrator?

 

Thank you.

Turn selected AI sublayers into top-level layers?

$
0
0
Hi, all!

I wanted to ask if by chance any of the scripting gurus here happen to have written an AI script that will take a number of selected sublayers/sub-sublayers and move them so they become top-level layers?
I am really needing this very badly, given that After Effects can only handle AI layers as separate entities. So I find myself moving tens, even hundreds of nested sublayers to the top level all the time.
Is it possible this script exists already?

Export file as a DXF

$
0
0

My script is working nice until I try to export my document. I am trying to export my document as a DXF file.  Using the Illustrator CS6 Scripting Reference I am using the TIFF export as a reference as there are no examples for exporting as a DXF (my luck!).  This is what I have in VBscript.  With this script I get the following error on the second to last line:

 

"Illegal argument - argument 2 - Enumerated value expected"

 

As you can see I do have one: "0" so I suspect the error lies elsewhere in the code?  I'll take a JavaScript example if you are not into VBscript since the two look very similar and I think I can adapt it.

 

Set App = CreateObject("Illustrator.Application")

Set FSO = CreateObject("Scripting.FileSystemObject")

 

Dim dest

dest = "S:\SOCAL\Section_32\Veg DXFs LC\SOCAL_CK67_pineLC"

 

Set DXFexport = CreateObject("Illustrator.ExportOptionsAutoCAD")

    If App.Documents.Count > 0 Then

        Set docRef = App.ActiveDocument

        Call docRef.Export (dest, 0, DXFexport)      ' 0 = aiDXF

    End If


javascript's "do script" documentation for Aia no gui

$
0
0

Hi,

 

I'm leeching Adobe's and Stack Exchange's forums, but I can't find any recent post about this specific command:

 

           app.executeMenuCommand('ai_browse_for_script');

 

I want to run a action script on a batch of files without User Interaction, only jsx file - So this CMD needs more parameters like PATH and NODISPLAY. NB: this cmd showed up since CS6

 

It is not in guides CS6 nor CC2017 (we already knew that) So it's not present into Jongware's fantastic CHM reference guide; The best guide about menuExecCMD I've found so far is http://chuwa.iobb.net/tech/illustrator-cc2014-menu-comman.html

Maybe noone is using this which I highly doubt; the only documented workaround seems to doscript from VB which is something I could do, but I was focusing JSX for now.

So I will run something like this:

 

#target Illustrator-21
#targetengine main
var scriptID = "test-doscript v0.0";
var sourceFolder1 = null;
var fileType = null;
var files1  = null;
var sourceFolder1 = Folder ("C:/TEMPai/F1");
var fileType = "*.pdf";
var originalInteractionLevel = userInteractionLevel;
userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;     files1 = new Array();     files1 = sourceFolder1.getFiles( fileType );      if ( files1.length != 0 ){          for ( i = 0; i < files1.length; i++ ){               var sourceDoc1 = app.open(files1[i]);               app.executeMenuCommand('ai_browse_for_script');          }     }

 

I'm looking for the equivalent of this - NB: I don't car about errors as I debug them myself. I doing things 1 by 1, nowadays I [think to] know what I'm doing.

Thank you for your time, maybe my google-fu is stuck. Overall this is very important to have a complete control about what illustrator do, because I can manage keeping ram usage low with the For {} loop, indeed I can't save save my work until the otherwise I'll loose hours a day waiting Ai to save files

 

Possible workaround? Could I copy paste aia into jsx file? https://gist.github.com/moluapple/2568405

EDIT: app.executeMenuCommand('ai_browse_for_script';script1); is not syntax-correct

EDIT2 app.executeMenuCommand('ai_browse_for_script') is requesting vb or jsx file extension only

 

Image: This is the screen I want to get rid off keeping the same idea, instead there I will make the batch myself

 

 

Message was edited by: et3d Updated edit

[Q] Is there any way if the document is showing Perspective Grid or not

$
0
0

Hi all,

 

I got issue with moving object position when Perspective Grid is showing.

Is there any way if the document is showing Perspective Grid or not?

 

Document object has some function to control Perspective Grid,

but it seems no function or property to tell if currently Perspective Grid is shown or not.

 

getPerspectiveActivePlane() returns same value either Perspective Grid is displayed or not.

 

Test Code

var _x1 = app.selection[0].left;

$.writeln("_x1 = " + _x1);

 

app.selection[0].left = 200; // set manually

 

var _x2 = app.selection[0].left;

$.writeln("_x2 = " + _x2);

 

app.selection[0].left = _x1; // revert to original value

 

var _x3 = app.selection[0].left;

$.writeln("_x3 = " + _x3);

 

Result with Perspective Grid is shown (I think bug)

_x1 = 214.392303466797

_x2 = 212.934600830078

_x3 = 213.081192016602

Note: It does not set to 200. Even original value cannot set again.

 

Result without Perspective Grid or hidden (expected behavior)

_x1 = 214.392303466797

_x2 = 200

_x3 = 214.392303466797

 

Thank you,

Naoki

If objects selected Then...

$
0
0

I have created a script where an image is traced and then I select objects that meet a certain color.  What I need is an If Then statement so if any PathItems (layers?), are selected the script will go in one direction, if no color was found thus no items selected then the script is to go in a different direction.  I do not need to know how many objects were selected just if any where selected.  This is where I am starting:

 

Dim docRef

docRef = App.ActiveDocument.selection

If docRef > 0 Then

     WScript.Echo "items where selected"  ' This will be replaced with additional script

Else

     WScript.Echo "no items were selected"   ' This will be replaced with additional script

 

Above in VBscript but I will take JavaScript if I can adapt it.  I did find a old post about deleting selected items and I was trying to adapt from that:

 

var docSelected = app.activeDocument.selection; 

for (j=0; j<docSelected.length; j++) 

    docSelected[j].remove();

Java Script code for browse and open AI file in Illustrator......

$
0
0

Hello Friends,

I am writing extension in HTML5 for Illustrator CC 2015.3's plugin.

so I want to browse  and open AI file only after click on  button Btn .

and after browsing  the path will appear in the textbox instead of art_filename  .

I am designing layout in html and I am using javascript for scripting .

So Please assist me for doing above task.

 

Thanks & Regards

Kundan

Script to make selection 100% Black?

$
0
0

This script question is basic.  How would i go about making a script that makes the selection Solid Black?  I think i could do this in Indesign but I'm finding that illustrator is not the same in scritping

Viewing all 3671 articles
Browse latest View live


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