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

How can I improve the script performance?

$
0
0

Hi,

 

I wrote an application in VB.NET. This application is using Illustrator to import a drawing in DWG format. Then I change some colors and lines in different layers. Everything works fine! But it is very slow!

 

I use VB.NET language. For a test I wrote a small program to compare VB.NET with JavaScript. JavaScript is much faster!

VB.NET: 60 seconds
JavaScript: 5 secondes

 

Is there any solution to make my application faster?

Thumbnails in layers panel are removed.

 

Is it possible to switch off all screen refreshes in Illustrator?

 

Harald


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!

How to select open path objects not include no filled objects?

$
0
0

I use CS6.

I want to select open path objects, but not include no filled objects.

That means if these objects with open path and filled any color or gradient, I want to select them.

 

Now I can select objects with open path.

 

var doc = app.activeDocument;

doc.selection = null;

numClosed = 0;

for ( var i = 0; i < doc.pathItems.length; i++ )

{

    if ( ! doc.pathItems[i].closed )

    {

        doc.pathItems[i].selected = true;

        numClosed++;

    }

}

 

 

alert(numClosed + " paths open.");

 

 

 

But how to not include no filled shapes?

Anybody know?

Thank you.

Resize artboard to content - works in Mac (CS6), not Win (CC)

$
0
0

Hello!

This code works perfectly in Illustrator CS6 for Mac:

 

function resizeArtboard() {

            app.redraw();

            app.activeDocument.artboards[0].artboardRect = app.activeDocument.visibleBounds;

            app.redraw();

}

 

It works like the menu option "Shrink artboard to fit content".

 

However, running this script in Illustrator CC for Windows, the result is different: the content is enlarged to fit the artboard instead.

 

How can I solve this?

 

Thanks in advance!

 

/Måns

embed all fonts in eps

$
0
0

I have a lot of existing eps-files of which the option "embed all fonts" is unchecked.

Know I have to check the "embed all fonts" in the existing eps-files.

I tried to modify the script below, but it seems that the embedallfonts is NOT working.

 

When I do it manually (without script), then it works fine. With script, it doesn't work.

 

 

 

#target illustrator

 

// PART 1

var doc = app.activeDocument;

 

// PART 2 -> herbewaren eps als eps

var destFile = new File(decodeURI(doc.fullName).replace(/(?: \[Converted\])?\.eps$/, '.eps'));   // also remove "[Converted]" from filename

var options = new IllustratorSaveOptions({});   // new save as options

options.compatibility = Compatibility.ILLUSTRATOR15;   // save as CS5

options.embedICCProfile=true;

options.embedAllFonts=true;

options.pdfCompatible = true;

options.useCompression = true;

doc.saveAs(destFile,  options);  // save the file in the same foldere as the eps

 

// PART 3

doc.close(SaveOptions.SAVECHANGES);   // close the file with saving

 

 

Another question will be: can I get a dialog box to put in the path to the eps-files, I can do thereafter it in batch instead of each time opening and closing a file.

Is there an Illustrator script that exports multiple file formats at the same time?

$
0
0

I've found some very good scripts like the MultiExporter.js by Matthew Ericson and Export Layeres as PNG files by Johan Otterud, however none that quite fit our needs. We need an Illustrator script that takes an AI file and spits out an .eps, .jpg (for print), multiple .png sizes for web, and .pdf. We have an extensive download library for members that constantly change and rotate with new logos, print materials and other graphics.

 

I was hoping that there was some kind of script that would cut some time off of exporting all the different versions each time. If anyone knows where I should look, then please let me know. Thanks, Curtis

Shear / Skew using shear angle and axis angle

$
0
0

Hi,

 

I want to skew/shear the selected object using shear angle and axis angle.

 

I am using below code for shear the object,

 

var skewMatrix = app.getIdentityMatrix();

skewMatrix..mValueB = .5

 

But i dont know how to apply the axis angle with this matrix.

 

any hints?

Select an object in illustrator using extendscript

$
0
0

I have a drawn rectangle on an illustrator document. In the layers menu I have given it a specific path name (outerBox). I would like to select this item and return its particular properties eg height, width, colour etc. How would I do this.

 

Thanks

Bob


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

[JS][CS5] Clean way to unlock endless sublayers?

$
0
0

Hello,

 

I've written a snippet that will unlock sub of sub layers up to 10 layers deep. It works fine; however I'm wondering if there is a better way to do this? I don't know that 10 is the maximum of sub layers I'll need to unlock but it's a fairly safe guess. I'd like to be more efficient and know that no matter what the layer structure of the file my script has unlocked any and all sublayers.

 

Is there a different approach or way to think about this problem where you can script for a potentially endless number of sublayers, and subs of subs, etc.?

 

Thanks!

 

var doc = app.activeDocument;


var layerCount = doc.layers.length;
for (i=0; i<layerCount; i++) {    var currentLayerI = doc.layers[i];    var layerCountII = currentLayerI.layers.length;    for (ii=0; ii<layerCountII; ii++) {        var currentLayerII = currentLayerI.layers[ii];        var layerCountIII = currentLayerII.layers.length;        for (iii=0; iii<layerCountIII; iii++) {            var currentLayerIII = currentLayerII.layers[iii];            var layerCountIV = currentLayerIII.layers.length;            for (iv=0; iv<layerCountIV; iv++) {                var currentLayerIV = currentLayerIII.layers[iv];                var layerCountV = currentLayerIV.layers.length;                for (v=0; v<layerCountV; v++) {                    var currentLayerV = currentLayerIV.layers[v];                    var layerCountVI = currentLayerV.layers.length;                    for (vi=0; vi<layerCountVI; vi++){                        var currentLayerVI = currentLayerV.layers[vi];                        var layerCountVII = currentLayerVI.layers.length;                        for (vii=0; vii<layerCountVII; vii++) {                            var currentLayerVII = currentLayerVI.layers[vii];                            var layerCountVIII = currentLayerVII.layers.length;                            for (viii=0; viii<layerCountVIII; viii++) {                                var currentLayerVIII = currentLayerVII.layers[viii];                                var layerCountIX = currentLayerVIII.layers.length;                                for (ix=0; ix<layerCountIX; ix++) {                                    var currentLayerIX = currentLayerVIII.layers[ix];                                    var layerCountX = currentLayerIX.layers.length;                                    for (x=0; x<layerCountX; x++) {                                        var currentLayerX = currentLayerIX.layers[x];                                        if (currentLayerX.locked == true) {                                            currentLayerX.locked = false;                                            }                                        }                                    if (currentLayerIX.locked == true) {                                        currentLayerIX.locked = false;                                        }                                    }                                if (currentLayerVIII.locked == true) {                                    currentLayerVIII.locked = false;                                    }                                }                            if (currentLayerVII.locked == true) {                                currentLayerVII.locked = false;                                }                            }                        if (currentLayerVI.locked == true) {                            currentLayerVI.locked = false;                            }                        }                    if (currentLayerV.locked == true) {                        currentLayerV.locked = false;                        }                    }                if (currentLayerIV.locked == true) {                    currentLayerIV.locked = false;                    }                }            if (currentLayerIII.locked == true) {                currentLayerIII.locked = false;                }            }        if (currentLayerII.locked== true) {            currentLayerII.locked = false;            }        }    if (currentLayerI.locked == true) {        currentLayerI.locked = false;    }
}

How to rename a layer like filename (with an action)

$
0
0

Could anyone help me to rename a layer of illustrator like document file name? (with an action)

Thank you

Mauro

Illustrator Macros/Scripting

$
0
0
Hey guys is it possible to create macros in illustrator, or how would this be achieved via the scripting.

Basically i have a c# application that contains alot of pictureboxes all with images in them. i want to be able to right click an image and select vectorise. Which will send the image to illustrator live trace the image, resize it, then copy the resulting image back into my c# app.

How would this be best done

thanks
r

All Group to Ungroup Script

Creating spot color in Illustrator CS4 js

$
0
0

Hi,

 

I need to create spot color in Illustrator CS4 with js, with assigned name and color values. Here what I have:

 

myColor = myDoc.spots.add({name:"FOIL", colorValue:[10, 0, 100, 0]});

 

 

But it comes out as process instead of spot and the color is not assigned.

 

 

 

Thank you for your help.

Yulia

Script for Selecting Open Paths in Illustrator CS6

$
0
0

I have created this script for selecting open paths in illustrator cs6 as the graffix plugin is not working under CS6.

 

Just save the following text in /Applications/Adobe Illustrator CS6/Presets/en_US/Scripts/Select Open Paths.js

 

 

if (documents.length > 0 && activeDocument.pathItems.length > 0){
 
          var allPaths = activeDocument.pathItems;
          var allPathsCount = allPaths.length;
          var openPathsAreLocked = false;
          var lockedOpenPaths = 0;
          var locked = false;
          for (var i=0; i < allPathsCount; i++){
                    allPaths[ i ].selected = false;
 
                    if( ! allPaths[ i ].closed){
 
                              try{
                                        allPaths[ i ].selected = true;
                              } catch (e) {
                                        openPathsAreLocked = true;
                                        lockedOpenPaths++;
                              }
 
                    }
          }
          if (openPathsAreLocked) alert (lockedOpenPaths + " open paths are locked or hidden (or their layer is locked or hidden) and cannot be selected");
}

Please, can I with help of Javascript change spot color values? for example by my color VARNISH with c:0,m:10,y:15,k:0 to make change to c:0,m:0,y:0,k:0? thank you

$
0
0

Please, can I with help of Javascript change specific spot color values? for example, I have color named VARNISH with values c:0,m:10,y:15,k:0 and it would help me to make change to c:0,m:0,y:0,k:0 as a part of an action. Is it possible? Thank you

Script to move all text objects to another Layer

$
0
0

Hi ,

 

I need a script that moves all text objetcs to another layer.

The layer is already created, i managed to access the text objects.

 

How can i move them to a specific layer ?

 

Thanks

Audrey

 

for(var e = 0;e<doc.textFrames.length;e++){

    var frame =  doc.textFrames[e];

 

WRITE HERE HOW TO MOVE TO ANOTHER LAYER

            

       }

How can resize an image proportionally?

$
0
0

Hi all

 

I'm new to illustrator script and now I've a need that I've to resize the image proportionally through javascript. That is if I change the width it should reduce height proportionally.

 

thanks

Hakkim

Need Help Converting Appscript to Javascript

$
0
0

I tried my best converting Larry G. Schneider's "Delete Invisible Layers" script to Javascript, but to no avail.  Little help for us Windows folks? 

 

Here's a direct quote:

 

Here's a script that I have to delete hidden layers in a file. It could be reworked to target page items. Remember you can only delete something if it is visible.

 

--get a sourceFolder that holds the files to process
set sourceFolder to (choose folder with prompt "Choose a folder with files to process:") as text

 

-- get a list of files of the files to process in the sourceFolder
tell application "Finder" to set workingFiles to (every file of folder sourceFolder) as alias list

 


repeat with aFile in workingFiles
    tell application "Adobe Illustrator"
        open aFile
       
        set currentFile to front document
       
        tell application "Adobe Illustrator"
            set myLayers to every layer of currentFile
           
            repeat with i from 1 to count of items in myLayers
               
                set myLayer to item i of myLayers
                set locked of myLayer to false
               
                if visible of myLayer is true then
                    set visible of myLayer to false
                else if visible of myLayer is false then
                    set visible of myLayer to true
                end if
               
            end repeat
           
            delete (every layer of currentFile whose visible is true)
           
        end tell
       
        tell application "Adobe Illustrator"
           
            set visible of (every layer of currentFile) to true
           
        end tell
       
        close currentFile with saving
       
    end tell
end repeat

 

 

Thank you!

Looking for "Replace with Symbol" script

$
0
0

So I am trying to replace gps points with a symbol I have created. I have found blogs referencing a script that can replace selected items with symbols saved in the symbols panel, but I can't seem to find the actual script! If anyone knows where I can find JET_ReplaceWithSymbol.jsx or any other script that can do the same function, it would be greatly appreciated!

Viewing all 12845 articles
Browse latest View live


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