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

Script to round fractional CMYK colours?

$
0
0

This script must exist but I'll be damned if I can find it!!!

 

I work in a large printing company and we get artwork from all over that has dodgy CMYK colours (quick convertions from RGB obviously). We have noticed that these colours don't rip as well as rounded CMYK colours, so we spend a lot of time cleaning them up and rounding them down...

 

I'd like to be able to just run a script that does this to a whole document, including the colours inside gradients. So if for example the number is .5 or below we round down, or above we round up.

 

Does this exist, does anyone know?

 

CHEERS!

S


Find a specific Sublayer and move to top level layer

$
0
0

I have a lot of illustrator files that are organized by a template size. The layers are setup so that the top level layer is always Template. However the sublayer I need to move to the top level could be called 42 Pg Border or 30 Pg Border or 24 Pg Border.

Is there a way for a script to search through the layers and if it finds "42 Pg Border" or "30 Pg Border" or "24 Pg Border" in the sublayer Template it would move it to the top level but if it doesn't see one of those it doesn't give an error?

 

I'm still new to scripting so the extent of my knowledge on this is to scan all the layers and unlock them. Then look for a specific layer name. It's the sublayer and moving it to the top level that I am not sure of.

 

Here is my current code:

var doc = app.activeDocument;
var allLayers = doc.layers;
for (var i = allLayers.length-1; i >= 0; i--){    allLayers[i].locked = false;    if (allLayers[i].name == "42 Pg Border" || allLayers[i].name == "30 Pg Border" || allLayers[i].name == "24 Pg Border") {        alert("I found the " + allLayers[i].name + " layer")    } else {        alert("Not the right layer")    }
}

 

Any help would be greatly appreciated!

I am using CS4 on a Windows 64 Bit PC with JavaScript

app.redraw()

$
0
0

I'm fairly new to Illustrator scripting, although I have had some experience scripting Photoshop and After Effects.

 

It seems that the app.redraw method is utilized for situations outside of intentionally facilitating a screen redraw.  More to the point it seems that it's utilized in many situations as a pseudo delay.  I've noticed that javascript seems to execute differently in Illustrator than Photoshop in that functions don't seem to execute in a linear fashion.

 

Currently, I'm working on a script that will facilitate copying path items from Illustrator into Photoshop as Smart Objects.  The issue I'm running into is that the following function seems to be executing before the previous function has finished.

 

var doc = app.activeDocument;

 

 

function targetIllustrator(){

#target illustrator

}

 

function targetPhotoshop(){

#target photoshop

}

 

 

///////////////////////////////////////////////////////////////////

//  Function Copy Layers.

//  Copies Layers sequentially from the active document in Illustrator.

 

function copyLayers(){

 

targetIllustrator();

 

var layerCount = doc.layers.length;

alert("My Layer Count is " + layerCount);

 

if(documents.length > 0) {

 

    if (layerCount >= 1) {

     

        for (var i =  layerCount-1; i >=0 ; i--) {

 

            var myLayer = doc.layers[i];

            alert("My Layer is " + myLayer);

            myLayer.hasSelectedArtwork = true;

            app.redraw();

            copy();

            app.redraw();

            }     

        }

    }

}

 

///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////

 

 

////////////////////////////////////////////////////////////////////////////////////////

//  Pastes a selected layer or PathItem from Illustrator into Photoshop as a ShapeLayer via ScriptListner.

 

 

function pasteShapeLayerToPhotoshop(){

 

targetPhotoshop();

 

var pDoc = app.activeDocument;

 

 

var idpast = charIDToTypeID( "past" );

    var desc3 = new ActionDescriptor();

    var idAntA = charIDToTypeID( "AntA" );

    desc3.putBoolean( idAntA, true );

    var idAs = charIDToTypeID( "As  " );

    var idsmartObject = stringIDToTypeID( "smartObject" );

    desc3.putClass( idAs, idsmartObject );

    var idFTcs = charIDToTypeID( "FTcs" );

    var idQCSt = charIDToTypeID( "QCSt" );

    var idQcsa = charIDToTypeID( "Qcsa" );

    desc3.putEnumerated( idFTcs, idQCSt, idQcsa );

    var idOfst = charIDToTypeID( "Ofst" );

        var desc4 = new ActionDescriptor();

        var idHrzn = charIDToTypeID( "Hrzn" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc4.putUnitDouble( idHrzn, idPxl, 0.000000 );

        var idVrtc = charIDToTypeID( "Vrtc" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc4.putUnitDouble( idVrtc, idPxl, 0.000000 );

    var idOfst = charIDToTypeID( "Ofst" );

    desc3.putObject( idOfst, idOfst, desc4 );

executeAction( idpast, desc3, DialogModes.NO );

 

 

}

 

//  Main

 

copyLayers();

app.redraw();

pasteShapeLayerToPhotoshop();

I put an alert in the copyLayers function which is the Illustrator portion of the script for the purpose of trouble shooting.  It baffles me that the alert is coming up in a Photoshop dialog.  I've never experienced anything like this before and I'm wondering what other methods are available to resolve the issue?

 

Any comments or suggestions would be appreciated.

 

TIA

ISO an expert to hire to write some custom scripts

$
0
0

Hi. I'm working on a project that requires some custom Illustrator scripts to improve workflow efficiency. If you're interested, please contact me and I'll send you a description of the scripts I need. Thanks!


Hal Rucker

hrucker@me.com

Is it possible, using javascript, to copy and rename an existing document? The copy I've managed, and resized the artboard to suit my intentions; but I think the .name property is read only. Do I have to wait until it's time to save it?

I am trying to set the settings when placing a PDF into Illustrator..

$
0
0

When I use the "Place..." option from the File menu I get prompted with a box to set the "Crop to" setting. From like "Art" or "Trim" etc.

When I place it with a script it is defaulting to "Art" right now and that isn't what I want.

Can I change this from a script?

Any help would be much appreciated!

Dialog in Illustrator CS4 js

$
0
0

Hi,

 

I have dialog script that I am using in InDesign to choose a pdf file to place into the document and I need exactly the same script in Illustrator, but  I have a hard  time to  translate it into Illustrator scripting format. I don't have much information about building dialogs in Illustrator. Could someone help me.

 

 

var myDialog = app.dialogs.add({name:"Holiday Templates",
canCancel:true});
with(myDialog){
//Add a dialog column.
with(dialogColumns.add()){

//Add a dialog column.
with(dialogColumns.add()){
   
    // Radius radio buttons //
    with(borderPanels.add()){
        staticTexts.add({staticLabel:"Choose Holiday Template:"});
        var myRadioButtonGroup = radiobuttonGroups.add();
        with(myRadioButtonGroup){
        var myEighthRadius = radiobuttonControls.add
        ({staticLabel:"4x6_flower", checkedState:true});
        var myQuaterRadius = radiobuttonControls.add
        ({staticLabel:"4x6_heart"});
        }
    }
}



    var myResult = myDialog.show();
    if(myResult == true){

var myFolderPath = myPath + "/~prepress/HolidayTemplatesFilePrep/";

        // Radio buttons readings //
        if(myRadioButtonGroup.selectedButton == 0){
        myTemplateA = File (myFolderPath + "/~4x6_flower.pdf");
        myTemplate2A = File (myFolderPath + "~4x6_flower_back.pdf");
        }
        else if(myRadioButtonGroup.selectedButton == 1){
        myTemplateA = File (myFolderPath + "/~4x6_heart.pdf");
        myTemplate2A = File (myFolderPath + "/~4x6_heart_back.pdf");
        }


        myDialog.destroy();
        myHolidayTemplates();
    }
    else{
        myDialog.destroy();
    }

}
}

 

Thank you very much for your help.

 

Yulia

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


VBA - Illustrator.Application not visible?

$
0
0

Hello World,

please help me. Searched the web for hours, but wasn't able to find anything about my problem...

 

I start Illustrator in Word-VBA. I use this code:

 

dim obj_AI as illustrator.application

set obj_AI = New illustrator.application

...

 

This did what it was supposed to do: If Illustrator was already runnig, it was captured in the object - if it wasn't running, Illustrator started - visible!

 

Two weeks ago this behavior suddenly changed!

 

Now, if illustrator isn't running the application gets not visible anymore. The object is created, the process in the task-manager is running, but I can't see the application on my screen (it doesn't show up in the taskbar either). Illustrator itself "thinks" it is visible - obj_AI.visible returns "True" - and the rest of the code works... 

 

I already tried set obj_AI = createobject(,"Illustrator.Application"), same result! Nothing to see on screen...

 

Does anyone know why the behavior suddenly changed? What can I do, to start Illustrator visible? (Shell("C:\...") is no option, because the path may be different on other machines...)

 

 

Greetings from BlackForest...

How to Export TIFF

$
0
0

Hi All,

 

How to export TIFF from Illustrator using Javascript. I could not find TIFF export type in Illustartor export type.

 

Regards,

Selvakumar

How to create Illustrator COM application Object in Invisible manner?

$
0
0

Hi,

 

I added CS6 COM reference in my VB.NET application and after that I have the following basic object creation in order to convert a eps file to svg. But for some reason when I create this COM object it is launching the Adobe Illustrator application. Why it is doing like this? It’s a simple COM object why it is interacting with Illustrator Editor?  Could you guide me how to take care this issue please?

 

 

Thanks

SG

Making all paths into a group without selection

$
0
0

I'm working on a script that will take every pathItem in a document and put it into a group (all pathItems in the document are groupless upon opening it, so there won't be other groups already in the document).

 

I have a script that creates a group, then puts the highest placed pathItem into the group. I just can't figure out how to have to grab all pathitems in the document, or loop this one action until everything is in a single group. Also the kicker is, as the title suggests this script has to work without selecting anything by hand first (in other words having to click something to select it). Now if there's was a way to select everything with a script that would be awesome.

 

Here's what I have so far:

 

 

#target Illustrator
//based on script from Carlos Canto
var doc = app.activeDocument

if ( app.documents.length > 0 ) {
doc = app.activeDocument;
newGroupItem = doc.activeLayer.groupItems.add();
}

var gi = doc.groupItems[0]; // the topmost existing group
var all = doc.pathItems[0]; // all paths in document

all.move (gi, ElementPlacement.PLACEATBEGINNING); // move selected path inside the group
all.evenodd = true; // necessary to determine "insideness" or to make holes.

 

I also have this that I found here on the forum

 

#target Illustrator
// GroupFromSel.jsx
// regards pixxxelschubser
if ( app.documents.length > 0 && app.activeDocument.selection.length > 0) {    var aDoc = app.activeDocument;    var Sel = aDoc.selection;    var GroupFromSel = aDoc.groupItems.add();    for ( i = Sel.length-1; i >= 0; i--) {        Sel[i].moveToBeginning( GroupFromSel )        }
}

 

But saddly it requires selecting so two scripts, two possible solutions. I'm just working on both until I can get one to work.

 

Any ideas?

Change color space

$
0
0

Hi!

 

Is there any wayto change adocumentscolor spaceonanalreadyopen document inVBS?

I have tried "AiDocumentColorSpace" but this seems to be a read only value!?

 

Please help!

 

/Tommy

All Group to Ungroup Script

How to hide the warning Dialog box in illustrator?

$
0
0
I need to open the pdf file in 'illustrator cs3' through visual basic coding and then save it as eps. But if i open the pdf file in illustrator some times 'warning dialog box' opened due to the font missing. I need to hide that warning dialog box while opening. Kindly help me.

Thanks,
Prabudass

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 );
}
}

Errors and more, my first illustrator script

$
0
0

First, I should mention that I started scripting for Photoshop about a month ago and have had some really motivating successes there. It led me to this one task we have that is just incredibly repetitive and boring in Illustrator that I want to script.

 

I haven't gotten all the pieces in here that I need so far, and any form of help would be greatly appreciated, whether just suggestion, or really whatever. I don't mind doing research and trying things out myself.

 

The purpose of this script is to open a template file we have on our network drive, ask for a folder with a collection of files (these are files provided to us that contain the info we need to make labels), place one, save with a specific name, and start over, placing the next file, till they are all on the template. We do this before we can create labels for our products. There are weeks when it has to be done 50+ times and that's pretty mind-numbing.

 

The steps I think I need are:

  • ask where the provided files are that need to be placed
  • open template file
  • make sure the folder chosen has the right type of stuff in it (PDFs)
  • place the first file at specified coordinates
  • embed the link
  • lock the embedded link
  • ask user to proof information on screen (ok to continue, cancel to stop and let user interact with file on their own) (95% of the time, there are no errors)
  • use the embedded link's name as the name of the file and save it to a specific network location
  • repeat until all the files in the chosen folder have been done

 

I've been lurking around here for a couple days, reading up on how Illustrator works with scripting and have broken off bits and pieces of different scripts to adapt for my purposes. So far, this is what I've come up with:

 

function getLabelRequests() {

     return Folder.selectDialog('Please select the folder containing label requests:', Folder('~/Desktop'));

     }

 

     function placeLabelRequests(selectedFolder) {

          var myDoc;

 

          if (selectedFolder) {

          var fileRef = File("/Volumes/myNetworkLocation/myTemplateFile.ai")

          open(fileRef);

          myDoc = app.activeDocument;

 

          var firstImageLayer = true;

          var thisPlacedItem;

 

          // create document list from files in selected folder

          var fileList = selectedFolder.getFiles();

 

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

          // open each document in file list

          if (fileList[i] instanceof File) {

          // get the file name

          var fName = fileList[i].name;

          // check for supported file formats

          if( (fName.indexOf(".pdf") == -1)) {

               // skip unsupported formats

               continue;

               } else {

                    // Give the file the name of the image file

                    File.name = fName.substring(0, fName.indexOf(".") );

 

                    // Place the label request on the artboard

                    thisPlacedItem = myDoc.layers['Job Form'].placedItems.add();

                    thisPlacedItem.file = fileList[i];

                    thisPlacedItem.position = [15,-45];

                    thisPlacedItem.embed();

                    }

               }

          }

     }

 

     if( firstImageLayer ) {

     // display error message

     alert("Sorry, but the designated folder does not contain any recognized image formats.\n\nPlease choose another folder.");

     myDoc.close();

     getLabelRequests (placeLabelRequests());

     }

 

     else {

     // display error message

     alert("Rerun the script and choose a folder with label requests, if you please.");

     }

}

 

// Start the script off

placeLabelRequests (getLabelRequests ());

 

 

So obviously there's no loop in there, which is one of my problems at this point. I know what each of these chunks of code do, but can't necessarily understand all the syntax. Particularly things like

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

I know it's saying that the variable i is zero, and while the list of files is greater than i, do whatever that last bit means, but I don't really know why it works or how it was constructed originally.

 

I haven't specified the save either, which might be why I'm running another of my problems, but I don't know how to get the name of the link to be the name of the file when it's saved. I also haven't given it a confirm to let the user proof either.

 

Here's my list of problems:

  • Running the script returns the image format error, even though the folder selected contains PDFs (I suppose I don't need to confirm the files are PDFs, that could just be incumbent upon the user)
  • Running the script places all the files into one iteration of the template (this may be because I haven't gotten the save or the loop in there, but I think it has more to do with the function being set up the way it is)
  • Obviously, it doesn't save with the link name as the file name
  • I don't seem to be able to figure out how to lock the link after it's embedded.

 

I also wonder if there's a way to, rather than opening-placing-saving-closing-repeat, to open-place-save, delete-placenext-save, delete-placenext-save.

 

Phew, sorry for the short novel.

 

Here is a copy of the template … or not. Can I not embed files in the post that aren't images?

 

Here's a JPG of the AI file that I use as a template

Label Job Form-5C-01.jpg

This document has two layers in this order normally:

Artwork

Job Form

 

 

And here are the blocks I'm using as placement for the information we are provided. These are taking the place of the files that need to be placed, and again, were PDF files, but I'm uploading as JPGs because I either don't know what I'm doing, or you can't upoad those file types.

PlaceMe.jpg

PlaceMe 2.jpg

PlaceMe 3.jpg

Find a specific Sublayer and move to top level layer

$
0
0

I have a lot of illustrator files that are organized by a template size. The layers are setup so that the top level layer is always Template. However the sublayer I need to move to the top level could be called 42 Pg Border or 30 Pg Border or 24 Pg Border.

Is there a way for a script to search through the layers and if it finds "42 Pg Border" or "30 Pg Border" or "24 Pg Border" in the sublayer Template it would move it to the top level but if it doesn't see one of those it doesn't give an error?

 

I'm still new to scripting so the extent of my knowledge on this is to scan all the layers and unlock them. Then look for a specific layer name. It's the sublayer and moving it to the top level that I am not sure of.

 

Here is my current code:

var doc = app.activeDocument;
var allLayers = doc.layers;
for (var i = allLayers.length-1; i >= 0; i--){    allLayers[i].locked = false;    if (allLayers[i].name == "42 Pg Border" || allLayers[i].name == "30 Pg Border" || allLayers[i].name == "24 Pg Border") {        alert("I found the " + allLayers[i].name + " layer")    } else {        alert("Not the right layer")    }
}

 

Any help would be greatly appreciated!

I am using CS4 on a Windows 64 Bit PC with JavaScript

How to make Applescript open AI then open file then run ExtendScript then close?

$
0
0

Here's the sample Applescript code I came up with using the scripting guide/reference for CS6 and also doing some online searches:

 

tell application "Adobe Illustrator"

    activate

    delay 10

    set pfilepath to "/Users/username/Documents/Temp/someFile.ai"

    set pfile to POSIX file pfilepath

    open pfile as alias without options

    delay 10

    do javascript "#include '/Users/username/Documents/Temp/someScript.jsx'"

    delay 1

    quit

end tell

 

I just want to open the app (sample here for AI but also nice to do same for Photoshop), open a file, then run ExtendScript file against it, then close after processing. With this sample script, all that works is the app launches. No file opened, no script ran, app doesn't close at end. I see no errors pop up nor anything show up in command prompt.

 

The sample ExtendScript just triggers an alert popup message for testing

 

Also to note, the Applescript snippet is executed from Python but I believe where/how it's executed shouldn't matter (except maybe where the error messages might show up). Although in worse case, I'll debug/run through the AppleScript editor.

 

Any tips on what's wrong here? Or does it look technically correct?

Running script from actions

$
0
0

I am using Illustrator CS4 on a Windows PC writing in JavaScript. I know I can't call an action via JavaScript in my version/language but I can load the script from an action. I call some scripts from my action set using the insert menu item in the action menu. However even if I save the actions with the scripts in the playlist Illustrator doesn't retain the scripts in the action set. Am I doing something wrong? Is there a work around?

Viewing all 12845 articles
Browse latest View live


Latest Images

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