Contacts

How to install scripts in Adobe Illustrator. Scripts in Adobe Illustrator

I will tell you about one very comfortable panel, about which rumors often go: how good she is, and no matter how much it was, if it was installed for me and worked and worked!

The advantages of this panel:

The ability to locate the folders with scripts anywhere on the computer - you should only specify the path to them.

If you arrange them in the folder Script Bay Cross-ApplicationThey will be available to other Adobe programs. And you can simply load them by specifying add Cross App Folder.

Compactness and convenience. You can position all your scripts in separate folders by organizing them by frequency of use or by their features: random, with selection, work with text, special effects. By the way, in the Script Bay settings you can create categories that will replace these folders.

But the main reason I am writing this article is that the standard installation method and by the way recommended by In-Tools Solutions, I did not help me. As with many, judging by the exclamations in LJ and other communities.

There are several problems:

The plugin is not installed via Adobe Extension Manager and has a cunning resolution of ZXP.
- Installed, but flies or loses all scripts when the Adobe Illustrator is new.

Therefore, if you also fail to install the plugin via Adobe Extension Manager, you can go in my way. That's how I solved this problem.

1. Installing scriptbay.

Got a plugin from the archive. Just open Scriptbay.zxp through WinRar (Archiver) and remove files from it to a separate ScriptBay folder.

Placed the resulting folder where it is necessary. Handles :)
In my version of the illustrator (Adobe Illustrator CS6) is the Extensions folder.


C: \\ Program Files (x86) \\ COMMON FILES \\ ADOBE \\ CS6ServiceManager \\ Extensions

For CS5, you must put in the folder with plugins plug-ins.

C: \\ Program Files \\ Adobe \\ Adobe Illustrator CS5 \\ Plug-Ins

For other versions, you can find a folder in the image and likeness. For CC, thanks to the guys for tips, here's the way:

C: \\ Program Files (x86) \\ COMMON FILES \\ Adobe \\ Cep \\ Extensions

2. Add scripts to ScriptBay

Then we add your favorite scripts to our panel. You can open the plug-in panel in the Window menu:


Window\u003e Extension\u003e Scriptbay (Window\u003e Extensions\u003e ScriptBay)

To add scripts Click on the panel add Script Folder. And specify the path to the storage folder scripts on your computer.


If scripts are designed not only for Adobe Illustrator - Click add Cross App Folder.
To remove the left folder, highlight and click remove Script Folder..
If you do not keep them in a special place on another disk, you can specify the native folder of the Illustrator scripts:

Usually the path to the folder is:


Disc C\u003e Program Files\u003e Adobe\u003e Folder with your version of Adobe Illustrator\u003e Styles\u003e EN_GB or RU (there is one folder - do not miss)\u003e scripts (scripts)

But I have no longer lying there. I do not keep them on one disk with Windows and programs. At the work of the Script Bay panel, this is not reflected. Also, the panel allows you to select two viewing modes: wood and sheet - display Scripts AS List or Tree.


3. Script Bay menu and other functions

Briefly about other context menu commands:

hide / Show Empty Folders - Hide / show empty folders
show Script File Path - specify the path to the script file
hide / Show Default Folders - Hide / Show folders by default
reveal Installed Scripts. - identify the installed scripts
script Bay Preference. - Script Bay settings menu
check for Updates. - Check for updates
about - Script Bay version

The Script Bay settings menu duplicates some context menu commands.


But it also has differences. So here you can create your categories for the entire collection of your scripts, which will replace you create and assorted the folder scripts.


If you feel capable of writing a new brilliant script, use the built-in Script Bay script editor - Script editor.

In Illustrator, there is a whole bunch of tools, but even with all this abundance, there will always be something miss. Here then come to the rescue scripts and plugins. Using them, you can perform such tasks that the illustrator itself is not able to perform. In this article you will get acquainted with 10 free and most useful scripts (scenarios) for Illustrator!

Scripts?

Illustrator supports scripts from Applescript, Visual Basic, JavaScript, and ExtendScript. In activated state, they perform various operations inside Illustrator, and can also involve other programs, such as text editors, database programs and spreadsheets. You can use both the finished scripts installed by default or other people's own and create your own. For greater information on scenarios in Illustrator, learn the documentation in the Adobe Illustrator CS3 / Scripting folder.

Install scripts

Download the desired script. After placing it in the Adobe Illustrator CS3 / Presets / Scripts folder and it will appear in the script submenu. To start the script you need in Illustrator, click File\u003e Scripts and select it in the drop-down list.


1) Close all the ways to close all dedicated paths (Close All Paths / Close All Selected Paths)

Simple, however, a very powerful script. Using it, you can separate multi-line text fields into individual objects of the text frame, facilitating the task of separating lists, navigation items and much more.


3) Frame Merge (Join Text Frames)

This script can reunite a split text frame. It is very useful if you need to open the PRE-CS Illustrator file or you need to combine a few text frames together.


This script is able to create floral figures from ordinary figures. Great for creating unusual patterns, logos and just for experimenting.


This script can create connecting arches from the figures you created. It is very useful when connecting ordinary figures to create more complex forms for logos, icons and illustrations.


6) CMYK translation in Pantone V.2 (CMYK to Pantone v.2)

This script will select the most accurate match of the Pantone from this CMYK color.


7) Changing Shades Random Colors (Vary Hues / Randomize Colors

This script will create an ellipse with the specified number of key points. This may seem simple, but the operation decently facilitates the process of editing circles, creating brushes, complex shapes and much more. Illustrator has a function that adds more key points into the figure, however you cannot specify how much the key points you want to add.

In this selection you will find 10 useful scripts for Adobe Illustrator. These scripts are completely free. All references - in the names of the scripts. If the script does not want to download the link, and instead the code opens in your browser, then do Right click\u003e Save the link as And save the script to your computer.

A small lyrical retreat for those who did not meet before that with scripts in an illustrator. The script is a program that can be launched in Adobe Illustrator through the menu. File\u003e scripts.. As it should be made any program, the script performs any useful actions, quickly and automatically. That is why the scripts have become inalienable assistants for microtokers, since the routines in our work are even debugging.

The scripts presented below for Adobe Illustrator help designers in a variety of tasks. Starting from the preparation of vector files on the microtoki and ending with the authoring of the flower. But if you and this is not enough, then at the end of the article there are links to still a whole bunch of scripts.

To install the script to 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: c\u003e Program Files\u003e Adobe\u003e Folder with your version of Adobe Illustrator\u003e Styles\u003e EN_GB or RU (there is one folder not slip)\u003e scripts.

For poppies: Applications\u003e Adobe\u003e Your version Adobe Illustrator\u003e Presets\u003e en_gb\u003e scripts.

If the standard folder is not found in any way, the scripts can be started in an illustrator without installing through File\u003e scripts\u003e Other Script (Ctrl + F12).

So let's go!

The script is looking for and corrects errors that are not allowed on microstoks. The vector file is scanned automatically: the script finds outdoor paths, ghost contours, unemmorted brushes, symbols, raster and so on. In the course of the case, the script immediately proposes to correct these errors. Download free Free Stock Master on Mai Tools.

With this script, you can selectively check the presence of certain objects in the vector file. For example, search for open paths, raster, etc. You can download the script on Arid Ocean. Green button extendedselect.zip There at the very top.

The script opens multiplocked PDF entirely and completely, and not one page, as is customary in the illustrator. In the script window, specify the path to the PDF file, the number of pages, and it opens in one document on several artboards.

The script lines the selected objects on the pixel grid. Works similarly to the ALIGN TO PIXEL Grid option.

The script turns the selected object that it becomes like a flower or pattern.

The script holds the corner of the angle in the figures. Geometric patterns and pictograms are obtained.

The script creates nodes from objects, interesting patterns are obtained. The script has convenient settings that immediately apply to the selected figure. Immediately you can see what it turns out on the workspace.

The script changes the position of lines and points so that the geometrically correct pattern becomes more alive. Either curves, but it is already as played with the settings.

The script makes a smooth column as on posters from individual single-time texts.

In this selection you will find 10 useful scripts for Adobe Illustrator. These scripts are completely free. All references - in the names of the scripts. If the script does not want to download the link, and instead the code opens in your browser, then do Right click\u003e Save the link as And save the script to your computer.

A small lyrical retreat for those who did not meet before that with scripts in an illustrator. The script is a program that can be launched in Adobe Illustrator through the menu. File\u003e scripts.. As it should be made any program, the script performs any useful actions, quickly and automatically. That is why the scripts have become inalienable assistants for microtokers, since the routines in our work are even debugging.

The scripts presented below for Adobe Illustrator help designers in a variety of tasks. Starting from the preparation of vector files on the microtoki and ending with the authoring of the flower. But if you and this is not enough, then at the end of the article there are links to still a whole bunch of scripts.

To install the script to 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: c\u003e Program Files\u003e Adobe\u003e Folder with your version of Adobe Illustrator\u003e Styles\u003e EN_GB or RU (there is one folder not slip)\u003e scripts.

For poppies: Applications\u003e Adobe\u003e Your version Adobe Illustrator\u003e Presets\u003e en_gb\u003e scripts.

If the standard folder is not found in any way, the scripts can be started in an illustrator without installing through File\u003e scripts\u003e Other Script (Ctrl + F12).

So let's go!

The script is looking for and corrects errors that are not allowed on microstoks. The vector file is scanned automatically: the script finds outdoor paths, ghost contours, unemmorted brushes, symbols, raster and so on. In the course of the case, the script immediately proposes to correct these errors. Download free Free Stock Master on Mai Tools.

With this script, you can selectively check the presence of certain objects in the vector file. For example, search for open paths, raster, etc. You can download the script on Arid Ocean. Green button extendedselect.zip There at the very top.

The script opens multiplocked PDF entirely and completely, and not one page, as is customary in the illustrator. In the script window, specify the path to the PDF file, the number of pages, and it opens in one document on several artboards.

The script lines the selected objects on the pixel grid. Works similarly to the ALIGN TO PIXEL Grid option.

The script turns the selected object that it becomes like a flower or pattern.

The script holds the corner of the angle in the figures. Geometric patterns and pictograms are obtained.

The script creates nodes from objects, interesting patterns are obtained. The script has convenient settings that immediately apply to the selected figure. Immediately you can see what it turns out on the workspace.

The script changes the position of lines and points so that the geometrically correct pattern becomes more alive. Either curves, but it is already as played with the settings.

The script makes a smooth column as on posters from individual single-time texts.

Usually, if we are talking about programs for designers, paramount attention is paid to the artistic possibilities of applications - drawing tools, filters, etc. But in everyday life you have to deal with routine. Fortunately, according to Adobe (including Illustrator) began to support writing scenarios (scripts), allowing to transfer monotonous work on the shoulders of the machine. And you no longer work in Illustrator - you manage them, and this, as they say in Odessa, two big differences!

Righting the report that the overwhelming part of Illustrator users are artists and designers who have not confronted with programming, I will try to build a review of the functionality of the scenarios so that readers do not have impressions that for this occupation need some kind of "special" warehouse of thinking and long-term special education. At the same time, I apologize to the professionals for some simplifications in the formulation in favor of the availability of the material. The author himself was once in a similar situation and at first did not consider this scope of his diocese. But she spent less than two weeks to study and now I argue: having minimal ideas about programming, master scripts - the task is quite satisfied.

The illustrator scripts can be written in any language: JavaScript, Visual Basic (Windows) and AppleScript (Mac OS). Since most of the readers are familiar with the first one (many designs for printing are successfully coping with the creation of the Internet pages in which it is used), we will rely on it. In addition, JavaScript platform-independent: written on it scripts will work in both OS - Windows and Mac OS. The method of circulation to elements is object-oriented: To find out, for example, the thickness of the edging in the second vector element on the first layer, you need to write the following design:

app.ActiveDocument.Layer.Pathitems.strokewidth.

This can be interpreted as follows: first indicates the object of the highest level in the Illustrator hierarchy (App - the application, abbreviated from the application), and then the choice is gradually narrows to a particular element (in the active document to work on the first layer; then in the specified layer, select the second in the depth of the icing vector in the specified layer The object and find out the thickness of the edging). A similar method of circulation to items is very convenient because it makes it easy to navigate throughout the diversity of their types that exist in the editor. With a full model of relationships, you can get acquainted on a well-compiled description (included in the IllustArtor kit).

Square brackets suggest that the element is part of the array. The array is a combination of several objects combined by a specific feature. For example, Layers, Pathitems, RasterItems, GroupItems, Selection, etc. - arrays consisting of similar objects (layers of document, vector circuits, raster images, groups, etc.). In brackets indicate the index (sequence number) of the desired item in the array. Thus, Layer recording denotes the first layer, since the first index is always "0".

You can contact objects by Layer names ["Chart"]. To do this, the item must be clearly called - manually using the Layers palette (double click on the object name opens the window with its properties) or from the script. In order not to write every time a bulky design with the listing of the entire "pedigree", use the links (References):

pi \u003d activeocument.layer.pathitems;

Then the above code of code will be viewed: pi.strokewidth.

To the layer how to object is allowed not to contact each time all operations occur on the same active layer. And keep in mind that in the names of variables it matters the register: if you first write PI, and the second - PI, then the script will give an error and will not work.

In an object-oriented model, there are: the application itself, classes (types of objects, or using a more familiar concept, nouns: layers, vector objects, groups, etc.), methods (ways of interaction with them - verbs: Move, Duplicate and etc.) and properties (adjectives: STROKEWIDTH, Fillcolor, selected, etc.). To easier to navigate, imagine that the application is a house in which there are various items - analogue of classes (windows, doors) with some properties (plastic, wooden), with which certain actions are performed - methods (open, close). Understanding the essence of such a hierarchy, it is much easier to understand scripting.

At the top level there is an application, and, literally following the rules for the subordination of objects, it would have to be indicated in any action. In order to simplify, the reference to the application can be omitted - except when it is really required to learn some properties (for example, available fonts - App.Fonts).

Classes Layer, Group, Text may contain objects of the same class that can also have subsidiaries. Useful features of the object approach - inheritance Properties. So, all vector contours (Pathitems) are subsidiaries for a more common class - page elements (PageTems). Consequently, assigning certain PAGITEMS properties, we automatically assign it and Pathitems.

Despite the similarity, Layers and Layer classes are still different. The first is the collection of all the layers in the document, the second is only some specific, accordingly their methods and properties differ accordingly. To the first, you can apply ADD, removeall methods, and the second is all operations available for a separate layer. Directly to the object appeal as an element of the corresponding array - in our case through layers, layers, etc.

The selected item corresponds to a separate class - selection, which is also an array (a group of objects can be highlighted). At a special account in Illustrator classes of Pluginitems, Colors, Views. The first has many restrictions related to the fact that objects of this type "not native" for Illustrator. These include Blend, Envelope, Mesh elements and similar. We will consider the rest of the rest as they are used.

For the script to be "visible," it is placed in the Presets.scripts folder, located in the one where the application is installed. We will consider real examples (this will allow you to immediately feel the usefulness of the scenarios), and write them under Illustrator CS, since its scripting is flexible previous versions.

Example 1: Combining Objects

Let's start with the simplest - write a script connecting the subordinate objects with the main objects with the main task when creating flowcharts, technical documentation and similar works). And we will be touched by such basic issues as working with dedicated objects, creating new layers, placement of objects, change their order, creating and enabling curves in a complex path (compound path).

Working with this kind of documents involves widespread use of symbols (Symbols) - making changes to them automatically updates all copies created. However, with such elements, Illustrator works not always correctly: it happens that it does not read the names from objects that are copies of characters. As a result, their selection by name is impartial. The processing of all the elements of this type in the current layer does not have practical benefit. As a result, I bowed in favor of an alternative version, in which you first need to select the required objects (the easiest way is the choice of one character and searching for its copies via the select.same instances command), and then select the support element with which they will be connected.

So, begin. To reduce, we enter the SEL variable to which we will apply when you need any actions on the selected object. Then check how many elements are allocated (although any selected text symbols also include any selected text symbols, check that not the text is not selected). Recording if (SEL.Length<2) означает, что мы сравниваем значение length (количество объектов класса sel) с двойкой — минимальным количеством для работы сценария. Если выделенных элементов меньше, будут выполняться действия, заключённые в первые идущие за оператором if фигурные скобки, иначе — идущие после else. При этом логично предусмотреть выдачу сообщения, чтобы сориентироваться в ситуации и понять, что нужно сделать.

sel \u003d activedocument.selection
If (Sel.Length.<2) {br> Alert ("Not Enough Objects To Proceed! \\ Nselect At Least 2 Objects and The Last - Target Object!"))
ELSE (

Alert is a standard JavaScript function that displays a window with a given text and the OK button. "\\ N" means the transition to a new string and is used so that the size of the windows remain small. The text displayed in the window must be enclosed in quotes.

Preparatory stage

We obtain the coordinates of the center of the reference object. Since we agreed that it is the topmost, its number (index) - "0" (SEL). To calculate the coordinates, we will use such properties of the object as Position (position), Width and Height (Height and Width). POSITION values \u200b\u200bare stored in an array consisting of a pair of values \u200b\u200b- coordinates along the X and Y axis, respectively. Therefore, each you need to contact as POSITION and POSITION.

refobj_x \u003d Sel.position + (Sel.width / 2);
refobj_y \u003d Sel.position - (Sel.Height / 2);

We got the coordinates of the center of the reference object and assigned them to two variables for further use. In the second line, there is a sign "-", since the left lower corner of the document is adopted for the reference point in Illustrator, and POSITION issues the coordinates of the upper left corner of the element.

Since, when working with a document, the last role plays convenience, take care so that the modes created are on a separate layer - such structuredness will help maintain order in the layout of varying complexity.

Create a new layer - it, like any Illustrator element, is created by the ADD () method applied to the corresponding class of objects. In brackets, you can specify the parameters of the action: specify the purpose object (it may be, for example, a layer or even a new document, as well as the position at the destination). Unlike most of the methods, for ADD additional parameters is not provided, therefore, for transfer to the top level, we use the special method - zorder, which, specify the BringTofront as a parameter (reserved constant, the full list of which is provided in the documentation). In principle, if the document is only one layer, it is not necessary to specifically indicate the position of the new one, since illustrator always has it above the current one. If the connected objects are not at the top level, the second line will be needed.

newlayer \u003d activedocument.Layers.add ();
newlayer.zorder (zordermethod.BeringTofront);

The first line can be found like this: create a new element by zooming (add) the number of objects of the required type (layers) and the link to the newly created element is assigned to the NEWLayer variable. At the initial moment, the layer is empty, since it is not placed in it. To simplify the orientation in a complex layout, we will give the name "Connectors" (Name method) - as you can see, the names of the methods are clearly talking about the actions performed.

newlayer.name \u003d "Connectors";

For training purposes, we will create non-fragmented connecting lines, and combined into the object type compound path - for ease of editing. The creation of such an object repeats the already known procedure, this time applied to the COMPOUNDPATHITEMS class:

newcompoundpath \u003d activeocument.compoundpathitems.add ();

Since in the last step we created a new layer, it is active - accordingly, the objects created will be located on it, and the need to specifically indicate it (ActiveDocument.Newlayer) is not.

Definition of coordinates of subordinate elements

This process is combining with the output of the connecting lines themselves, since their number must correspond to the number of objects. Alternately begin to sort out all the selected elements ("i ++" means increment per unit) and read their coordinates. Search will start not from the very first object from the SELECTION array (as you remember, they are a support object), and from the second (SEL). The following lines are already familiar to us:

for (i \u003d 1; i< sel.length; i++) {
OBJ_X \u003d SEL [i] .position + Sel [i] .width
OBJ_Y \u003d SEL [i] .position - Sel [i] .Height

Having obtained the coordinates of the center of the child element, proceed to creating a line connecting it with a reference. For each selected item, we create a new object - a vector circuit, which is included in the COMPOUNDPATH class, increasing the total number of contours:

newpath \u003d newcompoundpath.pathitems.add ();

To specify simple contours in Illustrator, there is a SETENTIPATH method, whose parameters of which acts from the coordinates of the initial and endpoints - which we already know, in turn, are specified in the form of arrays of two values \u200b\u200b(positions on two axes). Finally, we finish the condition introduced at the very beginning "if something is allocated".

newpath.setentirepath (Array (Refobj_x, refobj_y), array (obj_x, obj_y))); )

The script is ready. As you can see, nothing complicated in it: the names of the methods reveal their essence, and the object-oriented model helps to clearly understand the hierarchy of the objects of Illustrator. The script does not represent a special practical value (he is more like a training), but in his example, many basic concepts were considered to be based on further (work with dedicated objects, the principle of their numbering in the SELECTION massif, the definition of coordinates, the creation of new layers, conclusion lines).

Example 2: Detection of too thin contours

Scaling operations in vector graphics are very active. Therefore, with a decrease in the size of objects with thin lines (if the Scale Strokes parameter is enabled), the thickness of their stroke becomes below 0.25 pt (the values \u200b\u200bafter which the lines become weakly noticeable) and it causes their disappearance when printing on a jet printer. Embedded in the illustrator functions of searching objects with stroke values, less than specified, is not provided. Manually find them very difficult - you will have to allocate each object individually, which will quickly select the desire to engage in such inspections. Significantly simplify the operation script.

By itself, the script in the simplest version is small, but we will choose to make it more versatile - expand functionality due to the ability to specify the minimum thickness in the dialog box. Of course, you can hardly register this amount in the script itself and, if necessary, to adjust it every time, but you agree, it is inconvenient. Let us also provide an indication of the selected item as an object object with a minimally allowable edging value. In parallel, for statistics, we calculate the number of elements with the changed thickness and for clarity to highlight them.

The entire script is divided into two parts: the initial (read value from the dialog window or the selected item) and the final (search among all objects in the document and reassign the thickness of the edging). In addition to a demonstration of access to Illustrator objects, we will look at the creation of a mini-interface to enter custom values.

Entering values

The first two lines will be identical to the previous example, except that instead of "2" will appear to appear "0", because before working the script, we need to determine if there are allocated objects. The comparison is set by a double sign of equality (one assigns a value).

var mysel \u003d app.ActiveDocument.Selection;
var go \u003d true;
if (Sel \u003d\u003d 0) (

If nothing is allocated, the minimum thickness will be set through the dialog box. Withdraw it using the standard JavaScript function - Prompt. It opens a window with a field in which you can enter a value in the future to use it. The syntax function is as follows: First, the text-tip goes, which will be displayed in the window (taking into account the unification of the script operation, we will not use Cyrillic, because it is often displayed incorrectly), then the value that will be the default stand in the input field. Plus as many as two: the ability to immediately set the minimum allowable thickness and specify any value. Creating a variable that the value of the Prompt function is assigned, you can then use it for your own purposes.

Climbing forward, I note that Illustrator gives full access not to all types of objects - some remain overboard. Therefore, let's see the visualization of not only corrected elements, but also inaccessible to the script, so as not to search for them manually - because they may also have problem objects. In order not to output two dialog boxes (for the thickness and definition value, which elements are allocated), we will use JavaScript capabilities for row processing. The fact is that the contents of the field filled with the field is the "string" (block of information), in which any parameters can be (through separators). Knowing the separator, the values \u200b\u200bof the individual parameters can be easily removed from the row.

Accordingly, the text-tip of the dialog window will be like this: setting the minimum edging thickness and the conditional number: "1", if necessary, so that the script allocates the corrected elements, "2" - those to which "access" failed.

value \u003d Prompt ("Specify the Stroke Width Threshold (in PT), \\ n What to select: Corrected Objects (1) or Inaccessible (2)", "0.25, 1")

Initially, in the field, set 0.25 points (units of measurement in the default Illustrator), but when it changes it will be used a new value, and "1". "2" needs to be specified only if the script finds inaccessible objects (we will take care so that it signaled it at the end of work). And they will become dedicated that it will save us from manual search (as you know, the built-in search Illustrator leaves much to be desired).

With the reading of values \u200b\u200bfrom the user field, we figured out, go to their processing. Check whether the field is not empty (the sign "!" Means negation, i.e. "! \u003d" Is equivalent to "not equal to", NULL is a registered word for an empty value). If there is something in it, we divide the string into separate blocks using the JavaScript split function (as a separator, we determine the combination of characters ",") and the obtained values \u200b\u200bin the splitstring array. After that, the values \u200b\u200bof the array will give descriptive names (the first will determine the thickness, the second is the mode of operation).

if (Value! \u003d NULL) (
Splitstring \u003d Value.Split (",");
Weight \u003d Splitstring;
Type \u003d Splitstring; )

If there is nothing in the user field - stop the execution of the script. The last closing bracket is a sign of completion of the condition that we put at the beginning ("if nothing is allocated in the document").

eLSE (GO \u003d FALSE)

If the reference object is specially highlighted

Now write a sequence of actions, if we deliberately allocated an element whose overlaying thickness want to use as a threshold value. We will withdraw a warning about further actions of the script using the standard confirm feature (creates a dialog box with two buttons - and). Press<Сancel>, Work stops, but if you agree, the script will continue to work.

eLSE (SELECTEDMSG \u003d CONFIRM ("STROKE WIDTH OF SELECT OBJECT WILL BE USED AS THRESHOLD")
if (selectedmsg! \u003d True) (
go \u003d false;
) ELSE (

Go to the main part of the script. We consciously do not consider the situation when several objects are highlighted, because it is enough to choose the thickness of the edging. And what value to use if it is different from the elements? As we already know, the only dedicated object will have the "0" index, and illustrator has a STROKEWIDTH property to obtain the thickness of the edging. We will consider that in principle, Selection can contain not only individual elements, but also part of the text (for example, allocated by chance), which is not included in our plans, so before starting work, check the capabilities of JavaScript the type of dedicated item to belong to the array:

iF (Sel Isarray) (
Weight \u003d Sel.strokewidth;

Since we agreed to allocate changed objects, from the most reference allocation you need to remove (we appeal to its selected property):

sel.Selected \u003d False; )))

Now we are fully prepared for the main task of the script - search for objects: the value that will be used as the minimum allowable thickness is stored in the WEI variable.

Circumstances

Compare it with a similar property in all objects in the document. You can immediately go to the search, but the use of the script in everyday work required the accounting of additional circumstances - in layouts are often both blocked layers and individual objects. Therefore, at least in them the search and works, but it is impossible to make changes. To provide a total check, add several operations to the script: checking the items to match the specified criterion, at the same time unlock them, if necessary, and remember the index to return them to the previous state after completing the check. We enter two variables: the first for abbreviated access to all layers in the document, and with the second we will get access only to blocked. Store the sequence numbers of the latter in the array, which will create the JavaScript function - New Array ().

var dl \u003d activeocument.layers;
var BokeDlayers \u003d New Array ();

Then browse all layers and blocked (Locked \u003d True) the sequence number will enter the BlookeDlayers (using the PUSH function from JavaScript), after which it allows them to edit them (Locked \u003d False).

if (go \u003d\u003d TRUE) (
For (i \u003d 0; i if (dl [i] .locked \u003d\u003d TRUE) (
BlookeDlayers.push (i);
DL [i] .locked \u003d false; Previously, we agreed to allocate fixed objects, but after completing the script work on the locked layers, we cannot do this - you need to withdraw the appropriate warning. To do this, use the LockedPresence sign, which will establish if at least one layer is blocked.

lockedPresence \u003d True;

The same repeat and with separate blocked elements. In the simplest case, it is enough to check all the vector elements (Pathitems class), in which the subclass includes Compound Pathes, - so that nothing eludes from the all-seeming eye of the script.

Underwater rocks

In addition to the situation with the blocked situation, there is another "underwater stone". As already noted, some elements (in particular, Blend Group and Envelope) are not "native" for Illustrator, they belong to the special type of pluginitem. At the same time, access to such objects in Illustrator is not provided, they are "thing in themselves". You can "reach" to them only through a higher level class - PageTems, through which we can at least define their presence and withdraw the appropriate warning. It will say that by running the script again and specifying as the second parameter in the input field "2", it will allocate these "black boxes".

pGI \u003d ActiveDocument.pageItems;

To store indexes of blocked objects, create a BlookeDPATHES array, and for the calculation of the amount of changed, enter the corrected variable.

blockedpathes \u003d new array ();
Corrected \u003d 0;

For all objects, you will perform a check on the pluginitem type (TypeName property): if any, set the pluginiteExist sign (its state will determine the output of the prevention of such elements). In the case of re-checking (when the second parameter in the input field is "2") we will allocate them:

for (i \u003d 0; i< pgI.length; i++) {
if (pgi [i] .typename \u003d\u003d "pluginitem") (
Pluginitemexist \u003d True.
if (type \u003d\u003d "2") (PGI [i] .Selected \u003d True)

So, all (or almost all) possible situations arising in work, we have provided and determined for them.

Basic check

Now the cores actually check the layout for compliance with the specified edging criterion. We will consider that among the objects there may be such that there are no edging at all (determined by the status of a sign of STROKED) - therefore, they should be excluded from the inspection.

if ((pgi [i] .strokewidth< weight)&&(pgI[i].stroked)) {
if (pgi [i] .locked \u003d\u003d TRUE) (
BlookedPathes.Push (I);
PGI [i] .locked \u003d false;

This code fragment can be interpreted as follows: Determine each element the presence of edging and its thickness. If it is less than minimal (if (pi [i] .strokewidth< weight), и объект заблокирован, его индекс занести в специально созданный для такой цели массив blokedPathes, после чего разблокировать для внесения возможных изменений. Знак && обозначает логическое «И» (обязательное совпадение двух условий) — толщины меньше минимальной и присутствия окантовки.

Then you fix the presence of blocked objects (we install the LockedPresence feature to output in the future alert that not all modified can be highlighted) and the corrected itself is released, and its edging is assigned the threshold value - and so for all items. For statistics, in parallel, we will count the number of changed objects.

lockedPresence \u003d True;
PGI [i] .Selected \u003d True;
pgi [i] .strokewidth \u003d weight;
Corrected ++;

Earlier, actions were considered to highlight unverified elements (Type \u003d "2"). Now we define what should happen in a standard situation - with the usual search for potentially problem objects.

if (Type \u003d "1") (PGI [i] .Selected \u003d True)

Restoring the status of blocked elements

We fulfilled the main task - problem objects are corrected and highlighted. It remains to restore Status Quo - everything is originally blocked to return to the previous state. To do this, you read the contents of the array in the current loop where the indexes of blocked objects are stored, and each corresponding element is set by the LOCKED \u003d TRUE (SHIFT method displays the last value of the value in it). Since the total number of objects is more blocked, you need to take care so that after emptying the array, the check cycle has ended.

if (BlookedPathes.Length\u003e 0) (
retrievedpathes \u003d blledpathes.shift ();
Pi.Locked \u003d True;))

Then similar actions will be engaged in relation to the layers:

for (i \u003d 0; i if (blokedlayers.length\u003e 0) (
Retrieved \u003d blokedlayers.shift ();
DL.LOCKED \u003d TRUE; )) Actually, for the same type of operations, it is much more convenient to use functions. Their advantage is that once describing certain actions, you can repeat them in full, simply causing a function in the right places; So the compactness and readability of the script is achieved. To increase the flexibility of the function, the values \u200b\u200bused in it (parameters) are transmitted. If you do not want to use functions, skip the following two paragraphs.

We will form two functions: the first is to unlock the layers and objects, the second - to restore their attributes. Only the types of object types will be changed in them (Layers and PageTems) and arrays to record the elements of interest to us (Bloedlayers and BlookeDPATHES) - they will appear as function parameters. The first will write down this:

fUNCTION UNLOCK (Array, Itemtype)
if (Itemtype [i] .locked \u003d\u003d True) (
array.push (i);
Itemtype [i] .locked \u003d false;
Locked \u003d false;
}

Instead of Array, we will substitute an array, instead of the Itemtype - the desired class. Then we get two calls - unlock (BlockedLayers, DL) and Unlock (Blookedpathes, PGI). Similarly, write a function to restore status:

function Restore (Array, Itemtype)
if (array.length\u003e 0) (
retrieved \u003d array.shift ();
Itemtype.Locked \u003d True;
}

Display information about the results of the inspection

This is the last stage of the script. First, we determine the output condition of the message if the search for unreactible objects is selected, then the condition for the appearance of a warning that such objects were detected:

if (Type \u003d\u003d "2") (B \u003d "\\ Ncheck selected!")
if (pluginitemexist \u003d\u003d true) (
Alert ("Due to Scripting Restrictions Some Objects CAN" T Be Affected "+ B))

The logic of issuing a cavement that not all corrected can be allocated is as follows:

if ((LockedPresence \u003d\u003d True) && (pluginitemexist \u003d\u003d false)) (
Warning \u003d "\\ Nbecause Some of Them Are Locked The CAN" T BE SHOWED AS SELECT ")

After that we derive the final results:

alert ("Number of Corrected Objects Are:" + Corrected + Warning)

Here, in fact, the whole script. As you can see, these few lines perform a colossal amount of work on which it is unlikely that someone will hardly die. The script is executed instantly (in large-scale projects, with the number of elements of the order of several thousand, the processor performance begins to affect). You only need to select it from the list of available (you can even do it - Illustrator allows scripts to assign "hotkeys") by the Edit.Keyboard Shortcuts.Menu Commands.scripts command. But note: the names of the scripts are sorted in alphabetical order, so adding new or removal of older can lead to reassigning keys to neighboring scenarios. Conclusion: After the changes in the Presets \\ scripts folder, check the key matches.

We tried to make a script universal, which affected his volume. In the most primitive version (without taking into account the characteristics and pitfalls described above), it occupies a literally a couple of lines:

minwidth \u003d activedocument.selection.strokewidth;
PI \u003d ACTIVEDOCUMENT.PATHITEMS;
for (i \u003d 0; i< pI.length; i++) {
if (pi [i] .strokewidth< minWidth) && (pI[i].stroked)) {
Pi [i] .strokewidth \u003d minwidth;
}}

And dessert?

We will devote the next issue: We will write a script that automates their layout on the sheet. However, it will come in handy for a wider range of tasks, because it does not have binding to the size of objects. As it should be, we will seek the creation of issues to avoid problems with the inaccurate cutting of the sheet, as well as the turn of the business cards (if their top and bottom are significantly different). In parallel, we will touch on the question of searching for objects, the color model of which is different from the specified, which is also not uncommon with such works.

Free access logs.

On the same topic:

    News 2019-04-03

    As additional white ink helps to create new use of widescreen printing.

    Today, a number of models of widescreen and ultra-wide-format-format printers can print additional color ink - white, which creates new possibilities for using these devices. But in printers, various printing technologies can be implemented with white ink, and different technologies have their own capabilities and limitations.



Did you like the article? Share it