Illustrator scripts: down with routine.

The work of a designer associated with the implementation of any creative ideas is unthinkable without numerous routine processes, when you have to spend a lot of time and effort to repeat the same operation. There are many reasons for this. First, it is required to design a lot of graphic elements in a single style, which automatically implies multiple repetition of the same type of operations. Secondly, in specific areas of design there are many standard operations that also have to be repeated from day to day (a classic example in this sense is converting dozens and even hundreds of image files to a certain standard form). A separate issue is batch processing of files, when it is necessary to impose the same transformations at once on a large group of images.

One of the ways to automate repetitive processes is to use scripts, which are sequences of commands that can be repeated many times and are the most powerful and at the same time the most complex tool for automating work in Adobe Illustrator. Scripting is effective in a variety of situations when it comes to a large number of similar actions, and scripts can be applied both to individual images and to groups of images, effectively combining them with macros, which further simplifies and speeds up the process of preparing images and saves a lot of time ...

At the same time, in practice, scripts are not widely used by designers. Apparently, due to the fact that to write them you need to know one of the object-oriented programming languages: JavaScript, Visual Basic (Windows) or AppleScript (Mac OS). However, this is not so difficult, since many designers are involved in creating Web pages using JavaScript and therefore have an understanding of object-oriented programming, and this knowledge is quite enough for writing scripts. There is one more argument in favor of JavaScript - this language is platform independent, and therefore scripts written in it will work on both Windows and Mac OS. In this lesson, we will focus on JavaScript-based scripting technology in the Adobe illustrator CS2 environment, and to increase the level of accessibility of the material, we will try to do without complex formulations and without using a large number of concepts - new for ordinary users, but accepted in programming, since many of them are solving most of the standard design problems is optional. Those wishing to familiarize themselves with JavaScript scripting at a higher level and the basics of scripting in Visual Basic and AppleScript can refer to the detailed tutorial from Adobe (documentation files along with sample scripts are included in the delivery, and they can be found in the Scripting folder).

Theoretical aspects of working with scripts

The delivery of Adobe Illustrator includes several ready-made scripts aimed at solving the most frequently repeated tasks, including scripts for exporting images to SVG, PDF and Flash formats. The scripts included in the delivery are run by the command File => Scripts(File => Scripts) (Fig. 1), and are stored in the folder Presets \ Scripts... In addition, the demo scripts attached to the documentation can also be used in the work - they can be selected from the folder Scripting \ Sample Scripts using the command File => Scripts => Other Script(File => Scripts => Another script).

The library of built-in scripts can be unlimitedly replenished with new scripts by downloading them from the Internet or by creating them yourself. In both cases, additional scripts are simply copied into the same folder - after restarting the program, they become available from the menu File => Scripts along with inline scripts. In the case of a large number of scripts, it is wiser to save them indirectly in the folder Presets \ Scripts, and in separate subfolders, the number of which is not limited, and all of them will be presented as separate submenus of the command File => Scripts(fig. 2).

Almost all sequences of necessary actions and transformations are saved in scripts, which can later be used when working with other images. However, there are exceptions: for example, objects such as styles, brushes, graphics, mesh objects and spirals cannot be created in scripts, and in addition, plugins cannot be launched from scripts.

Scripts in the JavaScript programming language are plain text files with the js extension and therefore can be created in any text editor, including notepad.

Object-oriented programming concept

A document created in Illustrator is a set of objects, each of which is of one type or another (for example, vector, raster, symbolic, etc.) and has certain properties (border width, fill color, etc.). ). In addition, each object belongs to a certain document, and is located on its specific layer and can be subjected to certain actions (move, copy, duplicate, etc.).

In general, all these principles are also valid in relation to object-oriented programming, with the only difference that the types of objects are usually called classes, and actions allowed in relation to objects are called methods, however, properties are also called properties here. To better understand the relationship between classes and objects, you can think of a class as a kind of blueprint for creating objects. According to this drawing, different objects are made, as it were, with the same basic characteristics, but each object exists independently of the others, that is, a change in its characteristics does not in any way affect the characteristics of other objects. For example, all symbolic objects have the same nature, but each of them will have its own size, color setting, etc.

JavaScript has reserved names (or operands) for each type of object, method, and property, for example pathItems means a vector object, symbolItems- symbolic object, RasterItems- raster object, GroupItems- group element, Selection- selected item, etc. (see the scripting guide for a complete set of reserved names).

There can be many objects on each layer of a particular document, therefore all objects lying on any of the layers are combined into arrays in which the objects differ in numbers (numbering starts from zero). As a result, referring to a specific object implies sequential indication of the designation of the word app (abbreviated from application, which means that the object belongs to the loaded application), document name, layer number, class name and element number in the corresponding array. For example, the construction app.activeDocument.layers.pathItems- this is a call to the very first in depth vector object lying in the active document on the topmost layer (note that the numbering of layers also starts from zero).

The resulting rather long constructions can be easily shortened. Here it is possible not to indicate the components of the name that are unnecessary in this particular case (in particular, if there is only one layer in the document, then it is optional to indicate it). You can use name references by entering an abbreviated name (such names are called variables in the programming language) to indicate the part of the name structure that will have to be repeated many times. It is better to assign names meaningfully to simplify orientation in the body of the code. For example, if you first enter the construction mypathItems = app.activeDocument.layers.pathItems, then the code section under consideration will have the form mypathItems.

Do not use as names the words used in JavaScript to denote classes, properties and methods, as this can lead to unpredictable results. An example of an incorrectly defined variable is - strokeWidth = app.activeDocument.layers.pathItems, word strokeWidth used to denote the Border Width property).

Before you start experimenting with scripts, you need to remember a few rules:

  • variable names are case-sensitive (i.e. mypathItems and MyPathItems will turn out to be completely different variables);
  • array element number is always indicated inside square brackets;
  • any script construct (such constructions are called operators) ends either with a ";" or a closing curly brace ")". The second option takes place only in those cases; when this construction already contains an opening curly brace "(";
  • the number of closing curly braces is exactly the same as the number of opening curly braces;
  • it is better to place each new construct on a new line, and constructs placed inside curly braces are better to print with a line shift (Fig. 3). Although these techniques are optional, they greatly simplify the orientation in the generated script and allow you to control the number of opening and closing curly braces.

The principle of writing and debugging scripts

Although JavaScript is very easy to learn, it is still a programming language. In practice, this means that quite often scripts begin to work correctly only after debugging, which involves fixing both explicit and hidden errors. Explicit errors are understood as incorrect language constructs, incorrect syntax, attempts to access non-existent variables, etc. (These are reported by Illustrator when trying to run the script). The reason for the appearance of hidden errors is an incorrect algorithm, and such errors can only be guessed by a careful analysis of all script operations.

Before the script starts working, it will have to be edited and re-launched more than once, so it is better to immediately place the script in the menu File => Scripts(File => Scripts) than to manually select it each time using the command File => Scripts => Other Script(File => Scripts => Another script). To do this, open notepad, save a still empty file with the js extension in the Presets \ Scripts folder and restart the program. It is advisable to specifically set aside one item in the menu for debugging scripts File => Scripts, for example with the name debugging, - in this case, creating the next script, you can first place it in the debugging.js file in the folder Presets \ Scripts, then bring it "to mind" (the convenience is that this script will be immediately visible in the Illustrator program menu), and after debugging, save it in the same folder, but under a personal name.

Mastering the simplest JavaScript language constructs

Before moving on to examples of creating scripts that can automate the process of solving certain design problems, we will consider a few simple training examples that, although not of particular practical value, will help us understand the principles of using the most common language constructs. To do this, create an empty debugging.js file in Notepad and save it in the Presets \ Scripts folder. Next, load Illustrator and create a new document, placing three vector paths in it, for example, three rectangles with a wide border (Figure 4). Pay attention to the placement of objects in the Layers palette: the object at the very bottom of the layer was created the very first, and therefore in various arrays it will appear under the 0th number; as you move up the Layers palette, the object numbers will increase.

Enter the following lines into your debugging.js file

mypathItems = app.activeDocument.layers.pathItems;

mypathItems.strokeWidth = 2.5;

mypathItems.strokeWidth = 3.5;

mypathItems.strokeWidth = 2.5;

and save the file with the same name (fig. 5).

Design mypathItems = app.activeDocument.layers.pathItems means creating a variable named mypathItems, thanks to which it will be possible to shorten the reference to all objects of the first layer of the active document. Line mypathItems.strokeWidth = 2.5 says that the border width (property strokeWidth) for the very first object will be equal to 2.5 pixels. The rest of the lines are identical.

Switch to the image in Illustrator and run the created script with the command File => Scripts => debugging(File => Scripts => Debug). The result will be a change in the border width: for the first and third objects by 2.5 pixels, and for the second by 3.5 pixels. Since there is only one layer in the document, the considered construction can be shorter (Fig. 6).

In practice, the same transformations (as in this case, changing the border width) are most often performed in relation to several or even all objects. Enumerating them manually in a script, even just copying lines, takes quite a long time; besides, it is fraught with unnecessary errors and complicates the program code. In such cases, they resort to cycles - if the document contains all the same three rectangles, the reduction of the border in the cycle for all objects to a value of 0.5 pixels is shown in Fig. 7. Type these lines in the debugging.js file, save and run the script to process the working image. The modified script was supplemented with a loop operator:

f or (loop condition) (

loop body

The loop condition may look different, but in most cases it can be represented by the construct i = 0; i<имя_объекта.length;i++ , which means a change in the variable i by one unit in the direction of increasing from zero and until its value coincides with the number of objects ( length) in the active layer of the active document. The body of the loop is bounded on both sides by curly braces and can include one or several lines (depending on the number of actions performed in the loop), each of which ends with a ";" character.

Now let's try to change the script so that the border changes only when there are selected objects in the image, and at the same time we will get acquainted with the conditional jump operator, which in general looks like this:

if (condition) (

action set 1

action set 2

Such a construction means that if the condition is true, the first set of actions is performed, and otherwise, the second. In its simplest form, a condition can be represented in the form of equality or inequality, and any set of actions is enclosed in curly braces and can consist of one or more actions, each of which is on a separate line and ends with a “;” character. Try to change the script according to fig. 8 and test it in practice. In this case, the script has been supplemented with a new variable docSelected, used to refer to selected objects in a loop (the loop variable is increased until it becomes equal to the number of selected objects) and appearing in a condition statement that is checked for the presence of selected objects. As the check shows, this script does not generate errors when executed, but it does not work correctly - if there are selected objects, the border width does change, but not for those objects that were selected, but only for the corresponding number of objects in order. The problem lies in the line mypathItems [i] .strokeWidth = 0.5 and will be allowed if it is replaced by a structure docSelected [i] .strokeWidth = 0.5(fig. 9). Check it out for yourself to make sure that now the border width changes only for those objects that were previously selected.

At the end, we will add a finishing touch to the script - we will add it so that in the absence of selected objects, a corresponding message appears on the screen (Fig. 10 and 11). To display the message, we will use the operator Alert, which provides the display on the screen of arbitrary text previously entered in the design Alert in quotes. It should be noted that the operator Alert it may be useful not only if you need to accompany the script with some messages. It can be much more useful when debugging a script, when the reasons for the script's malfunction are completely incomprehensible. Using the Alert operator in such situations, you can track how the program understands this or that instruction, and thus you can determine the reason for the incorrect operation of the program code.

Examples of creating and using scripts

Changing the appearance of objects of the same type

It is often necessary to quickly change certain properties for all objects of the same type in a document. For example, you need to change the fill color of objects, or slightly decrease or increase the size. In the manual version, in this case, you will have to select all the objects of interest to you, which, with a significant number of them, is rather tedious. Therefore, for such operations, create a series of scripts that do the job automatically. Let's say you need to slightly reduce the size of a large number of character images in an already finished document ( symbolItems) (Fig. 12), and it is not known in advance by how many pixels it is necessary to reduce the height values ​​( height) and width ( width). In this case, you should reduce it by 1 pixel, and if this is not enough, then the script can be run repeatedly to further reduce it. To decrease the value of a property by a certain amount in comparison with the initial value, add a "-" sign in front of the equal sign in the property - in our case, the corresponding construction will take the form: mysymbolItems [i] .height- = 1... Likewise, you can increase the value of a property by typing a “+” instead of the “-” sign. The created script is shown in Fig. 13, and the result of its work is shown in Fig. fourteen.

Scripts can be used not only to change one or another property of objects, but also to complete their design, which is most often done by imposing a graphic style and can also be automated. Graphic styles ( graphicStyles), like many other objects, are combined into arrays and can be accessed by numbers. As an example, let's create a script that will apply a certain style to all vector objects whose border width is less than or equal to 1 (in fact, the principle of image verification depends on the features of their creation and can be very different). An example of such a script is shown in Fig. 15.

Thickening borders that are too thin

Quite often, after various transformations, it turns out that the boundaries of some objects are too thin and can be practically invisible (Fig. 16). Then the width of the border for such objects has to be increased, and doing it manually with a large number of objects is very problematic. It is much more convenient to do this job using a suitable script, which will take a matter of seconds. The task of such a script is to iterate over all objects, and those of them that have a smaller border width (for example, 0.25 pixels) - to increase the border width to 0.5 pixels. The rest of the boundaries should remain unchanged. The created script is shown in Fig. 17, and the result of its work is shown in Fig. eighteen.

Formatting text objects

Often, at some stage of document design, there is a desire to change the design principle of the text objects included in it. However, highlighting a large number of objects is tedious. In such situations, you can create a script that is able to iterate over text objects and change their characteristics in a certain way, for example, by reducing the size of the font, its color, font, position, etc.

You can think of a lot of such scripts, but we will focus on increasing the font size by 1 unit and changing its color for all text objects in the document (Fig. 19). This involves iterating over objects from the class in a loop. textFrames(this is how text objects are denoted) and adjusting their properties characterAttributes.size(font size) and fillColor(in this case, the color of the symbols). A similar script is shown in Fig. 20, and the result of its work is shown in Fig. 21.

Aligning the height and width of objects

When creating organizational, technological and other types of business diagrams, you have to work with a large number of identical objects, for example, ordinary rectangles, which differ in size due to the different lengths of the text placed in them (Fig. 22). Ultimately, however, all of these elements must often be equal in height. Aligning them manually is, of course, troublesome, but this operation can be quickly done using a script.

Let's create a script that will align the heights of all objects with the height of the control object created last. It should be created by manually setting the desired height (Fig. 23), and the width of the objects should not change. To do this, it is enough to simply iterate over all objects in a loop, recalculating the new height for each according to the usual proportion and then changing it. To change the height, we will use the method resize (scaleX, scaleY), where scaleX and scaleY- change of values ​​of width and height in percent (in comparison with old values). In our case, you only need to calculate the value scaleY, a scaleX will be equal to 100, since the width remains unchanged. The script we created is shown in Fig. 24, and the result of its work is shown in Fig. 25.

There is also a situation when objects need to be aligned in width, leaving their height unchanged. The script will also help automate the process, which can be obtained from the previous one by replacing the property height(height) per property width(width) and editing the principle of scaling objects in the resize ( scaleX, scaleY), where in this case the value scaleY(fig. 26).

Formatting a table

If you have to work regularly with objects of the same type, for example, with tables, the content of which, like the number of lines, is constantly changing, but the style of the design is preserved, then you can significantly speed up the process of designing the table by creating an appropriate script. Suppose that all table cells are created in white and have no borders (Figure 27). When designing, it is necessary to fill the header cells with a certain color (in other words, change the value of the property fillColor) and add a thin border 0.5 pixels wide to them, which implies changing the properties strokeColor and strokeWidth.

In this case, heading cells mean cells that have a certain left border - in our example, 40 pixels. The fill color of the cells will differ from the border color, so you need to form two variable colors - let's call them colorNew and colorNew1, for each of which you will have to determine the red, green and blue components of the color. After that, you need to iterate over all vector objects in a loop and change the properties fillColor, strokeColor and strokeWidth those of which the left border is 40 pixels. The created script is shown in Fig. 28, and the result of his work is in Fig. 29.

Please note that in this example, the cells themselves (that is, the corresponding rectangular objects) were present in the document, so their parameters could be changed. This means that when the table was created, its cells were drawn as rectangular objects, and then copied to the clipboard and duplicated with the command Edit => Paste in Front(Edit => Paste in Front). After that, the text was inscribed in the copies of the cells, grouped together with the corresponding rectangular cell. With a different technology for creating a table, a completely different script will be required for its design.

Export and save open documents

It happens that after working with several and even with many documents at the end of the work, they all need to be saved or exported to the desired format. Let's consider the option of exporting all open images to jpg format. When creating a script to perform this operation, firstly, you need to ensure that the images are saved with different names and in a specific folder, and secondly, you should somehow switch from document to document, provided that the document names are arbitrary.

There are two ways to solve the first problem - either to specify the destination folder, as well as the document name manually during script execution (but this is rather tedious, especially in the case of a large number of images), or to form the folder and document name according to a certain principle. We will follow the second path, that is, we will set a fixed folder as the destination folder C: / temp /, we will leave the document name the same, and the jpg extension will be assigned automatically by choosing the required export format. As a result, the corresponding line of the script in this example will look like this: fileSpec = new File ("C: / temp /" + doc.name), where doc.name is the name of the active document.

The second problem - switching from document to document - in the script will be solved automatically due to the fact that each already exported document will be immediately closed, and the one loaded before it will become active. However, it should be borne in mind that the number of working documents in this script will turn out to be the value of the variable, so it will not be possible to use it as the upper limit of the cycle execution. Therefore, before the loop, you need to create an additional variable to store the original number of documents - docLength = documents.length.

In addition, it is better to close images with the doc.close ( SaveOptions.DONOTSAVECHANGES), and not doc.close (), because in the second case, when closing each image, the program will ask for a corresponding confirmation. The script for solving the formulated problem is shown in Fig. thirty.

Batch processing of files

Quite often it is necessary to carry out the same processing for groups of files, for example, when converting a large number of files to a certain form. In such cases, it is advisable to execute the script in batch mode. Although this feature is not provided in Illustrator, you can run a macro in batch mode, one of the commands of which can be the launch of the required script.

Imagine that there are so many files developed by different users, and that they need to be reduced as much as possible in size and overwritten in the same EPS format. For each file, you need to perform two operations: remove unnecessary brushes, graphic styles, symbols and colors that weight the file, and then save the image in EPS format. Theoretically, you can put both operations in one script, which is later launched in batch mode from the palette. Actions(Actions), but in practice you will have to act differently - use a macro Delete Unused Palette Items from the set Default Actions which is responsible for removing unused brushes, graphic styles, symbols and colors. Unfortunately, JavaScript's capabilities are somewhat limited, and therefore, to solve this problem, you would have to use the commands docRef.swatches.removeAll (), docRef.symbols.removeAll () and d ocRef.graphicStyles.removeAll (), which will lead to the removal of all colors, symbols, etc., and not only unused ones, which cannot be considered the optimal solution. You can delete unnecessary graphic elements one by one, but this will take a lot of time and effort. Thanks to the Delete Unused Palette Items macro, the action we need will be performed in a matter of seconds, so we will focus on combining the script and the macro.

Open the palette Actions(Macros) using the command Window => Actions(Window => Actions) and create a new set of actions in it by clicking on the button Create new set(Create New Set) located at the bottom of the palette. Select a macro Delete Unused Palette Items, duplicate it with the command Duplicate(Duplicate) and drag the duplicate operation into the created macro set. Now you need to supplement the macro with the operation of saving the file in EPS format - a specially created script will be responsible for this operation. SaveAsEPS(fig. 31). We will save the files under their original names in the folder C: / temp /.

It would seem more logical to arrange the script launch in the form of the second macro in the created set of actions, but this will be inconvenient for further processing of the files. The fact is that only one macro can be run in batch mode, therefore, in order for the file processing operation to be carried out in one step, add the Delete Unused Palette Items macro by running the script and change the name of the macro. The script launch can be included in the set using the command Insert Menu Item(Insert menu item) the Actions palette menu by specifying the command in the window that opens File => Scripts => SaveAsEPS(File => Scripts => Save as EPS), fig. 32.

To run the created macro in batch mode from the palette menu Actions open command Batch(Batch), in the dialog that opens, select a set of macros from the list Set(Set), and then the desired macro in the list Action(Action). Next on the list Source(Source) install option Folder(Folder), click the button Choose(Select) and specify the previously created source folder. In the list Destination(Receiver) select option Save and Close(Save and close) (fig. 33) and click on the OK button. The result will be the appearance of reduced size files in the folder C: / temp /- they will all be in EPS format.

In this collection you will find 10 useful scripts for Adobe Illustrator. These scripts are completely free. All references are in the names of the scripts. If the script does not want to be downloaded from the link, but instead the code opens in your browser, then do Right Click> Save Link As and save the script to your computer.

A small lyrical digression for those who have not encountered scripts in Illustrator before. A script is a program that can be launched in Adobe Illustrator from the menu File> Scripts... As it should be for any program, the script performs any useful actions, quickly and automatically. That is why scripts have become indispensable helpers for microstockers, as there are more than enough routines in our work.

The following scripts for Adobe Illustrator help designers in a variety of tasks. Starting from the preparation of vector files for microstocks and ending with the authorization of flowers. But if this is not enough for you, then at the end of the article there are links to a whole bunch of scripts.

To install the script on your illustrator, you need to copy the script file to the folder with standard scripts. Look for it where your illustrator is installed.

For Windows, this is usually: drive C> Program Files> Adobe> folder with your version of Adobe Illustrator> Styles (Presets)> en_GB or RU (one folder will not miss there)> Scripts.

For poppies: Applications> Adobe> your version of Adobe Illustrator> Presets> en_GB> Scripts.

If you can't find the standard folder, then the scripts can be run in Illustrator without installing via File> Scripts> Other Script (Ctrl + F12).

So let's go!

The script searches for and fixes errors that are not allowed on microstock. The vector file is scanned automatically: the script finds open paths, ghost paths, unparsed brushes, symbols, raster, and more. Along the way, the script immediately suggests correcting these errors. You can download Free Stock Master for free at MAI Tools.

Using this script, you can selectively check for the presence of certain objects in a vector file. For example, search for open paths, raster, etc. You can download the script at Arid Ocean. The green ExtendedSelect.zip button is there at the very top.

The script opens a multi-page PDF entirely and completely, and not one page at a time, as is customary in the illustrator. In the script window, we indicate the path to the PDF file, the number of pages, and it opens in one document on several artboards.

The script aligns the selected objects to the pixel grid. Works in the same way as the Align to Pixel Grid option.

The script inverts the selected object so that it looks like a flower or pattern.

The script draws lines from corner to corner of the shapes. The result is geometric patterns and pictograms.

The script twists nodes from objects, interesting patterns are obtained. The script has convenient settings that are immediately applied to the selected shape. You can immediately see what happens on the work area.

The script changes the position of the lines and points so that the geometrically correct drawing becomes more vivid. Or crooked, but it's like playing with the settings.

The script makes an even column out of separate one-line texts like on posters.

Adobe Illustrator has a variety of tools and features to help you make your dreams come true. But even with so many opportunities in your arsenal, something will definitely be missing. On the Internet, you can now find many scripts and plug-ins for Adobe Illustrator that extend its functionality. Without these add-ons, Adobe Illustrator may not be able to cope with some tasks, or add extra work for the artist. Therefore, today we will consider several useful and free scripts for Adobe Illustrator.

Installing scripts

In order for the script to work in Adobe Illustrator, we need to place it in the Scripts folder, which is located in the Adobe Illustrator directory. In my case, this is ... / Adobe / Adobe_Illustrator_CS5 / Presets / en_GB / Scripts. If you are using an earlier version of the program, instead of Adobe_Illustrator_CS5, in your case, there may be Adobe_Illustrator_CS4, Adobe_Illustrator_CS3, etc.
If you downloaded the scripts that are compressed into an archive, do not forget to unpack them. After installation, you need to restart Adobe Illustrator.

The scripts available for use can be found on the File tab in the Scripts submenu.

Select Open Path

This script will find and select all open-loop shapes. This script will be useful when creating a vector for microstocks, because closed loops are one of the criteria for accepting your work in the microstock base.

Close All Paths / Close All Selected Paths

This script closes the path for all shapes, or for the selected shapes. So, for example, after finding open paths using Select Open Path, you can make them closed.

Devide text frames

With the help of this script, you can split a single text field into smaller ones, where the separation will be a line break.

Join Text Frames

This script will combine multiple text fields into one.

Fleurify

Thanks to this script, the shapes will be decorated with beautiful floral curves.

Metaball

After using this script, a few simple shapes will turn into more complex ones.

CMYK to Pantone v.2

This script converts the CMYK color mode to Pantone

Circle

Thanks to this script, you can create circle shapes with the required number of points on it.

Remove anchors

This script will delete the selected points on the shape.

Round any corner

After using this script, the sharp corners of the shape will be converted to rounded corners.

Swap Objects

This script will give one object the properties of the second, and the second - the properties of the first. Size and location on the stage will be used as properties.

Select Path By Size

The plugin will help you find shapes of a certain size.

The functionality of Adobe Illustrator is huge, but there are also some drawbacks here, since this program has scripting that simplifies and even expands the program's capabilities. In addition to scripting, there are also extensions - user panels for extending the program, but this is a slightly different topic.

Installing scripts

If you've never used scripts in Adobe Illustrator, here's a quick guide on how to run a script.

First, we need to put the scripts you want to use in the "Scripts" folder. How do I find the path to this folder? It's simple, go to the root of the folder where the Adobe Illustrator program is located, then "Presets -> en_US -> Scripts", instead of en_US there may be another folder with localization, what is the localization of Illustrator, and choose such a folder.

After you have placed the scripts in the folder, you can run them using the standard method - this is launching via "File -> Scripts", in the drop-down menu there will be a list of your scripts, click on any of them and you will run the script. Even if your scripts are in a different folder, you can also run them, moreover, in several ways:

  1. Go to the menu "File -> Scripts -> Other Script ...", the explorer will open, after which you need to find the script file, and then run the script
  2. You can simply drag the script into Illustrator from the explorer, after which the script will start.
  3. You can use extensions to run scripts - this is a panel for Illustrator that allows you to run scripts directly from the program. There are several such extensions. I recommend using LAScripts.

Harmonizer

Script for arranging elements on a grid

Select the objects, run the script, select the number of columns (the lines will be calculated automatically), select the distance between the elements, as well as their centering (by default, the largest element from the selected ones is taken).

ArtboardsResizeWithObjects

Script to resize the artboard along with the content.

Adobe Photoshop has an "Image size" function to change the artboard along with the content, but Adobe Illustrator does not have such a function out of the box. Sometimes, it is necessary to change the artboard along with the content, so that after the change all the states are preserved.

Let's say you decide to change the artboard with your hands, the order of your actions: Change the artboard, then you select all the elements on the artboard, and resize, but here just one problem comes up. If you have elements with strokes, then when you change by hand, the stroke will not shrink as the object shrinks, you can get around this solution by checking the "Scale strokes and effects" checkbox, but what if you need to resize multiple artboards? To simplify and save time, use the artboardsResizeWithObjects.jsx script


  • New scale factor- the scale of the artboard as a percentage
  • New artboard width- new artboard width, height will change proportionally
  • New artboard height- new artboard height, width will change proportionally
  • Only active artboard- change only active artboard
  • All artboards- change all artboards
  • Custom artboards- change arbitrary artboards, you can write both commas and hyphens (like when you specify pages when printing)
  • Include hidden & locked items- take into account locked and hidden elements
  • Input field for dimension- the default is the width of the active artboard.

ArtboardsRotateWithObjects

Script to rotate the artboard along with the content.

In Adobe Photoshop, you can rotate the artboard and the content will also be rotated, but in Adobe Illustrator there is no such function out of the box.

This script is useful if you need to rotate multiple artboards, or if you don't want to spend time adjusting the position relative to the artboard after you rotate it.


A brief description of each of the points in the script:

  • Active artboard #- rotate only active artboard
  • All artboards- rotate all artboards
  • Rotation angle 90 CW- rotate artboard clockwise
  • Rotation angle 90 CCW- rotate the artboard counterclockwise

InlineSVGToAI

Script to insert svg (and convert svg code) into document.

In the version of Adobe Illustrator CC 2018 v.22.1 (March, 2018), we added the ability to insert an svg object, the script in this case does not need to be used.

It always annoyed me that an svg cannot be inserted into a program that specializes in a vector, I mean if we copied the svg code from the editor or from somewhere else, but in the form of text, then it will not work to insert it into the program. You will first need to save the code to a file, only then open the file in Illustraor, copy the content and paste into the desired document. There are a lot of unnecessary actions, isn't there?

To get rid of this misunderstanding, I wrote a script that will automatically create a file, import the content into your document, and then delete it. Those. the script does everything the same, but only without our participation and there is no need to waste time on this.


A brief description of each of the points in the script:

  • It's simple - paste the content into the field and click "Paste"

PuzzleClipper


A script for creating jigsaw puzzles based on objects.

The script creates groups with clipping masks, the element that will be "sawn" - the lowest object of the selected ones. Modes of operation, if you have a group on top and an object on the bottom, then all the elements in the group will be converted into groups with a clipping mask and an object from the very bottom of the selected ones. The script does not have an interface, just select the elements you need and run the script.


ReplaceItems

Script for replacing objects with the original ones, objects from a group or from the clipboard.

For example, you need to replace some elements on the layout, but it takes a long time to replace them by hand, you can use this script for replacement, just select the element you need, copy it, then run the script, select the "Object Buffer" item.

Also, the script can accidentally rotate each of the elements, take the dimensions of the replaced element, take the fill, and you can also not delete the original element.


A brief description of each of the points in the script:

  • Object in buffer - the object is on the clipboard
  • Top object - the object is the first from the selected list
  • All in group (random) - an object is randomly selected from the group
  • Scale field - the scale of the inserted element
  • Replace items in a group? - Are the replaceable items in the group? (if the elements that need to be replaced are in the group, check this box, otherwise the whole group will be replaced, and not every element from the group)
  • Copy Width & Height - Copy the Width and Height values ​​from the element being replaced
  • Save original element - save (not delete) the replaced element
  • Copy colors from element - copy the fill from the replaced element
  • Random element rotation - randomly rotate each of the elements

CreateArtboardsFromTheSelection

Script for creating artboards based on selected items.

The script creates an artboard based on the selected items, as well as for each of the selected ones.


A brief description of each of the points in the script:

  • Each in the selection - create for each of the collection of selected items
  • Only selection bounds - create an artboard based on the selection.
  • Item bounds Vsible - item bounds "Visible"
  • Item bounds Geometric - item bounds "geometric"

TransferSwatches

Script for importing swatches from document to active document.

Run the script, select a document from the list, you can also check the box so that colors with the same names are replaced.


ArtboardItemsMoveToNewLayer

A script that places the contents of the artboard on a new layer.

Run the script, select your artboards, you can also select "remove empty layers and sublayers" and "Layer name from artboard name".


You have a unique opportunity to expand the functionality of Adobe Illustrator. Nothing is easier than using scripts (script files), just select the object and run the script you want. The scripts presented in this post will save you a lot of time, make your work more enjoyable and efficient. Believe me, they are worth your attention. All scripts have been tested in CS3 and CS4 versions of Illustrator.

If you need premium quality Illustrator add-ons, you can find them in our Illustrator Actions and Scripts section of our GraphicRiver resource, such as Isometric Guides Grid Action, Pattern Maker, and Long Shadow Action (Action to create a long shadow).

Best Actions and Scripts for Illustrator on Graphic River.

Otherwise, use the free "buns" about which we will tell you now. But first, let's figure out how to install scripts for Illustrator.

Installing Scripts

The scripts you intend to use should always be saved in the same place, for example, in the Scrips directory. To run the script, go to File> Scripts> Other Scripts (Command + F12) (File> Scripts> Other Scripts).

Open the directory with scripts and run the required file.

Share this