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

an Illustrator error occurred: 1346458189 ('PARM')

$
0
0

Hello everyone,

 

I am trying to open some documents in Illustrator CS4 by javascript, walk through all layers including sublayers, doing something (for now just reading the layernames and showing them at an alert), closing the document and continue with the next document in the given folder until all documents in that folder are done.

 

By doing so I found an error I never have seen so far and I cant figure out where it comes from exactly to get rid of it.

The Error an Illustrator error occurred: 1346458189 ('PARM') appears randomly when cycling through the layers of the document but only every second document, so I guess there might be something wrong with closing a document and realeasing all references but I could not figure out what.

 

Maybe someone got an idea on this problem? Posting my sourcecode (just a simple test-code) below.

 

 

#target illustrator

 

var sourceFolderPath = "/e/TestAI";

var destinationFolderPath = "/e/TestZielverzeichnis";

var fileNameDefinition = "*.ai";

var sourceFolder = new Folder(sourceFolderPath);

var destinationFolder = new Folder(destinationFolderPath);

 

runCheckTool();

 

function runCheckTool() {

var contentInput = sourceFolder.getFiles(fileNameDefinition);

var fileRef;

var docRef;

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

fileRef = null;

docRef = null;

try {

fileRef = new File(contentInput[i]);

docRef = open(fileRef);

} catch(e) {

alert("# 1: " + e);

}

 

try{

checkLayers(docRef.layers);

} catch(e) {

alert("# 2: " + i + " " + e);

}

 

try {

docRef.close(SaveOptions.DONOTSAVECHANGES);

alert("end file index: " + i);

} catch(e) {

alert("#3: " + e);

}

}

}

 

function checkLayers(layerRef) {

var countLayers = layerRef.length;

for (var j = countLayers - 1; j >= 0; j--) {

if(layerRef[j].layers.length > 0) {

checkLayers(layerRef[j].layers);

}

alert ("Layer: " + layerRef[j].name);

}

}

 

 

Screenshot001.png


Resize Artboard

$
0
0
Unsure if Im asking in the right spot but is it possible to automate the resizing of the artboard say from A0 down to A1

Test whether a layer with a specific name exists?

$
0
0

Is there a simple way to test whether a layer with a specific name exists?

Can you have a eval a variable within an object in scriptui?

$
0
0

Is what I'm trying to do below possible? I want to loop through an array and create radio buttons and at least set whether they're enabled. I know my syntax is way off here, but just wondering if I can create radio1, radio2 and radio3 using variables or if I have to hardcode these. Plase note "radios.radio.eval(i).enabled" is a complete shot in the dark, and I've confirmed it doesn't work, but a lot of Adobe scripting is just closing your eyes and guessing.

 

radios = win.add ("group");    radios.radio1 = radios.add ("radiobutton", undefined, "Long");    radios.radio2 = radios.add ("radiobutton", undefined, "Short");    radios.radio3 = radios.add ("radiobutton", undefined, "Full");    for(i = 1; i<=3; i++) {    radios.radio.eval(i).enabled = false;}

Is there a way to script options for embed in extendscript?

$
0
0

I wrote a javascript to loop through images in a document, embed links and rasterize at a specific resolution. I am treating placedItems and rasterItems the same, and just using app.activeDocument.pageItems[0].rasterize(); which allows for options to be fed to it. RasterizeOptions has a property called "includeLayers" which does not function at all how it sounds like it functions, and always flattens linked files even if they have layers, which I don't think this method supports anyway. Even when true, if an image has opacity or a blending mode, the appearance rasterizes to it, which the manual mentions that this property should maintain these.

 

What I'm wondering is if there are properties and options I can feed to embed(). Currently, it just goes by the last used settings from the embed dialog, which in some cases I will want to flatten, but others, I will want to convert to layers. Is there an ability to do this through javaacript? I'm beginning to realize I need to learn how to use the SDK so that I can have a full range of functionality.

Is there a way to create a Static Symbol via scripting?

$
0
0

The addition of Dynamic symbols, has completely messed up my process when prepping files. Final step is normally to prep an asset as a symbol, in case effects or strokes are used on the item, preventing them from being scaled incorrectly due to settings, and preventing inadvertent editing. Now Illustrator has made it so that by default a Dynamic symbol is made, which works the exact opposite of this, and has even unclipped clipping masks for me. I looked in the scripting guide, but it doesn't look like you can specify this. Has anybody found an attribute that would allow this? Symbols may have just proven themselves useless due to this new attribute.

 

See below, an unexpanded path stays the same width when scaling up, where as with the static symbol, it gets scaled proportionately:

Screen Shot 2016-05-24 at 9.50.29 AM.png

Is there a way to include a variable in an #include path?

$
0
0

Below is my example that doesn't work. I have a lot of on local machine files for Illustrator, to have them appear in a menu, and I'm wondering if I am able to use a variable with #include since the path can be long. Is this possible?

 

scriptingPath = "/Volumes/work/_Resources/_Apps/adobe_scripts/";
#include scriptingPath + "delete_layers.jsx";

Is there a way to embed a javascript alert in Illustrator to run on open?

$
0
0

As the question states, I'm just wondering if it's possible to embed a javascript alert in an individual Illustrator file. I could see why it would not be based on security but I'm just trying to trigger an alert on open, similar to alerts you're able to create on the web.


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

Illustrator VBA scripting 101 - via Excel

$
0
0

This post will attempt to introduce newcomers to Illustrator Visual Basic Scripting (well, not actually vbs, but rather tru VBA, Visual Basic for Applications). I personally prefer vba over bvs for a number of reasons. First, I always have Excel and Illustrator open, so it makes sense for me use it to drive Ai. Second, I usually need to transfer data between the two programs. Third...I love the Excel IDE...ok, let's get right into it.

 

 

- Open Excel

- hit Alt+F11, to bring up the editor

- in the Tools menu, click on References...

- add a reference to "Adobe Illustrator CS5 Type Library"

- in the Personal.xls (or in any other book) add a Module. Personal is a global workbook that is always available. If you don't see it, go back to Excel and record a macro, anything will do. That will create the Personal file.

- and type the following in that module

- we have to continue the tradition and do the "HelloWorld" script

 

Sub helloWorld()    Dim iapp As New Illustrator.Application    Dim idoc As Illustrator.Document    Dim iframe As Illustrator.TextFrame       Set idoc = iapp.ActiveDocument    Set iframe = idoc.TextFrames.Add       iframe.Contents = "Hello World from Excel VBA!!"       Set iframe = Nothing    Set idoc = Nothing    Set iapp = Nothing
End Sub

 

- save Personal book

- open Illustrator and create a new document first

- to run, move the cursor anywhere inside the Sub...End Sub and hit F5

 

that's it for now...in the following posts we'll move the text to the middle of the page, create new documents, get data from an Excel Range to Illustrator, get data from Illustrator text frame to an Excel Range...and more, hopefully.

 

questions? comments?

add page numbers via script

$
0
0

I want to try to add page numbers to artboard based on position of selected text. I saw someone had made a script similar to this, but I need to do it based on selected text. Here is my solution, but for some reason it is not adding it based on artboard coordinates. I ran into this a while ago, and setting the rule to artboards fixed it, here it does not seem to have same effect.

 

#target illustrator
// global variables

////////////////////////////////////////////////////
// Set up varaibles
////////////////////////////////////////////////////


var pageNumber = app.activeDocument.artboards.getActiveArtboardIndex() + 1,
    doc = app.activeDocument;


//make sure only 1 item is selected
if(selectedItems.length > 1 || selectedItems.length < 1) {    alert('please select only one item'}
else {    var selectionTopPosition = doc.selection[0].top,        selectionLeftPosition = doc.selection[0].left;    doc.selection[0].remove();    doc.selection = null;    //remove selection    //alert(selectionLeftPosition+" "+selectionTopPosition);
}


//create page numbers layer
var pageNumbersLayer = doc.layers.add();
pageNumbersLayer.name = "page numbers";
var pageNumbersLayerGroup = pageNumbersLayer.groupItems.add();


// main loop
//loop through artboards
for(i = 0; i < app.activeDocument.artboards.length; i++){    app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;    doc.artboards.setActiveArtboardIndex(i);    alert('active artboard is '+i);    var pageNumber = doc.artboards.getActiveArtboardIndex() + 1;    var pageCount = i + 1;    var textRef = pageNumbersLayerGroup.textFrames.add();    textRef.contents = pageCount.toString();    textRef.top = selectionTopPosition;    textRef.left = selectionLeftPosition;    pageCount++;
}

Script that worked now giving a 1302 error

$
0
0

I am getting an error with a script i have used before without any problems.

 

The script updates the only image at the bottom of a single page PDF and saves the changed PDF in another folder.

 

It asks me to locate the folder of PDFs to be modified.
It asks me to locate the folder where the modified PDFs will be saved.
It asks me to select the new image that will be used.
It will then update the image and resizes it and save the PDF in the specified folder.

 

I don't get this error on all PDFs but i get it at least once every 10 PDFs  (and there are over a 1,000 PDFs).


The error i get is this:

 

Error 1302:No such element
Line:27
->      rip=
doc.rasterItems[0].position;

 

I get this error regardless of whether the script is run in CS3 or CS5.


Additional info.
I ran this script in CS3 and it worked. At a later date i ran another script on the folder of modified PDFs in CS5 that deleted any

unnessesary elements outside the artboard, it selected All on the Artboard - then inversed the selection - and deleted any selected items

followed by save and close.
I have tried making sure the "new" image has the same name as the image being replaced but this made no difference.

I am using Illustrator on Vista.

 

The script is below:

 

#target illustrator

 

function replaceImage() {

 

          var i, doc, fileList, inFolder, outFolder, opts, pic, rep, rip, saveFile, uIL;

 

          inFolder = Folder.selectDialog( 'Please choose your Folder of AI PDFs…' );

 

          outFolder = Folder.selectDialog( 'Please choose a Folder to save AI PDFs in…' );

 

          pic = File.openDialog( 'Please choose your replacement Image…' );

 

          if ( inFolder != null && outFolder  != null && pic != null ) {

 

                    fileList = inFolder.getFiles( /\.pdf$/i );

 

                    if ( fileList.length > 0 ) {

 

                              uIL = app.userInteractionLevel;

 

                              app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

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

 

                                        doc = app.open( fileList[i] );

 

                                        rip = doc.rasterItems[0].position;

 

                                        rep = doc.placedItems.add();

 

                                        rep.file = pic;

 

                                        rep.move( doc.rasterItems[0], ElementPlacement.PLACEBEFORE )

 

                                        rep.position = rip;

 

                                        rep.resize( 31.414, 31.414, true, true, true, true, 100, Transformation.TOPLEFT );

 

                                        doc.rasterItems[0].remove();

 

                                        rep.embed();

 

                                        opts = new PDFSaveOptions();

 

                                        opts.pDFPreset = '[Illustrator Default]';

 

                                        saveFile = File( outFolder + '/' + doc.name );

 

                                        doc.saveAs( saveFile, opts );

 

                                        doc.close( SaveOptions.DONOTSAVECHANGES );

 

                              };

 

                              app.userInteractionLevel = uIL;

 

                    } else {

 

                              alert( 'This Folder contained NO Illustrator PDF files?' );

 

                    };

 

          };

 

};

 

replaceImage();

Getting Page Count for a Multi-Page PDF file using Illustrator script?

$
0
0

Does anyone know how to get the page count of a multi page PDF file?  I know you can then open each page using the PDFFileOptions (pagetoopen).  But I need to know up front how many pages there are to loop thru to open each page and process each page.

 

Any Ideas?

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

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;

}


Calculer la surface d'un objet

$
0
0

Bonjour, comment faire pour calculer la surface d'un objet dans Illustrator cc 2015 ?
je possède un script conçu par Scriptomedia, qui permet de le faire mais le facteur d'échelle utilisé (ligne 11 > var ech = 30) me donne des résultats erronés.

Or, je travaille à échelle 1/150 dans les faits. Que dois-je faire ou modifier pour obtenir des résultats cohérents ? merci.


Le script ressemble à ceci :

-----------------

// surface6.js

/* Calcule la surface des traces selectionnes et effectue la somme

   en pt2 mm2 m2 et a echelle 1:1 variable ech facteur d'echelle defaut 30

   les variable ard... correspondent au nb de chiffres apres la virgule pour arrondi

   variable er ecart  en + et - pour lequel les mm2 sont arrondis au nombre entier

   affichage sur le plan de travail dans un nouveau calque*/

//INIT------------------------------------

var coulText = macmykColor(25,100,100,25);

var police ="Arial-ItalicMT";

var corps = 12;

var ech = 30;

var ardmm = 2;

var ardm = 6;

var ardp = 3;

var er = 0.1;

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

if (app.documents.length > 0) {

   var docRef = app.activeDocument;

       docRef.rulerOrigin = [0,0];

   var erreur = 0.05; // % erreur pour le test de surface du cercle

   var Version  = parseInt(version);

   if (parseInt(version) >= 12) {

   var point = UnitValue (1,"Pt");

   var mm = UnitValue (1,"mm");//alert(mm)

   var m = UnitValue (1,"m");

   var pouce = UnitValue (1,"in");

   } else {

      var mm = uniteMesure("mm");//alert(mm)

      var mm1 = uniteMesure("mm")*ech;//alert(mm)

      var pouce = uniteMesure("in");

      var pouce1 = uniteMesure("in")*ech;

      var point = uniteMesure("pt");

      var point1 = uniteMesure("pt")*ech;

      var m = mm*1000;

      var m1 = m*ech;

      }

   var iCount = textFonts.length;

   var numPolice = detectPolice (police,iCount);

   var p; //compteurs

   var aire, smm, spouce, total = 0;

   var liste = initliste();

   var propObjets = new Array();

   var pathes = new Array();

   var selectedItems = selection;

   extractPathes(selectedItems,pathes);

   var endIndex = pathes.length;

   var ObjetName, aire, rayonNul;

       if (endIndex > 0) {

       nouveauLayer = docRef.layers.add();

       nouveauLayer.name = nomLayer("Aire");

         for (p = 0; p < endIndex; p++) {

         rayonNul = false;

           if (propObjet(pathes[p],propObjets)) { //cercle

           aire = propObjets[2][1];

           }

           else aire = propObjets[2][0];

         pointText1(propObjets[0][0],propObjets[0][1],"p "+p,corps,numPolice,coulText);

         Sm   = getArrondi(aire/Math.pow(point*m,2),ardm);

         Sm1  = getArrondi(Sm*ech,ardm);

         Smm  = proche(getArrondi(aire/Math.pow(point*mm,2),ardmm),er);

         Smm1 = proche(getArrondi(Smm*ech,ardmm),er*ech);

         Spouce = getArrondi(aire/Math.pow(point*pouce,2),ardp);

           if (rayonNul) ObjetName = "point isole";

           else {

           ObjetName = pathes[p].name;

           if (ObjetName != "")  ObjetName = ObjetName;

           else ObjetName = "Sans nom";

           }

         liste[0] += p+"\tSurface = "+getArrondi(aire,2)+"\r";

         liste[1] += Smm+"\r";

         liste[2] += Smm1+"\r";

         liste[3] += Sm+"\r";

         liste[4] += Sm1+"\r";

         liste[5] += ObjetName+"\r";

         total += aire;

         }

         afficheTab(20,corps*1.3*(p+6),liste);

             if (endIndex  != 1) {

             Sm   = getArrondi(total/Math.pow(point*m,2),ardm);

             Sm1  = getArrondi(Sm*ech,ardm);

             Smm  = proche(getArrondi(total/Math.pow(point*mm,2),ardmm),er);

             Smm1 = proche(getArrondi(Smm*ech,ardmm),er*ech);

             pointText1(20,corps*1.3*3,"Facteur d'Èchelle "+ech+"\rSurface totale   = "+getArrondi(total,2)+

             " pt2\t\tou "+Smm+" mm2\t\tou  "+Sm+" m2",corps,numPolice,coulText);

             pointText1(20,corps*1.3,"Surface ech 1:1 = "+getArrondi(total*ech,2)+

             " pt2\t\tou "+Smm1+" mm2\t\tou  "+Sm1+" m2",corps,numPolice,coulText);

             }

       } else alert("Au revoir, 1 selection est obligatoire","De Elleere");

} else alert("Pour l'execution de ce sript un document doit etre ouvert !","Script Alerte de Elleere !");

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

function proche(v,e)

{

var ar = Math.round(v);

if (Math.abs(v-ar) <= e) return ar;

return v;

}

function afficheTab(x,y,tab)

{

  var dec = 20, gout = 40;

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

         pointText1(x,y,tab[i],corps,numPolice,coulText);

         var geo = [docRef.pageItems[0].geometricBounds];

         x += geo[0][2]-geo[0][0]+gout;

     }

}

function initliste() {

   return ["Objet de Rang\tpt2\r\r", " mm2\r\r", " 1:1 mm2\r\r", " m2\r\r", " 1:1 m2\r\r", " de nom\r\r"];

}

function propObjet(objetSelect,Cxy)

{ //

  var p1x, p1y, p2x, p2y, surface, aire, marge;

  var largeur, hauteur, Cx, Cy;

  var geo = [objetSelect.geometricBounds];

  p1x = geo[0][0]; p1y = geo[0][1]; p2x = geo[0][2]; p2y = geo[0][3];

  largeur = p2x-p1x;

  hauteur = p1y-p2y;

  if (objetSelect.pathPoints.length <= 2) {

  surface = aire = 0;

  }

  else {

  surface = Math.abs(objetSelect.area);

  aire = Math.PI*Math.pow((largeur+hauteur)/2,2)/4;

  }

  marge = aire*erreur/100;

        if (largeur == 0 && hauteur == 0) rayonNul = true; // rayon nul, point isole

        Cx = (p1x+p2x)/2;

        Cy = (p1y+p2y)/2;

        Cxy[0] = [Cx,Cy];

        Cxy[1] = [largeur,hauteur];

        Cxy[2] = [surface,aire];

        if (surface < aire+marge && surface > aire-marge)

        { // Si l'objet au premier plan est un cercle

        return true;

        }

  return false

}

function detectPolice(chaine,iCount) {

    for (var i = 0; i < iCount; i++) {

           if (police == app.textFonts[i].name) {

           return i;

           }

    }

}

function extractPathes(s,tabs){

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

    if(s[i].typename == "PathItem" && !s[i].guides && !s[i].clipping){

      tabs.push(s[i]);

    } else if(s[i].typename == "GroupItem"){

      // Cherche les objets de types dans ce groupe, recursivement

      extractPathes(s[i].pageItems, tabs);

    } else if(s[i].typename == "CompoundPathItem"){

      // Cherche les objets de type PathItem dans ce tracÈ transparent, recursivement

      extractPathes(s[i].pathItems,tabs);

    }

  }

}

function getArrondi(nb,N)

{ //arrondi nb ‡ N chiffres aprËs la virgule

  return Math.round(Math.pow(10,N)*nb)/Math.pow(10,N);

}

function inv(chaine) // fonction recursive

{ // inverse une chaine

if (chaine.length < 2) return chaine

return inv(chaine.substring(1))+chaine.substr(0,1)

}

function macmykColor(c,m,j,k)

{ //cree une nouvelle couleur CMJN

  var cmykColor = new CMYKColor();

  cmykColor.cyan = c;

  cmykColor.magenta = m;

  cmykColor.yellow = j;

  cmykColor.black = k;

  return cmykColor;

}

function nomLayer(nomLayer)

{ // Empeche les noms identiques, retourne le nom suivi d'un indice

      var nom, tnoms = new Array(), exist = false, indice = 0;

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

           nom = docRef.layers[k].name;

               if (nom.indexOf(nomLayer,0)!= -1) {

               tnoms[indice] = inv(nom);

               indice++;

               }

         }

      tnoms.sort();

      indice = 1; k = 0; nbExist = tnoms.length;

         while ((!exist || k < nbExist) && nbExist != 0) {

            if (parseInt(tnoms[k]) == indice || k > nbExist-1) {

            k = 0;

            indice ++;

            }

            else {

            k++;

            exist = true

            }

         }

      return nomLayer+" "+indice;

}

function pointText1(x,y,text,corps,font,maCouleur)

{// Cree un element de bloc de texte de point

    var pointText = docRef.textFrames.add();

    pointText.contents =text;

    pointText.spacing = 0;

    pointText.position = [x,y];

    if (font != undefined)

    pointText.textRange.characterAttributes.textFont = app.textFonts[font];

    pointText.textRange.characterAttributes.fillColor = maCouleur;

    pointText.textRange.characterAttributes.size = corps;

}

function uniteMesure(monUnite) { // pour la version  CS 11

var uniteMesure = new Array();

uniteMesure[0] = ["cm","in","mm","pc","pt","Q","px"];

uniteMesure[1] = [28.34645,72,2.834645,12,1,0,709,1];

  for (var i = 0; i < uniteMesure[0].length; i++)

   if (uniteMesure[0][i] == monUnite) {

    unite = uniteMesure[1][i];

    continue;

   }

   return unite;

}

How do I get rid of this invisible box?

$
0
0

When I use the "direct selection tool" (not the regular selection tool) to select the image, this box randomly shows up around it... It is making the script I wrote freak out. Basically, what I need to do is resize the image to a specific dimension by inches (constrained as well), but this random box around it is not helping....

 

For some images, I can ungroup and group again, then run my script and it will work, but overall I need something that will work for every file. I need to be able to write this in a script, so please let me know how to do this manually... without creating a whole new file. I left the "layers" box open, so you can see how the image is (terribly) organized. The problem is EVERY image is going to be different...so I need to figure out a way to just nuke that box. I've tried deleting certain objects, I just don't understand what it is.

 

2.jpg

1.jpg

Ai Packaging Script

$
0
0

Ok.. I'm sure this has been posted before (already searched, didn't find however), but does a file packaging script exist for AI? (one that collects all linked images and fonts and places them in one place) This would be IMMENSELY helpful to me if anyone can post a link to one or even be willing to write it.

 

OS: W7

AI Version: CS5

 

Thanks in advance!

JavaScript to prompt user to save as PDF

$
0
0

I am making changes with code to the file. I want the user to be prompted to save as a .ai file first. I have that down. Now I am wanting to have the user immediately be prompted to save as a pdf with only the optimize for fast web view option selected. I believe it is an adobe preset of Smallest File Size.

The reason for wanting the prompt is because I want to save the files in 2 different locations.

Here is my code so far.....

var doc = app.activeDocument;
// Save as .ai file 
var fileName = doc.fullName; 
var thisFile = new File(fileName);
var saveFile = thisFile.saveDlg();
doc.saveAs (saveFile);


// Save as .pdf file
var pdfSaveOptions = new PDFSaveOptions(); 
pdfSaveOptions.pDFXStandard=PDFXStandard.PDFXNONE; 
pdfSaveOptions.compatibility = PDFCompatibility.ACROBAT5; 
pdfSaveOptions.preserveEditability = false;  
var pdfFile = new File(fileName); 
doc.saveAs(pdfFile, pdfSaveOptions);

AI CS4 Windows 7 64bit

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

Viewing all 12845 articles
Browse latest View live


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