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

Iterate shapes and convert them to Compound Shapes

$
0
0

In order to keep shapes as shape layers in Photoshop when exporting from .ai to .psd, one has to convert all shapes to Compound Shapes.
At the moment, i'm using an action that converts the shape, then selects the shape above. Starting with the bottom shape, i have to click

the action for every shape.

 

Is there a way to make a script cycle through all shapes and groups, converting them to Compound Shapes?

At the end of the script, it would be nice to have it make an export of the file to .psd aswell.

 

I'm somewhat familiar to javascript, but i would really appreciate some guidelines in creating this.


"Isolation Mode" and Javascript.

$
0
0

Hi All,

 

Does anyone know of a way to get out of IsolationMode using Javascript?

 

I am trying to create a Duplicate of a Selection on a Tempory Layer.

The selection is often quickest to get to by Isolating.

Then running script.

 

I'm getting this error:

 

Error 9034: Cannot add a new layer as sibling to 'Isolation Mode' synthetic layer.

->  tempLayer = app.activeDocument.layers.add();

 

I also have this issue with another Script I use to Save Artwork.

If Isolation Mode is active when script is run, file is saved with non-isolated sections "Dimmed"

Would be nice to "Idiot Proof" the code a little more by getting out of Isolation mode if need be before saving.

 

Snippet of save code below:

saveName = new File(FilePathAndName);
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
app.activeDocument.saveAs( saveName, saveOpts );

 

Fingers Crossed there is a way to access "Isolation Mode" using Javascript.

Both scripts are too much for an action.

I can't run action from Javascript... can I? (boo)

and I realy don't want to go down the path of running JS from an Action, then calling VB to call a different action bla bla.

 

am using CS6 with CC coming soon...

 

Thanks in advance...

Is there a script available for arranging elements for optimal use of the printable area?

$
0
0

I'm starting a sticker printing business using Illustrator as my main layout and illustration too. I was wondering if there's a script available for automatically arranging a set of elements on a page so that they optimally take up the available space. I figured this would save me some on material costs.

 

If I were to create a script from scratch, can someone give me pointers? I'm a casual AI user but I have Javascript experience.

 

Thanks.

Draw graphic by using scripting

$
0
0

Let say I've build some logo & icon & legend that is going to be re-use over and over again. I am wondering if I can "translate" those graphic into code so that when I need them, I just run a script?

Is it possible to run program functions with javascript?

$
0
0

In a nutshell, I want to run clean up, but recording it to an action still makes me confirm it. This is a pain on batch items. I'm looking/creating a script that does the same thing as cleanup, but figured I'd ask if one can utilize program functionality with any sort of scripting.

Illustrator script to select multiple layers

$
0
0

I have about 74 layers in illustrator and i want to run a script to select combination of layers at a time.

 

For e.g. I want 5 layers to be selected and save them as one .jpg. Then say i need to select other 3 layers to save it as a seperate .jpg file. If i do it manually it comes upto 300,000 images.

 

I can create a csv file with all layers to be selected presented in a row. I need help with the command to select 4 or more layers at a time, say if i have layer1, layer2, layer3, layer4 then a command to select those 4 layers and save them as a .jpg file.

 

Any help will be greatly appreciated.

 

Thanks

 

H Patel

CEO

Data Entry India

Link to a web page from AI javascript?

$
0
0

I've written a script with a ScriptUI interface, which other people will be using. I'd like to include a 'help' button in the interface, which ideally would connect to a web page with more details. (The alternative is to create the 'help' window in javascript, but the web page already exists and it would be a shame not to use it.)

 

From what I've read, other Creative Suite programs may be able to connect to the web with javascript, but apparently not Illustrator. Can anyone please confirm this is so? Or better, point me towards a solution!

 

With thanks.

My Script works for exactly half of the group items I want it to act on, not sure exactly why.

$
0
0

var docRef = app.activeDocument;

 

var selectedObjects = docRef.selection;

 

 

if (selectedObjects.length > 1) {

 

 

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

var thisItem = selectedObjects[i];

 

 

thisItem.name = "RunPrep";

 

 

}

}

 

 

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

 

 

var thisItem1 = docRef.groupItems[i];

   

if(thisItem1.name == "RunPrep"){

 

 

var Layer2Move = docRef.layers.add();

 

 

Layer2Move.name = "Temp Layer";

 

 

var Layer2Move = docRef.layers.getByName ("Temp Layer"); 

 

 

thisItem1.moveToEnd(Layer2Move); 

   

var otherLayer = docRef.layers[1];

 

 

otherLayer.locked = true;

   

app.doScript ('PREP', 'SEP ACTIONS');

   

var poop = docRef.selection[0];

 

poop.name = "Prep has been run";

 

otherLayer.locked = false;

 

poop.moveToEnd(otherLayer);

 

Layer2Move.remove ();

 

}

}

 

 

 

 

So here is what is going on. My script will run a prep action. The prep action basically flattens the artwork. I am trying to do the prep action on each design I have selected individually so that it does not all get grouped together. It works exactly how I want it to......for exactly half of the selected objects no matter how many I have selected (or half +1 if it is an odd number).  Not sure why it only works for half haha but I am on the right track other than that. If anyone has an idea why that is happening, please let me know. Thanks in advance!!


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

How to call a swatch from the library

$
0
0

Hi,

 

I'm writing a script to create a new AI document with a restricted swatchbook. The designer is supposed to use only the swatches/inks provided by this script.

So far I was able to delete all current swatches and add a CMYK or RGB spotcolor swatch.

 

var inkt02 = app.activeDocument.spots.add();

inkt02.name = 'inkt 2';

inkt02.colorType = ColorModel.SPOT;

var kleur02 = new CMYKColor();

kleur02.black = 10;

kleur02.cyan = 80;

kleur02.magenta = 0;

kleur02.yellow = 90;

inkt02.color = kleur02;

var newSpotColor = new SpotColor();

newSpotColor = inkt02;

newSpotColor.tint = 100;

thePallet.addSpot(newSpotColor);

 

Often we will be dealing with Pantone colors. No need to define these, as they are inside AI already, right? But how to call them from the library?

 

I'm new to ExtendScript, but this forum (and google) helped me along nicely so far :-)  I don't have a concrete use case for this yet, but I decided on this exercise as a good way to learn about ExtendScript.

ScriptUI - bring palette to front on Mac

$
0
0

Howdy yall!  Please consider this:  on my Windows 7 home computer I am able to create UI progress bars and popup messages for my UI window and everything works just fine.  Now, I come to work on the Macintosh and they don't work so well.  In this question, I would like to learn if there is a technique to bring a palette to the front when one is created, such as for this progress bar example, on a Mac.  The palette appears deactivated and in back for me.  It is unseen most of the time because it appears in the center of the screen behind the window by default, and when I move my window we can see the palette but there is no progress bar going on.

 

As you can see in the screenshot, my main window is deactivated because I attempted to get the progress bar active by deactivating the main window, obviously not successful.  I also set the palette to active, which did not work.

 

And, as I have implied, on my home computer on Windows things appear just as expected with the progress bar working and palettes appearing in front and active.  Does anybody know what could be the issue?

 

Thank you!

 

Screen shot 2012-09-15 at 9.36.24 AM.png

Create a rectangle around object?

Move a Spot color to a layer

$
0
0

I am very new to this, but am excited to unlock the power of scripting Adobe products. I have search through the forum for a similar issue but couldn't quite find the answer. This is my problem:

 

I am trying to grab specific spot colors and move them to separate layers for our cutting software. In this case I am trying to grab "perimeter cut" and move it to a layer called "tc 1"

I get the following error when I try to run the script.

Screen Shot 2013-10-10 at 9.44.38 AM.png

 

 

#target Illustrator

 

 

var idoc = app.activeDocument;

var ipath = idoc.pathItems;

 

 

    if (ipath.typename == "SpotColor") {

        if (ipath.spot.name == "perimeter cut") {

                    ipath.move(tc 1, ElementPlacement.PLACEATBEGINNING).

                              }

                    }

Drawing a rectangle of exact size of the artboard?

$
0
0

Has anybody written a JS script to to draw a rectangle on an active document which would be exact size as the document's artboard?

I find it very inaccurate and cumbersome trying to draw such rectangle by hand.

 

Please let me know where such JS code can be found. I have not done any Illustrator scripting beyond the "Hello world".

 

Thanks

franK

Help with "Print to PDF" Script...

$
0
0

Hi All,

I'm a Web Designer and I would need help creating a Print to PDF Script...

Here's what I have:

 

// Illustrator Export Script

 

var difDocuments;
difDocuments = documents.length;
    for(i=0;i<difDocuments;i++) {
        var aDocument;
        aDocument = documents[i];
        var docName;
        docName = aDocument.name;
        var docPath;
        docPath = aDocument.path;
        var docPathStr = docPath.toString();
            if (docPathStr.length>1) {
                var documentPath;
                documentPath = aDocument.path + "/" + aDocument.name;
            }
            else {
                var documentPath;
                documentPath = "Z://Users//Fred//Chavi Files//Saved Exported PDF" + "/" + aDocument.name;
            }
        var printOpts;
        printOpts = new PDFSaveOptions();
        printOpts.printPreset = "Print As PDF";
       
        var fileToSave;
        fileToSave = new File(docPath + "/" + "Saved Flat PDF" + "/" + aDocument.name);
       
        aDocument.print(fileToSave,printOpts);
    }

 

So what I'm attempting to do is to make a Print to PDF script rather then a Save As PDF, since print as PDF takes half the space...

The settings would either be from a Print Preset or just by regular options...(if someone could make a list of the attributes and the "formatting" it'd be extremely appreciated...

Thanks,

Fred.


Anything similar to javascript's setInterval in ExtendScript?

$
0
0

I need a way to poll my server for new jobs for the illustrator script to work on every few hours.

I tried with $.sleep(), but that is blocking, I need a non-blocking way to do this.

Any advice?

 

Thanks!

Kashmira

Is it possible to run an action with a script using cs6 javascript

$
0
0

In the pdf for the scripting guide it says :

 

"A script can execute an action, but actions cannot execute scripts."

 

I am having trouble finding out how to do that, and I know a way to have an action execute a script so that part is false haha. But if anyone knows how to have a script execute an action it would be very helpful to me. Thanks in advance!

Importing Color to Swatch Library from Text File

$
0
0

Hi,

I have a large list of custom colors in Excel that has the color name and CMYK breakdown of each color. I'm looking for a way to import this information to create a custom Color Swatch Library. That will have the name of the color and the CMYK breakdown. So that I can easily use in Illustrator and Photoshop. Is there any way or application in doing this with out manually entering the information and creating a new library?

 

Thanks!

Dimension Illustrator CS6

$
0
0

Does anyone know of a script that will automatically put dimensions on rectangular shapes in Illustrator CS6?

Determining the index of selected items in a ListBox?

$
0
0

Hello,

I can't seem to figure out a simple/direct method to identify the index of the selected item in a list box.

I feel like I'm missing something, but I can't seem to figure which (if any) property returns an index number if you use it with the .onChange callback for a ListBox.

The following code accomplishes what I need but isn't particularly efficient or elegant and can get muddled if you introduce multiple lists to check.

Any suggestions to duplicate this same behavior with better code would be appreciated.

Thanks!

 

 

var res = "palette {text: 'Example List', properties:{resizeable:true}\

pnl: Panel{orientation: 'row',preferredSize: [400,600],\

list1: ListBox{preferredSize: [400,550], properties:{multiselect:true,numberOfColumns:2, showHeaders:true,columnTitles: ['List 1', 'Subitem 0']}},\

}}"

 

 

var win = new Window(res)

win.show()

for (i=0; i<10;i++) {

    var row = win.pnl.list1.add('item', "Same Entry")

    row.subItems[0].text = "Subitem "+i}

 

 

win.pnl.list1.onChange = function() {

     var tempArray = new Array()

     for (i=0; i<win.pnl.list1.items.length;i++) {

         if (win.pnl.list1.items[i].selected == true){tempArray.push(i)}

         }

    var selectedRow = win.pnl.list1.items[tempArray[0]].text

    var selectedRowSubitem = win.pnl.list1.items[tempArray[0]].subItems[0]

              alert("Selection: "+tempArray+"\n Displayed Contents:   "+selectedRow+"\t"+selectedRowSubitem)

            

     }

Viewing all 12845 articles
Browse latest View live


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