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

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?


Creating Multi-Page PDF from a Layerd Illustrator file (script)

$
0
0

Often times when designing a logo I create different versions and variable options on layers. This can result in several layers in one Illustrator file. Is there an easy way or an existing script that will allow me to (with one click) create a multi-page PDF consisting of all the layers within my .ai file? The current method is turning on each layer, performing a save-as (PDF), then turning off said layer and turning on the next layer and repeating the task and so-on-and-so-forth, etc … It becomes tedious and quite often I save over the previous version, forgetting to re-name it or forget to perform a save on a certain layer. Can anyone help with some advice? I have never written my own script before but am not opposed to trying, where do I begin?

Any help is appreciated.

Assigning Text Fields Variables via VBScript

$
0
0

I'm looking to complete the first challenge of my project of repopulating text fields with translated text automatically.  To do this I need to pull the text down from an Ai file.  However, each text field must be identifiable so that it can be recorded into an excel spreadsheet.  So the spreadsheet would essentially contain the following data:

 

Column 1

 

File Name + Text1(this being variable name)

 

Column 2

 

English text pulled from that variable text field

 

Column 3

 

Translated text

 

So I need to code a script to batch through a folder of Ai files and assign each text field in the drawing a unique identifier or variable, i.e. "Text1", "Text2", etc...

 

I know that I can convert a text field to dynamic flash text which allows me to manually name a field, however doing this through script is less obvious to me, any help would be apreciated!

 

Furthermore, if there is already a unique identifier on textfields by default that I can tap into, that would be nice as well.  Otherwise I'd like to write a script that in the beignning of the code it steps through the number of fields and assigns each a unique identifier, copies that identifier to a spreadsheet, then next to that, copies in the text from the field into the spreadsheet as well.

 

Thanks,

-Chris

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

How to embed multiple images

$
0
0

Hello!

 

I have been tying to figure out how I could easily embed multiple linked images easily. I have some 1000 .svg  images which have about 1-7 .tif images linked in to them. I now need to get those links embedded and becouse of the amount of images I'm hoping to make an action out of it. I have a script to embed single image in .svg but haven't have luck with multiple embeddings.

 

Any ideas?

Batching In Illustrator??

$
0
0

In PhotoShop CS3, you can select File/Automate/Batch, and run an Action on an entire folder.  I don't see that option in Illustrator CS3?  Is there a way to run an action on an entire folder?

 

I'm attempting to save many EPS images as PNG images, and would really like to retain "vector attributes" - is any of this possible???

 

Thanks for any help.

How can I batch a huge bunch of wmf to ai in multiple subfolders?

$
0
0

Hi,

 

I have a couple of thousand old cliparts in .wmf format that I have to convert to .ai.  What I need to do is simply open the .wmf, store it as .ai in exactly the same location.

 

Actions didn´t work because the files are in mutliple folders and subfolders. "Actions" keeped saving all the ai-files in the same folder. Which is kinda weird since this doesn´t happen when using the same action in PS.

 

Sure, there are some quality issues with converting wmf to ai - but for what we´re plannning the quality is sufficient.

 

CarlosCantos script at http://forums.adobe.com/message/5378444#5378444  looked like the thing to do. Loaded it in apple script,  patched the lines to open .wmf  and saved it in the Illustrator script folder, but all I got was a bunch of error messages, so I´m pretty clueless :-/ guess I´m not a script guy...

 

Any help is greatly appreciated

 

HF

Is there a collection of free commonly useful scripts?

$
0
0

I know about the various sample scripts, but does there exist a source of open and free scripts that are popular?


Select objects inside many artboards

$
0
0

Hi everybody !

 

After having searched on ALL topics existing in the world for days, I could not find an answer to my question. That is why,I need your help

 

I want to export specifics artboards ( not all ) in the same DXF file . In order to do that, it's necessary to select layers, pageItems and sublayers which are on each artboard that I want export. I know and already tried the function " selectObjectsOnActiveArtboard() ", it's perfect if you want to export one artboard but does no work for multiple artboards . I would like to know if there is anything that would work for multiple artboards.

 

Thank you very much for your answer and help !

 

Have a nice day,

 

Miyano

Resolution check in illustrator

$
0
0

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

Duplicate illustrator layer with scripts

$
0
0

Hey! I'm new to scripting, and I'm trying to find a solution to what should be such a simple problem.

 

I'm trying to duplicate a layer with a script, but as of now, it seems there's no an easy way. Somebody suggested that I should create an action that duplicates a layer, and then call that action from my code. But I can't seem to get an action to duplicate a layer, it just doesn't register it.

 

So, does anybody have an already working code for something like this, if not, can somebody point me in the right direction to code this myself?

Batch image processing

$
0
0

Hi: So, I'm looking for a way to automate the task of batch processing files located in different folders, opening, saving and closing them in the same location. (Please see the attached screen capture for the folder structure).

folders.png

These files are in the Illustrator format but do not include a PDF preview. This is why I must open them in Ai and save them again with the PDF preview. The tricky part is to drill into the different folders and saving them. There are hundreds of these files.

 

Someone has suggested that a script might help. I will appreciate any suggestions in the matter. Thanks in advanced.

 

Jose

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

Anti-aliasing Type Optimized/Art Optimized on PNG export

$
0
0

Hello there,

 

I'm modifying a javascript that makes an export of each layer contained in an Illustrator document and I want to specify the method used for anti-aliasing (either Type Optimized or Art Optimized). Similarly to the option under the "Image size" tab in the "Save for the Web" panel.

 

I didn't find any antiAliasingMethod property in the ExportOptionsPNG24 properties (only an antiAliasing property that accepts boolean). So I wonder if it is actually possible to do it through scripting?

 

Many thanks,

D

Saving PDF - Hi and Lo res - JSX

$
0
0

Hi all,

 

I've been trying to figure this out but to no avail. Basically I want to save a Hi and Lo res PDF of an ai file using a script. I've done some searching around on the forum and come across this script. The problem I have is that the 2 PDFs produced are both the same size. I want one to be compressed and one to be Hi res. Where am I going wrong? Below is the script I'm using.

 

#target illustrator

#targetengine "main"

 

for (x=0;x<app.documents.length;x++)

{

     var workingDoc = app.documents[x];

     var workingDocFile = workingDoc.fullName;

 

// populate these with your settings

     var lowResOpts = new PDFSaveOptions();

     lowResOpts.colorDownsampling = 150

     var lowResOpts = new PDFSaveOptions();

     lowResOpts.compressArt = true

     var highResOpts = new PDFSaveOptions();

 

     var lowResFile = new File(workingDocFile.toString().replace(".ai","_LR.pdf"));

     workingDoc.saveAs(lowResFile,lowResOpts);

 

     var highResFile = new File(workingDocFile.toString().replace(".ai","_HR.pdf"));

     workingDoc.saveAs(highResFile,highResOpts);

 

     workingDoc.close(SaveOptions.DONOTSAVECHANGES);

 

}

 

Thanks in advance!


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

List installed system Fonts

$
0
0

Hi,

 

is it possible to get a list of fonts installed in the system (win or mac)?

Illustrator Scripting Panel

$
0
0

Just thought I'd share an extension I've been tinkering with:

 

GitHub - majman/adobe-scripts-panel: Scripting Panel for Adobe Illustrator

 

It's a pretty simple panel that allows you to try snippets of code in the editor, list and run saved scripts from your local files, or even load and run scripts from the web.

 

Hope somebody finds it helpful. Feel free to fork the repo and send pull requests.

 

-Marshall

find and replace text in illustrator

$
0
0

Hi,

 

How to perform find and replace text in illustrator using javascript?

 

any predefined functions in illustrator like in indesign..

 

app.findTextPreferences.findWhat = "XXX"; 

app.changeTextPreferences.changeTo = "YYY"; 

app.activeDocument.changeText();

 

for now I have achieved find/replace by using iterating all textFrames and replace the contents

but it is not a better solution

 

pls help..

 

Thanks

Save multiple pdf problem...

$
0
0

Hello Everyone, i need some help here. I'm a JS noob and have no idea what i am doing. I managed to put a script together that is made of several scripts.
Everything works fine until the very end.
I need to export my ai. file to 3 pdf files named:
filename.pdf
filename_K.pdf (converted to outlines)

filename_P.pdf (converted to curves, without layers)

 

The  thing is that i can't find a way to export my third pdf without layers. Sometimes it does everything right, but sometimes it doesent.

 

 

 

Can someone help me with this?

 

Here my currents script:

 

#target illustrator 

function Filename(){ 

  var doc = app.activeDocument; 

  var parentPath = Folder(File(doc.fullName).parent); 

  var opts = new PDFSaveOptions();

  opts.pDFPreset = "Polpharma (cartons)"; 

  doc.saveAs(File(parentPath + "/"), opts); 

}; 

Filename();

 

 

#target illustrator 

 

function outlineDocText(  ) { 

 

          if ( app.documents.length == 0 ) return; 

   

  var docRef = app.activeDocument; 

   

          recurseLayers( docRef.layers ); 

   

}; 

 

outlineDocText();  

 

function recurseLayers( objArray ) { 

   

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

   

                    // Record previous value with conditional change 

                    var l = objArray[i].locked; 

                    if ( l ) objArray[i].locked = false; 

   

                    // Record previous value with conditional change 

                    var v = objArray[i].visible; 

                    if ( !v ) objArray[i].visible = true; 

   

                    outlineText( objArray[i].textFrames ); 

   

                    // Recurse the contained layer collection 

                    if ( objArray[i].layers.length > 0 ) { 

                              recurseLayers( objArray[i].layers ) 

                    } 

   

                    // Recurse the contained group collection 

                    if ( objArray[i].groupItems.length > 0 ) { 

                              recurseGroups( objArray[i].groupItems ) 

                    }  

   

                    // Return to previous values 

                    objArray[i].locked = l; 

                    objArray[i].visible = v; 

          } 

}; 

 

function recurseGroups( objArray ) { 

   

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

   

                    // Record previous value with conditional change 

                    var l = objArray[i].locked; 

                    if ( l ) objArray[i].locked = false; 

   

                    // Record previous value with conditional change 

                    var h = objArray[i].hidden; 

                    if ( h ) objArray[i].hidden = false; 

   

                    outlineText( objArray[i].textFrames ); 

   

                    // Recurse the contained group collection 

                    if ( objArray[i].groupItems.length > 0 ) { 

                              recurseGroups( objArray[i].groupItems ) 

                    }  

   

                    // Return to previous values 

                    objArray[i].locked = l; 

                    objArray[i].hidden = h; 

          } 

}; 

 

 

function outlineText( objArray ) { 

   

          // Reverse this loop as it brakes the indexing 

          for ( var i = objArray.length-1; i >= 0; i-- ) { 

   

                    // Record previous value with conditional change 

                    var l = objArray[i].locked; 

                    if ( l ) objArray[i].locked = false; 

   

                    // Record previous value with conditional change 

                    var h = objArray[i].hidden; 

                    if ( h ) objArray[i].hidden = false; 

   

                    var g = objArray[i].createOutline(  ); 

   

                    // Return new group to previous Text Frame values 

                    g.locked = l; 

                    g.hidden = h; 

   

          } 

 

}; 

 

 

#target illustrator 

function Filename_K(){ 

  var doc = app.activeDocument; 

  var parentPath = Folder(File(doc.fullName).parent); 

  var opts = new PDFSaveOptions();

  opts.pDFPreset = "Polpharma (cartons)";

  PDFSaveOptions.acrobatLayers = false;    

  doc.saveAs(File(parentPath + "/" + doc.name.replace(/\.\w+$/, "_K.pdf")), opts); 

}; 

Filename_K(); 

 

 

#target illustrator 

function Filename_P(){ 

  var doc = app.activeDocument; 

  var parentPath = Folder(File(doc.fullName).parent); 

  var opts = new PDFSaveOptions();

  opts.pDFPreset = "Polpharma (cartons)";

  doc.saveAs(File(parentPath + "/" + doc.name.replace("_K.pdf", "_P.pdf")), opts); 

}; 

Filename_P(); 

 

 

 

 

 

 

 

 

Thank you for your time!

Viewing all 12845 articles
Browse latest View live


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