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

assign text through java script

$
0
0

Hello All,

 

This question might have been asked earlier but i couldnt find a clear cut answer to this. So here goes. i am trying to localise an image across different languages and though it was best to use illustrator capabilities. For this purpose i wanted to create the image file and leave the test fields empty and make them dynamic. The idea is to then run a Javascript from illustrator that would essentially populate the dynamic text field from an external data source. However i am not able to manually create such text placeholder on the illustrator file which can later be accessed as a variable from the javascript. Any help would be greatly appreciated.

 

Note: I know this can be done by importing it to flash and then setting the variable using the actionscript but i was hoping to tackle the problem from the illustrator side itself

 

Thanks a ton


How do I get the position of the selected PathItem in pixels ?

$
0
0

Hi,

 

I have a simple problem, but can't seem to find my way around it:

 

I have PathItem and Illustrator points out that it is at position (781px,250px).

How can I get those values in jsx ?

 

I've noticed that the PathItem inherits the position property from PageItem, and position

is a point, but when I try prining the values, I get undefined:

 

$.writeln(app.activeDocument.selection[0].position.x);

 

If I leave out .x from the line above I get this printed in the console:

 

521,510

 

What are these values ? Are they x,y coordinates ? In what unit ? How can I convert to pixels ?

Why can I not access x,y/top,left properties (always get undefined) ?

 

I'm using Illustrator CS5.

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

[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)

Move paths to another layer VB-script

$
0
0

Hello.


This is my first post on this forum. I need help with making a script that selects all the paths in a document that has a certain line width, for example 3 pt, and move them to a specific layer.


Since my knowledge of javascript is limited I would like to have an example in vb script.


Thanks in advance


Tommy

Illustrator Timestamp

$
0
0

Is it possible to create a script for Illustrator that would "timestamp" the file when edits/changes have been made?

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)?

New to Illustrator scripting, looking to make a Compound Path from Existing Paths/Compound Paths

$
0
0

I am wondering how to select existing paths (normal paths and compound paths) and make a new compound path.  Google does nothing for me on this....

 

I have begun to understand the basics of targeting objects and doing some basic changes such as width, height, textFont, positioning and such...but the Scripting Guide is hard for me to wrap my head around as far as compound paths.

 

I am also having issues understanding the differences between object references that either do or don't have an "s" at the end. I assume there is some uniformity to why many object references have both. Could someone explain the reasoning?

 

Example

 

pathItem

pathItems

 

 

Thanks in advance!!

James


How to save illustrator file without save as dialog ?

$
0
0

I' trying to save a file using 

 

app.activeDocument.saveAs(savepath);

 

and i am doing it in a loop on multiple files, but every time it will just show save as window and i have to do it manually.
Any ideas how to ignore that save as window ?

Group from selection

$
0
0

Hi

 

I want to align all the contents to the artboards top-left position and resize it to the artboards width and height.

if i use this

activeDocument.selectObjectsOnActiveArtboard();
for (var i = 0; i < activeDocument.selection.length; i++) {          doc.selection[i].position = [0,0];
}

it aligns every single item seperatly.

 

So how do i make the whole artboard one single group and then align this particular group to the top-left corner and then ungrouping it again?

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!

Possible to round font size if in decimal with AppleScript?

$
0
0

Hi,

 

Is it possible to automate the rounding of font sizes if they are in decimal form? I have a few thousand files I have to prepare for upload and they can't have font sizes such as 8.214 which several do. With AppleScript would it be possible to identify and then round up or down such font sizes?

 

Thanks!

"width" and "height" attributes not included on svg export

$
0
0

Hello,

 

When exporting svg files through scripting, Illustrator CC includes the viewBox attribute in the <svg> tag – but not width and height. This makes display inconsistent and problematic in web browsers.

 

Is there a way to include width and height attributes when exporting from Illustrator CC? CS6 did it automatically.

Duplicate a layer with a new Name

$
0
0

I am writing a script that duplicates all layers in a document, but adds a new name (In this case, it's the original layer name with the words Hat at the end of it).

 

My script is pasted below and works fine (It's based onanother script I wrote).

 

I've just got a few questions:

 

1) I only want it to work on selected layers and not every layer in the document. How can I do this?

2) When the script is finished, it displyas the following error message:

 

Error 2: sourceDoc is undefined.

Line: 9

->                                with(sourceDoc) {

I don't understand this error, could someone explain it. Thanks!

 

 

Here is my code:

 

var myDoc = app.activeDocument; // returns the document object

var myLayers = myDoc.layers;

//Go through all layers of source document and copy artwork

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

          myLayers[i].hasSelectedArtwork = true;

};

 

 

with(sourceDoc) {

          var count = pageItems.length;

          for (var i = 0; i < count; i++) {

                    pageItems[i].selected = true;

          }

          redraw();

          copy();

          for (var i = 0; i < count; i++) {

                    pageItems[i].selected = false;

          }

 

 

          var title = myLayers[i].name;

          var title = title + "hat";

          newLayer = myDoc.layers.add();

          newLayer.name = title;

 

 

          //Paste into this new layer

          newLayer = app.paste();

 

 

}

Properties property example javascript in Adobe introduction to scripting doesn't work?

$
0
0

I'm completely new to scripting so I figured I'd start with the Adobe guide to scripting pdf.

On page 18 it gives examples of 3 ways to use properties. The first 2 work just fine, but the third just ignores the properties part even when I directly copy paste it.

This is the bit:

 

JS also provides a properties property, which allows you to define several values in one statement. You

enclose the entire group of values in curly braces ({}). Within the braces, you use a colon (:) to separate a

property name from its value, and separate property name/property value pairs using a comma (,).

 

var myDoc = app.documents.add()

var myLayer = myDoc.layers.add()

myLayer.properties = {name:"My New Layer", visible:false}

 

So I know for Photoshop you have to use ArtLayers, but even in Illustrator it just adds another layer without renaming or setting the visibility.

Anybody have any idea why it doesn't work?


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

Batch replace color without using swatch as source

$
0
0

I've searched these forums and the rest of the web trying to find a method to do this... Actions don't cut it (if Actions were able to record the "replace color" dialoge it would be fine) so I've turned to scripts, but I have almost no knowlege on this.

 

I checked out this thread:

http://forums.adobe.com/message/2588737

 

and it is very close, except that it assumes that there is a named swatch as the source color - which there isn't.

 

The script I tried was .JS

 

I'm trying to have the script run on a bunch of .eps files in a folder:

- Select object which has specified CMYK value (0,7,34,10)

- Replace fill color of the selected object with another CMYK value (5,19,36,0)

- Save over the existing .eps

- Close

- Make coffee (optional)

 

Also, any books you can recommend for learning this stuff? For a noob.

Sorting Layers

$
0
0

I have a map of the US that is broken down into counties.  Each state has its own layer and the counties are sublayers.  I am currently going through and naming all of the counties, but I need to be able to alphabetize them.  Is there a way to do this?

 

Thanks

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.

Cutting a circle

$
0
0

Hi all,

 

I need to make shapes like this based on a value for graph purposes - usually I would just create a cutting shape based on trig (this shape representing around 60%) and subtract it from the path - I have about 30 graphs to do and I need to base it on a variable, and I want to use script - I'm sure there must be a better way, and I'm hoping you guys have the answer.

 

Thanks in advance

 

Dave

cut.png

Viewing all 12845 articles
Browse latest View live


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