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

How to delete specific layers?

$
0
0

Hi,

 

I have a large batch of files (100+) that all have the same layer structure. The top layer is called 'Guides', the next layer is called 'Object", the next layer is called 'Shadow' and it goes on down through another 5 layers. I'd like to create a script that will select delete certain layers (eg. 'Guides') before I save out a new file as part of an action. I'm coming from a background in Photoshop, where this could all be done in actions, but appears you can't select layers in Illustrator (please correct me if I'm wrong!).

 

Any help in creating a script would be most appreciated!

 

Dave


Scripting in touch workspace

$
0
0

Is JavaScript api available from touch workspace? My plan was to have a floating virtual keyboard from where I can trigger a shortcuts that runs different scripts.

Split a string into multiple lines based on length

$
0
0

I am allowing the user to input a description. What I am needing is to split up the string they input based on 27 characters.

 

So if their description is less than 27 characters....

It is a single string and needs to alert them of that.

 

If their description is more than 27 but less than 54 characters....

I need it to find the space closest to the 27th character, then split the string into 2 lines

 

If their description is more than 54 but less than 81 characters....

I need it to find the space closest to the 54th character, then split the string into 3 lines

 

If their description is more than 81 but less than 108 characters....

I need it to find the space closest to the 81st character, then split the string into 4 lines

 

If their description is more than 108 characters....

Alert that it is really long

 

Here is a section of code I am working with

 

                for (z = 0; z < theDocVariables.length; z++) {                    // Start finding variables here                    if (theDocVariables[z].name == "coverPageDecriptionLineOne") {                        if (getText(titleDescription).length < 27){                            alert("single line");                            }                        if (getText(titleDescription).length > 27 && getText(titleDescription).length < 54){                            alert("two line");                            }                        if (getText(titleDescription).length > 54 && getText(titleDescription).length < 81){                            alert("three line");                            }                        if (getText(titleDescription).length > 81 && getText(titleDescription).length < 108){                            alert("four line");                            }                        if (getText(titleDescription).length > 108){                            alert("that's a long freakin description");                            }                        alert("Your title is " + getText(titleDescription).length + " characters in it");                        }

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?

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

Script to select layer by name and change font

$
0
0

I'm trying to automate the conversion of some maps in Illustrator from one language to another. I already have a script that automatically replaces the English with my target language based on a word list (thanks to help here!), but I am having trouble figuring out how to select certain layers in the files and automatically change the font and font tracking on all text boxes in that layer.

 

I can't even get a script to select a layer by name...I'm not really experienced with scripting.

 

Can anyone point me in the right direction?

I have multiple layers with constant naming throughout (like "City Names" and "River Names") and I want to select each layer based on its name and then choose a font for everything on that layer as well as change the tracking to 0.

 

Thanks for any help you can give.

Select Layer by Name (with or without objects)?

$
0
0

I appropriated a script from this thread (thank you, pixxxel schubser).

 

It works as long as "myLayer" contains object(s) (even if they are locked and hidden). How can I change it to select the layer whether it has artwork or not?

I tried setting "hasSelectedArtwork" to "false", but no cigar.

 

var aDoc = app.activeDocument;  aDoc.selection = null;  try {      // be sure that top level layer with name "FINGERPRINT" with sublayer with name "Fingerprints" exists      var myLayer = aDoc.layers.getByName('FINGERPRINT').layers.getByName('Fingerprints');      myLayer.hasSelectedArtwork = true;      }  catch (e) {      alert("the layer doesn't exist");      // do whatever you want      } 

 

Here's a sample file. The script will select "Fingerprints" layer unless the layer is empty.

 

Dropbox - Sample.ai

How do I include DOM references to other apps in the same .jsx without returning failure?

$
0
0

Hey guys, say I have a single panel I want to use for both Illustrator and Photoshop. In JavaScript I can use csInterface to find the host application then route through a conditional to do app-specific actions, I figured I could just evalScript to different app-specific functions in doing so -- but I've noticed that having separate DOM references within my .jsx will cause the entire .jsx to fail. If I have a script that works perfectly in Photoshop but add something like app.isFill() anywhere in that .jsx, it returns Extendscript Fail -- even if I don't initiate it on auto-execute and try to put it in a conditional like `if (app.name === 'Adobe Illustrator'){alert (app.isFill());};`.

 

Is there a way to sneak cross-application DOM references in the same script? If not, then what would I need to do here?


Are there opposites of app.doScript() or $.evalFile() to delete from memory?

$
0
0

Hey guys, I'm making a panel that uses the CodeMirror library to act like a pocket IDE / native text editor for scripting, that can 'load' (by writing to a .jsx file which is immediately $.evalFile'd) snippets of jsx and transfer any error messages between:

 

PW_A1.gif

PW_A2.gif

 

This works really well and I like the idea of these independent "notesnippets" to work with in a sandbox, but I'm not sure how I would edit or delete them after using $.evalFile on these snippets. Since I write to a file then $.evalFile(), I don't know how to do the opposite -- say I want to edit the snippet's contents then reload them so their values are updated, I notice that the original values still remain even if I:

     1) Rewrite the contents of the file then $.evalFile() it again

     2) Delete the file, then write and eval or doScript() it.

     3) Try uneval() (which I'm sure isn't for this purpose, but I can't find any explanations of it's use and hardly any examples online, of which I don't understand the context of)

 

So I imagine that using $.evalFile() is returning a new instance while the original instance is still being evaluated without regard to the referenced file's current contents? Can I delete a $.evalFile()'s results from memory in order to clear it without refreshing the extension, which would allow me to subsequently write new values in with a new $.evalFile() using variables or functions with the same name? Overwrite, modify or delete them?

ai script to flip path Text

$
0
0

Can a script flip text on a path?

 

With menus it would be Type > Type on a Path > Type on a Path Options > Flip  How to create type on a path in Illustrator

 

The closest I can see a script getting to it is using app.executeMenuCommand('textpathtypeOptions') but with thousands of text to flip on circles I'm looking for something more automatic.

 

A script to put text on a path is easy enough thanks to Muppet Mark: https://forums.adobe.com/thread/983212, but what should the last line to flip it be?

 

#target illustrator 

 

var doc = app.activeDocument; 

 

doc.defaultFilled = false, doc.defaultStroked = true; 

 

var textPath = doc.pathItems.ellipse( 0, 0, doc.width /2 , doc.height /2 ); 

 

textPath.pathPoints[3].selected = PathPointSelection.ANCHORPOINT; 

 

app.cut(); 

 

doc.selection = null; 

 

app.redraw(); 

 

var tp = doc.textFrames.pathText( doc.pathItems[0], 0, 0, TextOrientation.HORIZONTAL ); 

 

tp.textRange.characterAttributes.size = 20; 

 

tp.contents = 'Please flip me'; 

 

tp.textRange.paragraphAttributes.justification = Justification.CENTER;

 

// tp.flip  // what should this line be??

 

Thanks!

Can I get rid of this error?

$
0
0

I have a simple script. I am removing all artboards in the document from back to front. I get an error when running the script - but after the error, my script runs as planned ( all artboards are removed, except for artboard 1). Any way to remove this error, or write the script a little bit cleaner? Thanks!

 

var myDoc = app.activeDocument;

 

for (i=myDoc.artboards.length +1; i > myDoc.artboards.length; i--) {

    activeDocument.artboards[i-2].remove();

    }

Calling functions from UI palette

$
0
0

Hello,

From what I understand, you can't call complex functions from a scripted UI palette, only from "dialog" windows (which are usless in my case) because I need the persistance of a palette.

 

I have a series of scripts in use now that are  accessed from the usual "file-scripts folder" within Illustrator itself (about 27 of them).  I want to script a palette window so users can acces them without the usual mouse clicks down the menu system.

 

I'm able to call a simple "Hello World" type function using the "onClick()" method from a button of a scripted palette window, but I cannot use my regular working scripts inside a function that's called from the button.  In X-Code, I was able to write my scripts individually, then just add them to a main floating window via a separate function when they were completed.  But, I'm finding Javascript a little more tricky.

 

If I copy my other's script code into the function in the palette window script, it runs, but it runs before I click the button! --  After in runs, then the palette window is displayed(?).  If I try to use the execute() method with "onClick", the script just opens in the SDK, it will not and does run in Illustrator.

 

I take both of these as clear indications that I have no clue what I'm doing (or that I'm trying to do the impossible).

 

I did find someone with a similar problem, but they were scripting After Effects and were offered this solution:

 

system.callSystem ('afterfx -r "/C/Program Files/Adobe/Adobe After Effects CS3/Support Files/Scripts/GlobalVars.jsx"');

 

 

Is there anything I can do in Illustrator that will allow me to call (or execute) my other scripts/functions and have them execute within Illustrator?

 

Thanks for any and all help!

Export multiple ARTBOARDS to multiple JPGs (AppleScript)

$
0
0

I´m aware that Illustrator doesn´t have multiple artboards options for JPG as it does with eps, or other formats, but is there any workaround for this??

Looping current artboard and exporting them to JPG or something. 

Or maybe there is someway to force the   "save multiple artboards:true" in JPG??

 

 

exportdocumentcurrentDoctofileexportFolderasJPEGwith options¬

                                                  {class:JPEG export options¬

                                                            , quality:100 ¬

                                                            , artboard clipping:true¬

                                                            , artboard range:1 - 2 ¬

                                                            , save multiple artboards:true}

Is there a way to ungroup and skip group with appearances?

$
0
0

I'd like to ungroup all groups on a given layer, but skip those that have clipping masks, opacity masks, appearances, blending modes, effects etc. The goal for example  with this being to then be able to then run other scripts then be able to export page items to layers for photoshop export, and maintain the look of the graphic. The clipping attribute is easily accessible, as are opacity and blending but I'm not seeing any indication of opacity masks or at the very least appearances so I could skip the group. Are these attributes available? The quick draft of my script is:

lng = app.activeDocument.layers[0].pageItems.length;
lyr = app.activeDocument.layers[0];
for(i=lng-1; i>=0;i--){
if(lyr.pageItems[i].typename == "GroupItem"){    if(lyr.pageItems[i].clipped == true) continue;    app.activeDocument.selection = null;    lyr.pageItems[i].selected = true;    app.executeMenuCommand("ungroup");    i = app.activeDocument.layers[0].pageItems.length;
}
}


Is this possible to achieve with extendscript?

ACROBAT via BRIDGE TALK

$
0
0

Hi

 

Is there any way to open a file on ACROBAT via BRIDGETALK?


Resolution check in illustrator

$
0
0

How to check the raster image resolution in illustrator through script?

How to divide all textFrames in one-character-per-textFrame?

$
0
0

Hello:

 

How to divide all textFrames in one-character-per-textFrame?

 

Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".

 

Help, please.

Split Text into Layers

$
0
0

I was wondering if anyone is aware of a script that is able to do the same as this photoshop one http://www.agasyanc.ru/text-splitter, I would use that one in photoshop but its not working in CS6.

 

I  was hoping to find a script that will seperate the text into layers  ready for export to After Effects to be used in Kinetic Typography  pieces

 

thank you

Illustrator Scripts - Windows vs. Mac

$
0
0

Hi I have a question regarding compatibility beetween Windows and Mac scripts.

Does a script writen in Windows works in a Mac computer ?

and viceversa.

 

Thanks

 

Manuel

Expand stroke/create outline of multiple SVG

$
0
0

Hello everyone, I have more than a thousand SVG icons but unfortunately all SVG are in stroke like this image below:

Screenshot at Oct 16 14-17-34.png

and this one below is what I'm looking for:

Screenshot at Oct 16 14-18-04.png

I've tried Illustrator batch action with this step: Select - All on active artboard - Object - Expand - Save.

BUT I need to confirm (click OK) each time expand windows pop-up appear, and it's take a lot of times.

Screenshot at Oct 16 14-24-08.png

 

Is there any script to replace this action without clicking any pop-up window?

 

Thanks.

Viewing all 12845 articles
Browse latest View live


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