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

Custom scripts not working in Illustrator CC (2014)

$
0
0

A couple of custom scripts that are part of my workflow don't work in the new CC; MultiExporter.jsx and Sprite CSS Generator.jsx.

When I try to run either a titled modal window comes up as if the script is running but the actual window is only a couple of pixels tall and can't be re-sized;export-win.png

sprite-gen-win.png

 

They both worked fine in CC. My grasp of javascript is pretty basic but is there code that needs to be changed to update these to work with the current version?

Thanks!

Bob


Storing a persistent variable with scripting?

$
0
0

Hello --

 

is it possible to store the value of a variable via scripting after a script has been executed or does it only exist during runtime? The use case here would be to store a user entry between multiple executions of a script, e.g. the name of an artboard.

 

thanks in advance,

patrick.

Position objects on path

$
0
0

HI

Is there any way to find a specific point on a curved path, that is not an anchor point?

I want to position an object on a path, but I need to know the Y of any given X on that path.

 

Thanks

 

Math

Working on a script that will add a new artboard and delete the old one if it is not a specific size

$
0
0

var docRef = app.activeDocument;

app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM; 

 

var ab = docRef.artboards[0];

 

if ((((ab.artboardRect[2] - ab.artboardRect[0]) / 72) == 17) && (((ab.artboardRect[1] - ab.artboardRect[3]) / 72) == 20)) {

// do nothing

}

                 

else {

 

docRef.artboards.add( [575,1601.78,1799,161.78] );   

docRef.artboards.remove(0);

 

var abIdx = docRef.artboards.getActiveArtboardIndex(); 

var actAbBds = docRef.artboards[abIdx].artboardRect;

}

 

I want to say it works about 90% of the time. I have no idea why it doesn't always work, sometimes it will build the other artboard even though it is the correct size and I have no idea why. It is very frustrating haha. If anyone has an idea why it won't always work, please let me know. Thanks in advance!

Break link to symbol

$
0
0

If I right click on a symbol instance, I get a menu item, "Break link to symbol."  How can I do that same thing in Javascript?

 

1) That is, how do I use Javascript to break the link between a SymbolItem and the Symbol it represents? (i.e. without deleting the Symbol?)

 

2) Once the link is broken, how do I locate the Layer that was created when the link was broken?  That is, once the link is broken, it is no longer a SymbolItem; it becomes a Layer instead.  How do I locate that Layer?

 

3) How do I convert the Layer to a GroupItem?

Extracting data from Excel To Illustrator javascript or vbscript

$
0
0

Hi all-

I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that.  What I would like to do is pretty much the opposite:

 

1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.

2. Run script(VBSCRIPT,Javascript, doesn't matter)

3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.

4, Save each to a PDF file and name file with text from Excel Column1(Filename)

 

In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI. I hoped I explained this well enough without causing too much confusion. Thanks in advance.

 

FilenameReplacement Text

test1.pdf

DWG01
test2.pdfDWG02
test3.pdfDWG03
test4.pdfDWG04

AI_Ex..PNGAI_Ex2.PNG

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

Reset Zero Point? Illustrator CS3 JS

$
0
0

Hi, I am looking for a way to reset the zero point to always be the top left corner of the document, but can not seem to find any documentation or preferences to do this. Can anyone help?


how to change the document color mode(RGB to CMYK)?

$
0
0

Kindly advice me how to change the document color mode(RGB to CMYK) via scripting in "illustrator cs3".

 

Thanks.

need script to export text from multiple illustrator files to txt files

$
0
0

Hello.

 

I can do the following manually:

 

open an illustrator file (cs4, pc, windows xp); go to file, export, export text to a file with the same name as the illustration file (with the txt extension).

 

that results is a text file with all the call outs from my illustration in one text file. great.

 

however, i have hundreds of illustration files. I need to extract out the text for each file and save to text files for each. (as an aside, I wouldn't mind an option that would append text within one txt file; that is, allow me to list the source file "Illustration 201.ai; c/drawings... " followed by lines of text; followed by the next file name... followed by the next lines of text... etc.)

 

Does anyone know of a script that will do this in a batch mode?

 

Thanks in advance

 

RP

Trigger Save As... dialog with Javascript?

$
0
0

I have a script that makes some significant changes to an Illustrator file and would like to have a "Save As..." dialog pop up at the end of the script to give the user a chance to save the changes in a location of their choosing.

 

I know how to trigger a Save As dialog box with AppleScript using GUI scripting, is there a way of doing this with Javascript?

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

[JS] CS6+ executeMenuCommand

$
0
0

Hello together,

 

since CS6+ there is possible to

executeMenuCommand (menuCommandString: string)

Executes a menu command using the menu shortcut string.

 

Question 1:

Who knows a way to read all the available commands?

 

Question 2:

At the time I need 'Clear Guides'

 

app.executeMenuCommand ('Clear Guides')

app.executeMenuCommand ('Clear guides')

app.executeMenuCommand ('clear Guides')

app.executeMenuCommand ('ClearGuides')

app.executeMenuCommand ('clear guides')

 

and other variants doesn't work.

 

Who know the right syntax? (Or is this menu command not available????)

 

 

Any help is appreciated. (Additional: I know the way to use app.doScript (myAction) - but this is not part of my questions)

applying a swatch to a pathitem

$
0
0

I am trying to apply a swatch to all pathItems on a certain layer. I have the code written to access the layer I want but I am not sure how to apply a specific swatch name to the pathItems on the layer that I want. In my code if the pathItem is on a layer named "651(Highways)" I want the swatch in my document labeled "651 (Blue Gray)" to be applied to all those pathItems.

Anyone help me out with that? I am sure it is simple but I have never done it before and not much luck Google'n it.

Here is my code....

#target illustrator
var doc = app.activeDocument;
var allLayers = doc.layers;
var allLines = doc.pathItems;
var allSwatches = doc.swatches;


// CHECK TO SEE WHAT LAYER PATH ITEMS ARE ON
for (var i = allLines.length-1; i >= 0; i--){  if (allLines[i].layer == "[Layer Rails/Feather Bars]"){  allLines[i].filled = false;  lineFormat();  blackStroke();  allLines[i].strokeWidth = 2.0;  }  else if (allLines[i].layer == "[Layer 651 (Highways)]"){  lineFormat();  allLines[i].strokeWidth = 1.1;  }
else {  //alert("Found line on " + allLines[i].layer);  }
}
function lineFormat(){  allLines[i].filled = false;  allLines[i].strokeWidth = 1.6;  allLines[i].strokeJoin = StrokeJoin.MITERENDJOIN;  allLines[i].strokeCap = StrokeCap.BUTTENDCAP;  }
function blackStroke(){  var blackLine = new GrayColor();  blackLine.gray = 100;  allLines[i].stroked = true;  allLines[i].strokeColor = blackLine;  }

Moving items from a template file to active document

$
0
0

Hello Everyone,

 

What I am currently doing is I will leave a template file open and I will have to go to that file really quick and copy what I have selected in that file, go back to the file I am currently working on, then I will use an action that will paste it in the correct place. I was wondering if a script could copy what I have selected in my template file and paste it into my active file so I won't even have to leave my active file. Here is what I have so far.

 

var template = app.documents.getByName ("sig.ai");

 

var tempSelected = template.selection;

 

var docRef = app.activeDocument;

 

 

 

if ( tempSelected.length > 0 ) {

 

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

 

newItem = tempSelected[i].duplicate( docRef,

 

ElementPlacement.PLACEATEND );

 

}

 

}

 

else {

 

alert( "Please select one or more art objects in your temp file" );

 

}

 

It is not working, I just get the alert message, unless my template is my active file too, which does me no good. Not sure if this is possible to do I have trouble finding scripts that involve files other than the active file so I am not sure what all is capable. Thanks for taking the time to look at this for me I really appreciate it. I tried messing around with placing files but it is not editable enough for me to use.


Resource specification for a treeview

$
0
0

Hi

 

I can't seem to get a resource specification 'fully' working for creating a treeview UI control.  I can get the treeview control to show up but I haven't been able to get the list items to work.  Probably just haven't figured out the proper formatting for the resource spec.

 

This creates the treeview control okay,

 

pickFolder: Panel {text: 'Select Folder for New Drawing', orientation: 'column', alignment: 'left', \

  folderTV: TreeView {preferredSize: [470, 300]} \

} \

 

 

This does not work,

pickFolder: Panel {text: 'Select Folder for New Drawing', orientation: 'column', alignment: 'left', \

  folderTV: TreeView {preferredSize: [470, 300], \

   node1: Node {items: 'Projects'}\

  } \

} \

 

I am able to get list items to show up if I add them after the window is created (using the first sample above and the following),

node1 = newDwgDialog.pickFolder.folderTV.add("node", "Projects");

 

Of course I could just keep doing this, but I'd like to get the resource specification doing everything if I can.

 

Thanks for your help

Doug

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

Extract text from illustrator for translation then replace with translated text

$
0
0

I am trying to find a way to expedite translations of our drawings.  Each drawing has a series of callouts showing what that piece of the drawing is via text.  I would need to do 100's of drawings for each book.

 

Questions:

 

1. Can I write something to batch a folder and extract the name of the file, and the text from each textbox so that when I get the translation back, I can automate the reinsertion of the translated text to its correct field (i.e. TextField1 = "Translate this" then repopulate that same exact field with "Translation")?  In order to do this I would think each text field would have to be tagged with some unique identifier so that it would know which translation goes where in the drawing.  Keep in mind, I'm ok with manually tagging each textbox if necessary.

 

2. Assuming the above is possible, what would be the best program to write the extracted text to so that reading and writing the translated text back into the drawing is as easy as possible (i.e. Word, Excel, PDF)?

Altering a textframe that wasn't created through a variable by getByName

$
0
0

Hello all

Does anyone know how to alter a preexisting textframe within illustrator using extendscript. I can see how to do it after using ".add" and then referring to the variable and altering the contents, but I can't seem to find the answer to altering the contents of a textframe that wasn't created through the script:

I've come across "TextFrameItems.getByName," but I can seem to get it to work. Any help would be appreciated.

 

 

var doc = app.activeDocument;

  var Ref = doc.textFrames.add();

var myContent = Ref.contents = "blah";

UI (Window, dialog, palette etc) reference info for AI scripting

$
0
0

I'm looking for standard reference info on UI elements like popup windows (dialogs, palettes etc). I've been through the Illustrator CS6 Javascript Scripting reference guide and also the CS6 Scripting guide, checking every mention of the words "Window", "Dialog", "Palette" etc (there aren't many), plus related terms like "edittext" and "slider" (which seemingly don't exist in these documents at all), and can't find what I'm looking for.

 

----------

 

I'm trying to script a simple info box that contains information generated by a script that doesn't need to be closed before the user continues working.

 

All I'm trying to find out is the basics. From looking at other scripts I've figured out that you can create a popup box like this:

 

var box = new Window('dialog', 'Some title');

var panel = box.add(panel, undefined, 'Panel title');
panel.add('edittext', undefined, 'Default value');
panel.add('slider', undefined, /*Default numeric value*/,/*min*/,/*max*/);

var group = box.add(group, undefined, 'Group title');
group = area_len_box.add('group', undefined, 'Title (not displayed)');
group.orientation='row';
group.closeBtn = group.add('button',undefined, 'Close', {name:'close'});
group.closeBtn.onClick = function(){
  box.hide();  return false;
}

...which is enough for a very rudimentary input system, but one which has to be closed before the user can return to their work - and I can't find any resource that gives the full options:

 

  • What are the other options for 'new Window'? I'm aware of 'palette' which appears to need an array of four co-ordinates like [20,20,100,100], but it clearly needs something else too as every palette I've made instantly closes. And what else is there beyond Window and Palette?
  • What other input devices are there beyond edittext and slider, and what parameters do they each need?
  • What can go in the "undefined"s I see everywhere these are used?
  • etc etc

 

There must be a reference to this somewhere, but I can't find it.

Viewing all 12845 articles
Browse latest View live