Quantcast
Viewing all 12845 articles
Browse latest View live

illustrator script to fill a layer and repeat

im very new to illustrator and i have not done scripting before, i have like a hundred illustrator files that i need to change the background color lets say background color is layer 5 for every file, can scripting make it like repeat changing the background color for all my files, i would really appreciate some help with how to start writing a script, thank you

 

Image may be NSFW.
Clik here to view.
Capture.PNG


JETalmage's Script Library

Hi -- just wondering if anyone knows what became of the great repository of AI scripts JET had posted on the web -- I have been using a modified version of his Label Script and went looking recently for his other ones, but all the links point to a site that is now under construction. Are they archived elsewhere? or is JET coming out with a commercial package (I'll be first in line to buy!)?

 

Thanks!

 

-g-

batch exporting mulitple ai files to jpeg (+ exporting artbords)

First, let me start by saying how awesome you guys are for being able to write scripts.

 

I have about 250 ai files, each with two artboards.

 

Is there anyway I can export the ai files to jpegs but also exporting each artboard into its own jpeg.

 

I hope that makes sense.

Here's an example.

 

When I open one of the illustrator files, there are two art boards. I  can go File>Export> and choose 'jpeg' then check 'use artboards' then hit export, I can achieve what I want. I would like to do this to all 250 ai files with a script.

 

appreciate any help on this!

Illustrator - Coumpound Path Bug in javascript

Hi,

 

We found that CompoundPath have a bug in every version of Illustrator, even the last one and apparently it was found by others before us but I did not find any ticket about it so here it is :

 

I attached the file with a working case and the compound path bug (LEFT object = BUG | RIGHT object = WORKING).

 

So in Adobe CEP with the javascript (extendscript API), I was parsing the pathItems inside the compoundPath and I was surprised that there was only 2 pathItems inside and it was looking like 3 different shapes. So for the 'ö' I deleted the two dots and retried and surprise the 'o' was still here on the Illustrator layer but there wasn't any pathItem inside this compoundPath!

 

It seems like this bug is an Illustrator bug that makes possible to put a group inside a CompoundPath and if you do that there is no way to have have access to all pathItems inside via the javascript API.

 

We see this bug as a major bug for us & cep / javascript scripting, so it will be great to have any feedback on this !

 

 

Reference to other people writing about it :

 

The only problem I think you may run into is the quirky way Illustrator allows Groups to be inside CompoundPaths. Crazy, right, because CompoundPathItem doesn't have a GroupItems or PageItems property, so you can't get them out using the above method. In fact, it may get stuck in an infinite loop if there's one like that!

https://forums.adobe.com/thread/1575232?start=0&tstart=0

 

Normally, creating a group of two paths wouldn't even be possible in Illustrator.

But if you create a group of one path, select this group and an other path, make a compoundPath of this selection, you get a group inside a compoundPath.

http://stackoverflow.com/a/26847856

 

A Compound Path Issue

Some scripts don't work for some part of compound paths. When this occurs, please select part of the compound path or release the compound path and select them, then run script again. I still have not figured out how to get properties from grouped paths inside a compound path.

http://shspage.com/aijs/en

fit frame to text (free script)

Wrote it but don't need it, so help yourselves…

 

/* fit_frame_to_text.js -- resize selected text frames to fit their current text content [Adobe Illustrator]

This script is released into the public domain. No warranty provided, E&OE, caveat emptor, etc.

Notes:

- Text frame must be rectangular area text, vertically aligned to avoid skewing when its path height changes.

- On success, fitFrame returns new height in points. If text frame is empty it is resized to 0 height.

- If text frame was point- or path-based, or not a text frame, fitFrame returns -1 to indicate it was ignored.

Caution:

- JSX scripts should use anonymous functions and local vars only whenever possible, as AI's shared JS interpreter gets increasingly fragile as globals are defined, eventually resulting in JS (and AS!) commands repeatedly failing with PARM ('MRAP') errors until AI is relaunched. (Though even this doesn't necessarily avoid problem; e.g. repeatedly running any JS script from AS seems to blow up after a while, after which AS commands randomly fail as well.)
*/

(function() {

     function fitFrame(textFrame) { // textFrame must be a TextFrameItem
          if (!(textFrame instanceof TextFrame && textFrame.kind == TextType.AREATEXT)) { // ignore point/path text
               return -1;
          }
          var limit = 0.2;
          var textPath = textFrame.textPath;
          var textLength = textFrame.contents.replace(/\s+$/, "").length; // get length of printable text (ignores trailing whitespace)
          if (textLength === 0) {
               textPath.height = 0; // text frame is empty so set to zero-height and return
               return 0;
          }
          var h = textPath.height;
          // if frame has no height, add some to get things started
          if (h < limit) {
               h = limit;
               textPath.height = h;
          }
          // overflow checker; this checks length of printable text to index of last visible character in frame
          var hasOverflow = function() {
               var lastLine = textFrame.lines[textFrame.lines.length-1];
               if (lastLine === undefined) { // no lines are visible (frame is too small)
                    return textLength > 0;
               }
               return textLength > (lastLine.characters[0].characterOffset + lastLine.length - 1);
          }
          // adjust text frame height using two-stage divide and conquer; crude, but works, and acceptably fast
          // find initial approximate min and max heights between which text overflow occurs
          var oh;
          if (hasOverflow()) {
               do {
                    oh = h;
                    h *= 1.5;
                    textPath.height = h;
               } while (hasOverflow());
          } else {
               do {
                    oh = h;
                    h /= 1.5;
                    textPath.height = h;
               } while (!hasOverflow());
          }
          // narrow the difference between min and max approximations till it falls within limit
          var d = oh - h;
          if (d < 0) { d = -d; }
          while (d > limit) {
               d /= 2;
               h += (hasOverflow() ? d : -d);
               textPath.height = h;
          }
          // if final reduction caused overflow, undo it
          if (hasOverflow()) {
               textPath.height = h + d;
          }
          return textPath.height;
     }
    
     for (var i = 0; i < activeDocument.selection.length; i++) { // iterate over each item in AI's janky selection object
          fitFrame(activeDocument.selection[i]);
     }
})();

resizing width of a selected object.

Trying to get a very simple script to adjust for the slight distortion that happens when a printing plate is wrapped around the print cylinder. Basically I need to condense the image width wise only (not the height) so it will compress something like 95-98% of it's original width but the height will be the same.

 

I tried to make a fairly basic script to do this, but it keeps telling me "selectedObject.resize is not a function". Ultimately my idea was to create a variable called condenseRatio that would be the percentage I would reduce the width by, because not every plate would reduce by the same percentage. The distortion changes based on which print cylinder is chosen, so wherever the left x value of the repeating image is determines what percentage the image will need to be condensed. Currently I've just got the resize set to 90% of width just to see if I can get it going, and worry about using a variable number there later. So far, no go.

 

Here's what I've cobbled together:

 

// required: an open document and a selected path item 

 

var myDocument = app.activeDocument; 

var selectedObject = myDocument.selection; 

 

//Identify left edge of repeat 

var repeatBounds = app.activeDocument.groupItems['repeat'].geometricBounds; 

var r1 = repeatBounds[0]; 

 

// Get position of selection bounds and create condense ratio 

var myBounds = selectedObject[0].geometricBounds; 

var x1 = myBounds[0]; 

var x2 = myBounds[2];

var rawRepeat = (r1 - x1);

var rawGap = (r1 - x2);

var rawPrintWidth = myBounds[2] - myBounds[0];

var condenseRatio = (rawPrintWidth / rawRepeat) * 100;

 

selectedObject.resize(

    90.0, // x

    100.0, // y

    true, // changePositions

    true, // changeFillPatterns

    true, // changeFillGradients

    true, // changeStrokePattern

    true , // changeLineWidths

    undefined); // scaleAbout

 

Any help on what I'm doing wrong would be greatly appreciated.

 

Thanks in advance.

Tweaking the SaveDocsAsPDF script

Hello. Absolute scripting newbie here; will someone take pity...?

I am looking at the SaveDocsAsPDF script. It works for our purposes except I would like it to save PDFs using a Preset we created called "SGS PDFs. (We have trouble with people in our office forgetting to choose this setting, so I thought a script might be the answer.)

I found a posting on this forum where someone wanted to save files as small as possible, and got some clues from that. So I left everything as is in the original script, except I added this first line in the function:
{var NamePreset = '[SGS PDFs]';

Then after the line:
var options = new PDFSaveOptions();

I added:
options.PDFPreset=NamePreset;

I thought this would result in a script that does the same thing I now do "manually". However, if I save my document "manually" using File/Save As/ Adobe PDF, and choosing the SGS PDFs preset (and changing nothing else), I get a 716 KB file. But if I use my script, I get a 4.9 MB file. So it appears that what I added is NOT making the script use my preset settings.

So my question is: Is there something REALLY basic missing from my script, or... In order to get a script that accomplishes everything already determined in the Preset, do I manually have to list all those settings as options?

I think I can do the latter if I need to if I just study some of the other scripts... unless there's a shortcut!

Split Text into Layers

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


releasing all compound paths on a layer with javascript

Hello everyone!

 

I am trying to make a script that converts groupitems to pathitems on a layer. I found a script on here that ungroups group items in a layer.

 

var thisDoc = app.activeDocument;

var myLayer = app.activeDocument.activeLayer;

var group = thisDoc.activeLayer.groupItems;

 

for (d=0;d<group.length;d++){

    var mygroups = group[d];

          for (i=mygroups.pageItems.length-1; i>=0; i--)

               mygroups.pageItems[i].move(myLayer, ElementPlacement.PLACEATBEGINNING);

     }

 

Is there a way to also release the compound paths in the group items so they become individual pathItems as well?

 

Thanks

Need script to batch convert vector .eps to .png images with scale

Hi,

 

I'm looking for a script/program that if you run it, all the .eps files in a folder will batch convert to a png-24 with 250% scale.

 

Erdem

Select an object in illustrator using extendscript

I have a drawn rectangle on an illustrator document. In the layers menu I have given it a specific path name (outerBox). I would like to select this item and return its particular properties eg height, width, colour etc. How would I do this.

 

Thanks

Bob

Script for changing order of layers

I have multiple files that I need to prepare for Die- Cutting... The art files have been built in Photoshop and saved as a .tif... I then need to place them in an illustrator document in a layer called artwork, which is above the die-cut layer... I have built an action that allows me to pick the file to be placed, (I then need a script it to flip the order of the layers to put the die cut layer on top)... Then the action continues with a print... (then I need the script to flip the layers back the Artwork on top and diecut on bottom), then the action continues with a save.

 

Any help would be greatly appreciated

Scripting Illustrator actions, incorporating calls to Excel

Hello all, I need some help...

 

I am building a series of logos — based on word strings —  using Illustrator CS4 with a combination of Actions, but also retrieving the word string from an Excel file.

 

Normally for one or two iterations of the process, I would not hassle with a script, but this is a mind-numbing repetitive task, and I have to make 6,000 logos!! Seems the ideal use for a script.

 

We have tried to work with ExtendScript Toolkit (ESTK) but we can't get our heads around how to make it do certain things, and I can't find anyone who really knows how to use ESTK correctly.

 

I have a MAC, so the script has to be written in Java Script or Apple Script.

 

Here's what I need to do:

 

  1. Execute Action: Open a Master Illustrator doc. This doc is already configured with art board, pre-defined type box (Area Type Optioned), Charater Styles, Drop Shadow parameters set. <pause Action>
  2. Run Script: Retrieve the word string from a cell in Excel worksheet (or CSV??). Some are single words, first letter capped. Some are two to four words Camel Cased. Example: "DinnerPartiestm". There are two additional charaters "tm" at the end of the word string that will be acted upon (remember these two characters for item 7 below)
  3. Run Script: Place this WordString into the predefined type box in the Illustrator Master doc. That is, in Illustrator, "select" the type box so the cursor is at first position and place the word string — copy from Excel & paste into Illustrator? <pause Script>
  4. Execute Action: Apply character style 1— font with point size, letter spacing, stroke and colour (It just happens to be red). Example: DinnerPartiestm  <pause Action>
  5. Run Script: Select all caps in word string. Example: DinnerPartiestm<pause Script>
  6. Execute Action: Apply character style 2 — Caps Only (selected) — New point size, baseline offset. Example: DinnerPartiestm<pause Action>
  7. Run Script: Select last two letters of word string. Example: DinnerPartiestm<pause Script>
  8. Execute Action: Apply character style 3 — last two letters only (selected) — New point size, change colour, baseline offset. Example: DinnerPartiestm<pause Action>
  9. Run Script: Select text box. <pause Script>
  10. Execute Action: Apply Stylize > Drop Shadow — On contents of text box, preset DS parameters in either Appearence panel or Effect menu.
  11. Execute Action: File > Save As .ai document. <at Save As dialog, pause action>
  12. Run Script: Retrieve file name from Excel and place in Save As dialog (copy & paste?). In next column in Excel doc, same row, is a SEO-friendly file name. Example: word string is "DinnerParties"; file name (next column) is "logo-dinner-parties"
  13. Run Script: Select folder to save the .ai doc into. Example: Folder is "Logos AI". <pause Script>
  14. Execute Action: Complete Save As. Example: in Folder "Logos AI" now we have the file "logo-dinner-parties.ai"
  15. Execute Action [assumes that the Saved As document — logo-dinner-parties.ai — is now the active one in Illustrator]: Save for Web & Devices. Preset to PNG24/Transparent. Correct file name will NOT be in Save field. <at Save dialog, pause action>
  16. Run Script: Repeat retrieval process to get same file name from Excel.
  17. Run Script: Select new folder to save the .png doc into. Example: Folder  is "Logos PNG". <pause Script>
  18. Execute Action: Complete Save for Web. Example: in Folder "Logos PNG" now  we have the file "logo-dinner-parties.png"
  19. Execute Action: Close
  20. Repeat steps 1 though 19 until all word strings processed: Script has to know to go to next word string (next row) in Excel doc.

 

This is a tricky one, but there's got to be a way to automate the process... otherwise I'll go crazy doing this manually!!

 

IS THERE ANYBODY OUT THERE WHO CAN HELP?

 

Thanking you in advance for any assistance.

 

All the best.

Change Folder.current to location of script (.jsx) file?

All,

 

I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.

For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:

 

var w = new Window ("dialog");
var f = new File ('~/Desktop/transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();

 

However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:

 

var w = new Window ("dialog");
var f = new File ('../../../transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();

 

But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.

I say that because when I do this:

 

alert(Folder.current);

 

The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.

 

So, is there a way of setting Folder.current to the location of the actual script?

Resize Artboard

Unsure if Im asking in the right spot but is it possible to automate the resizing of the artboard say from A0 down to A1

fit frame to text (free script)

Wrote it but don't need it, so help yourselves…

 

/* fit_frame_to_text.js -- resize selected text frames to fit their current text content [Adobe Illustrator]

This script is released into the public domain. No warranty provided, E&OE, caveat emptor, etc.

Notes:

- Text frame must be rectangular area text, vertically aligned to avoid skewing when its path height changes.

- On success, fitFrame returns new height in points. If text frame is empty it is resized to 0 height.

- If text frame was point- or path-based, or not a text frame, fitFrame returns -1 to indicate it was ignored.

Caution:

- JSX scripts should use anonymous functions and local vars only whenever possible, as AI's shared JS interpreter gets increasingly fragile as globals are defined, eventually resulting in JS (and AS!) commands repeatedly failing with PARM ('MRAP') errors until AI is relaunched. (Though even this doesn't necessarily avoid problem; e.g. repeatedly running any JS script from AS seems to blow up after a while, after which AS commands randomly fail as well.)
*/

(function() {

     function fitFrame(textFrame) { // textFrame must be a TextFrameItem
          if (!(textFrame instanceof TextFrame && textFrame.kind == TextType.AREATEXT)) { // ignore point/path text
               return -1;
          }
          var limit = 0.2;
          var textPath = textFrame.textPath;
          var textLength = textFrame.contents.replace(/\s+$/, "").length; // get length of printable text (ignores trailing whitespace)
          if (textLength === 0) {
               textPath.height = 0; // text frame is empty so set to zero-height and return
               return 0;
          }
          var h = textPath.height;
          // if frame has no height, add some to get things started
          if (h < limit) {
               h = limit;
               textPath.height = h;
          }
          // overflow checker; this checks length of printable text to index of last visible character in frame
          var hasOverflow = function() {
               var lastLine = textFrame.lines[textFrame.lines.length-1];
               if (lastLine === undefined) { // no lines are visible (frame is too small)
                    return textLength > 0;
               }
               return textLength > (lastLine.characters[0].characterOffset + lastLine.length - 1);
          }
          // adjust text frame height using two-stage divide and conquer; crude, but works, and acceptably fast
          // find initial approximate min and max heights between which text overflow occurs
          var oh;
          if (hasOverflow()) {
               do {
                    oh = h;
                    h *= 1.5;
                    textPath.height = h;
               } while (hasOverflow());
          } else {
               do {
                    oh = h;
                    h /= 1.5;
                    textPath.height = h;
               } while (!hasOverflow());
          }
          // narrow the difference between min and max approximations till it falls within limit
          var d = oh - h;
          if (d < 0) { d = -d; }
          while (d > limit) {
               d /= 2;
               h += (hasOverflow() ? d : -d);
               textPath.height = h;
          }
          // if final reduction caused overflow, undo it
          if (hasOverflow()) {
               textPath.height = h + d;
          }
          return textPath.height;
     }
    
     for (var i = 0; i < activeDocument.selection.length; i++) { // iterate over each item in AI's janky selection object
          fitFrame(activeDocument.selection[i]);
     }
})();

Transform Each

Changes in CS6

OMG! the CS6 DOM additions are _________. (fill in the blanks).

 

2 Enumerations

- Compatibility.ILLUSTRATOR16

- ExportType.TIFF

 

2 Methods

- PlacedItem.relink()

- Application.sendScriptMessage()

 

1 Data Class

- ExportOptionsTIFF

 

 

(According to the CS6 SCRIPTING REFERENCE)

Pg Number, File path and date automatically printed?

Is there a way to automatically print the page number, complete file path and date at bottom of each  page (set to landscape)?

 

Thanks!

Calling functions from UI palette

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!

Viewing all 12845 articles
Browse latest View live


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