Svg Could Not Read the File Because the Plug-in Could Not Read This File Illustratro

adobe-scripting

This guide walks through the process of getting started writing scripts in Javascript for utilize in Adobe Illustrator CC.

This tutorial was written using Adobe Illustrator CC (2017) running on macOS (10.12).

Table of Contents

  • Setup Development Environs
    • Install and Setup ExtendScript Toolkit CC
    • Install and Setup Atom IDE Based Workflow
    • Install and Setup VSCode IDE Based Workflow
  • Getting Started
    • Introduction
    • Understanding the Adobe Documentation
    • Setup Development Surround
    • Agreement the Certificate
    • Preprocessor Directives
    • How-do-you-do World
    • Debugging
  • Examples
    • Hi World
    • New Document
    • New Certificate RGB
    • New Document Gear up Origin
    • New Document Preset
    • New Document Preset Units
    • Primitives
    • Save Files
    • Make Document
    • Preprocessor Directives
    • Layers
  • References
  • Donate

Setup Evolution Environment

In that location are two means to write scripts for Adobe Illustrator: 1) Use the ExtendScript Toolkit.app or 2) Use a text editor and custom workflow (ie. Atom). Both workflows are described below.

Recommendation: If y'all are new to scripting or coding in general, I suggest starting with the standard Extendscript Toolkit.app to get familiar with the language, syntax, and DOM before moving onto a different editor and workflow (ie. Atom or VSCode).

Pro Tip: As you become experienced you may find that its beneficial to utilize both IDEs at times since (in my opinion) Atom (or VSCode) is much nicer to look at / apply and ExtendScript Toolkit has a built in Information Browser for learning the API and a JavaScript Console for debugging.

Install and Setup Extendscript Toolkit CC

  1. Launch Adobe CC and look for "Extendscript Toolkit CC" in the list of bachelor applications. If information technology isn't shown in the list goto Preferences > Creative Cloud > Cheque "Prove Older Apps" to reveal it in the listing of available applications. If needed, the direct download link tin can exist found here.
  2. Click Install
  3. Later on installing the toolkit you should encounter a folder chosen "Adobe ExtendScript Toolkit CC" under Applications. Locate the binder and launch "ExtendScript Toolkit.app".
  4. Set the Target application to "Adobe Illustrator CC 2017". If Illustrator is not open, open it and click the small broken red "concatenation link" icon in the scripting application to change it light-green and connect to Illustrator. If Illustrator closes the concatenation link icon will change back to a broken red link.
  5. (Optional) The default settings are much to modest for a Macbook Pro with Retina Screen on the highest resolution setting. Alter the font to 'Consolas' or 'Monaco' and font size to 'xvi'.

At this point yous are ready to write scripts! Proceed reading for alternative workflows with Cantlet or VSCode text editors. Both are free and open source and provide many congenital in features and packages to customize your workflow.

Install and Setup Atom IDE Based Workflow

Atom Using Process Palette

  1. Install Atom IDE
  2. Install process-palette atom package.
  3. Add a new global command to the process-palette.json file by going to the package setup options and adding the post-obit.
    • Give information technology a namespace of "ai"
    • An action name of "run-current-script"
    • A keystroke of "cmd-ctrl-r" (You lot tin set this to anything you want)
    • A beat out command of osascript -e 'tell awarding "Adobe Illustrator"' -e 'activate' -e 'do javascript "#include '{fileAbsPath}'"' -e 'finish tell'
  4. Load a new .jsx file and run it via "cmd + ctrl + r" or by right clicking on the file in the sidebar and choosing "Run With" > Run Current Script.
  5. Make sure Adobe Illustrator is open and you should see the results when running the script.

Atom Using Adobe Script Runner (Updated!)

As of September 2018, I have shifted the workflow to using Adobe Script Runner. Good news! There is a version for both Atom and VSCode (continue reading). It essentially replaces the Process Palette workflow in a higher place (Yay!). Which means it works with any kind of file/folder path including spaces or not. By default, information technology contains a key control setup for After Effects then you will demand to do the following to setup a key command for Illustrator.

  1. Enable keybindings in the packet settings.

  2. Open up upwards Cantlet > Keymap. The file keymap.cson will open in the editor.

  3. Add the following primal bounden for Adobe Illustrator. This i replaces the default AE keybinding. If you desire to keep it, merely use a different keybinding.

                      '.platform-darwin atom-workspace':   'alt-cmd-r': 'adobe-script-runner:Adobe Illustrator'                                  
  4. Now you lot can run scripts with the specified key command as before. If yous don't take Illustrator open it volition automatically launch it.

Install and Setup VSCode IDE Based Workflow

  1. Install VSCode IDE

  2. Install Adobe Script Runner and ExtendScript Syntax Highlighting. This second extension volition ensure syntax highlighting and that you don't get unnecessary errors when running a .jsx file.

  3. Load a new .jsx file and run information technology via "cmd + shift + p" and selecting Adobe Illustrator. Similarily you could run other Adobe applications the aforementioned way.

  4. If y'all would similar to customize the fundamental command to be the same equally Cantlet or different than the default, follow the remaining steps.

  5. Goto Code > Preferences > Keyboard Shortcuts

  6. Search for adobeScriptRunner.ai and add a new central command to this by editing the keybindings.json file or clicking on the pencil next to the detail. Add the following keybinding for Adobe Illustrator:

                      {   "key": "ctrl+cmd+r",   "command": "adobeScriptRunner.ai",   "when": "editorTextFocus" }                                  
  7. Run using the new key command and you should see the results in Illustrator.

Getting Started

Introduction

This guide is written with the intention of providing an entry point into learning how to write scripts for utilize in Adobe Illustrator CC. Information technology assumes some experience with programming fundamentals and JavaScript. If you are familiar with a programming language such equally python, C/C++, or Java it should be fairly straightforward to follow along.

The content is oriented towards visual blueprint and writing code that results in visual and graphical elements. If you are familiar with creative coding IDE's such equally Processing or OpenFrameworks, it should experience familiar in the iterative "write - run ... repeat" workflow, meaning yous write some lawmaking, run it, see the issue in Illustrator, and echo the process. To facilitate this kind of workflow I recommend using Atom IDE as opposed to the ExtendScript Toolkit Application.

Understanding the Adobe Documentation

There are several official Adobe documents that deed as good references for learning scripting. I suggest reading through them in the post-obit club to grasp fundamental concepts and to learn which references are relevant to the task at mitt.

  • Adobe Illustrator Scripting References - All Official Documentation (Login Required)
  • Adobe Illustrator Scripting Guide - Read First
    • Affiliate 2: The Illustrator Scripting Object Model
    • Chapter 3: Scripting Illustrator
    • Affiliate 5: Scripting with JavaScript
  • Adobe Illustrator Scripting Reference: Javascript - Reference as needed
  • JavaScript Tools Guide CC (PDF located under Applications/ExtendScript Toolkit CC/SDK) / Online Version
    • Chapter 7: Integrating External Libraries

A searchable and more accessible HTML Version of the Document Object Model can be found here Adobe Illustrator Blazon Library. For older versions check

If yous are interested in a more modern approach to working with the documentation and have some experience working with Node.js, check out the Documentation for the ExtendScript API by Yearbook. It'due south a great alternative for building your ain searchable reference documentation from the ExtendScript API.

Setup Development Environment

In general, y'all want to Setup Atom (once) and make a new Illustrator certificate. It is possible to generate new documents using the app.documents.add() function. We volition comprehend more of this method later.

  • Setup Atom to be your primary editor. Trust me, information technology merely works better.
  • Open Up Illustrator
    • Create an Illustrator file with mm as the default units.
      • New Document > Width: 100, Tiptop: 100, Millimeters, RGB Color > Create
    • Setup Grid & Rulers
      • Preferences > Guides & Grid > Gridline every: 1 mm, Subdivisions: 1
      • Show Grid (View Card or CMD + ')
      • Show Ruler (View Carte du jour > Rulers or CMD + r)
  • Open Up Atom
    • Brand a new directory called "scripts".
    • Make a new file called "script.jsx" in your scripts binder. This and other scripts will be used for writing lawmaking and running from inside Cantlet via the process-palette bundle you setup previously.

At this signal you should have an empty document in Illustrator with 1 empty layer and a project binder to store scripts in.

Understanding the Document

The most basic scripts consist of drawing paths (and shapes) on layers within a document. To do this there needs to be a reference to an active document and at to the lowest degree one layer inside the certificate. The code below provides a boilerplate to get a reference to the active document and the first (and but) layer in the document.

              // become the active document              var              doc              =              app              .              activeDocument              ;              // become reference to layer 1              var              layer              =              dr.              .              layers              [              0              ]              ;            

Any code entered in a script following these references volition take admission to the doc or layer objects.

Preprocessor Directives

Preprocessor directives are a mode to include external scripts. At a basic level, the showtime line of a script might accept a directive equally show below. This directive includes any code written in the file lib.js, bringing information technology into my script. Why use this? Over fourth dimension your code might become complex, making it hard to read. Using additional files will allow you to modularize, simplify, reuse, and streamline your lawmaking. To learn more near their use expect at the JavaScript Tools Guide (pdf) located nether Applications/ExtendScript Toolkit CC/SDK.

For the moment we won't worry about preprocessor directives. We will make use of them afterward in the guide.

Hullo World

This example volition insert the text "Hello Earth" at the position (0,0) in the artboard. The position that an object is inserted into the artboard is dependent on the artboard coordinates. When you make a new document using the Illustrator New Certificate window, the artboard volition default to a position of (0,0). This is not ever the instance when generating an artboard using a script. We will explore why this is next.

  1. Create an Illustrator file with mm as the default units. Prepare the certificate size to 100 mm 10 100 mm and RGB Colour. As mentioned previously, its really nice to be able to see the filigree while learning about positioning and inserting objects to the artboard. Setup the grid past going to Preferences > Guides & Grid > Gridline every: 1 mm, Subdivisions: 1.

  2. Create a script called hello-world.jsx and insert the following code.

                      // get the active document                  var                  md                  =                  app                  .                  activeDocument                  ;                  // go reference to layer ane                  var                  layer                  =                  md                  .                  layers                  [                  0                  ]                  ;                  // create new text frame and add it to the layer                  var                  text                  =                  layer                  .                  textFrames                  .                  add                  (                  )                  ;                  // contents and position of text frame                                    text                  .                  contents                  =                  "Hullo World"                  ;                  text                  .                  position                  =                  [                  0                  ,                  0                  ]                  ;                
  3. Run the code using Procedure Palette to see the result in Illustrator. The text was placed in the top left corner at (0,0).

Debugging

The $.writeln() part - This is similar to println() in Processing or panel.log() in standard JavaScript and is really useful for debugging. The only caveat is it but works in the ExtendScript Toolkit IDE and will print to the JavaScript Console within the IDE. I have not found a solution for printing debug messages to the console in Atom yet. To make employ of it, you tin have the ExtendScript Toolkit open next to Cantlet.

Information Browser - This window inside the ExtendScript Toolkit IDE is shows the namespace and all the objects, variables, and methods bachelor. It is only available inside the ExtendScript Toolkit IDE and only updates when running a script. In general the typical utilise case involves a document and/or layer so I normally start off inspecting an active certificate using the following script. In many cases, it's probably much easier to reference a documentation organisation such equally Documentation for the ExtendScript API by Yearbook.

              var              medico              =              app              .              activeDocument              ;              var              layer              =              doc              .              layers              [              0              ]              ;            

Examples

This section describes the examples contained in the scripts binder. The best way to acquire the API is to work through these examples starting from the acme.

Hi Earth

This example assumes there is an active document open in Illustrator. Information technology gets a reference to the document, the first layer in the document, then adds a textFrameItem to the textFrames collection. A reference to the textFrameItem added is then positioned at 0,0 and given the contents of "Hello World".

Assuming the certificate was created from the new file menu, information technology volition have an origin of the top left, significant both the earth coordinates and artboard coordinates will marshal. As such, the text should be drawn in the top left corner.

              // go the active document              var              medico              =              app              .              activeDocument              ;              // get reference to layer one              var              layer              =              doc              .              layers              [              0              ]              ;              // create new text frame and add it to the layer              var              text              =              layer              .              textFrames              .              add together              (              )              ;              // fix position and contents of text frame              text              .              position              =              [              0              ,              0              ]              ;              text              .              contents              =              "Hello Earth"              ;            

New Document

This example creates a new document with a width of 100 pt and height of 100 pt and adds a pointTextItem to the textFrames drove. Points are the default unit of measurement in Illustrator.

              // define the document width (in points)              var              width              =              100              ;              // ascertain the document superlative (in points)              var              height              =              100              ;              // create a new document; Defaults to CMYK colorspace              var              md              =              app              .              documents              .              add              (              null              ,              width              ,              superlative              )              ;              // add text to information technology              var              text1              =              medico              .              textFrames              .              pointText              (              [              ten              ,              0              ]              )              ;              // the text              text1              .              contents              =              "Hello World"              ;            

New Document RGB

This case is the same as the previous only shows how to alter the colorspace of the file from the default CMYK to RGB.

              // define the document width (in points)              var              width              =              100              ;              // ascertain the document height (in points)              var              height              =              100              ;              // create a new certificate; Set to RGB colorspace              var              doc              =              app              .              documents              .              add together              (              DocumentColorSpace              .              RGB              ,              width              ,              acme              )              ;              // add text to it              var              text1              =              md              .              textFrames              .              pointText              (              [              10              ,              0              ]              )              ;              // the text              text1              .              contents              =              "Hello Globe"              ;            

New Document Fix Origin

This case creates a new document with a width of 100 pt and superlative of 100 pt and adds a pointTextItem to the textFrames drove. Earlier adding the text object we shift the ruler origin for the certificate such that the origin is in the meridian left. This is different from when we create a document using the standard new file card. In two previous examples, y'all may notice the location of the text inserted is at or near the bottom of the artboard. This is because when generating a new document with a script, Illustrator will default to the bottom left every bit the origin instead of the top left.

              // ascertain the document width (in points)              var              width              =              100              ;              // define the document superlative (in points)              var              height              =              100              ;              // create a new document              var              doc              =              app              .              documents              .              add              (              DocumentColorSpace              .              RGB              ,              width              ,              elevation              )              ;              // shift the nada-indicate of the rulers in the document relative to the bottom left of the document. Basically, make (0,0) of the artboard the top left corner to get in easier to position objects.              doc              .              rulerOrigin              =              [              0              ,              height              ]              ;              // add text to it              var              text1              =              doc              .              textFrames              .              pointText              (              [              0              ,              0              ]              )              ;              // the text              text1              .              contents              =              "Hello World"              ;            

New Document Preset

This example makes use of the DocumentPreset() function to setup a new document. This allows you to customize things like the document championship, width, height, and colorspace. It also allows you lot to make use of built in Illustrator presets for documents (which I rarely find myself using).

              // define the document width (in points)              var              width              =              100              ;              // ascertain the document summit (in points)              var              height              =              100              ;              var              presets              =              app              .              startupPresetsList              ;              /*                              To go list of presets:                              var presets = app.startupPresetsList;                              $.writeln(presets);                              Returns: Art & Illustration,Basic RGB,Devices,Motion-picture show and Video,Mobile,Print,Video and Film,Web              */              var              preset              =              presets              [              0              ]              ;              var              docPreset              =              new              DocumentPreset              (              )              ;              docPreset              .              title              =              "MyNewDocument"              ;              // Untitled past default              docPreset              .              width              =              width              ;              docPreset              .              height              =              height              ;              docPreset              .              colorMode              =              DocumentColorSpace              .              RGB              ;              // create a new document              var              medico              =              app              .              documents              .              addDocument              (              preset              ,              docPreset              ,              false              )              ;            

New Certificate Preset Units

This example builds on the previous one and includes a scaling factor to change the certificate units from Points to Millimeters. I find the easiest way to deal with unit conversion is to just multiply or separate by the scaling gene. In this case its two.834645 so we just declare a global variable called PTS_MM to reference as needed. The document units are likewise specified in the docPreset every bit Millimeters.

              var              PTS_MM              =              2.834645              ;              // define the document width (in mm)              var              width              =              100              *              PTS_MM              ;              // define the document height (in mm)              var              superlative              =              100              *              PTS_MM              ;              var              presets              =              app              .              startupPresetsList              ;              /*                              To get list of presets:                              var presets = app.startupPresetsList;                              $.writeln(presets);                              Returns: Art & Illustration,Basic RGB,Devices,Film and Video,Mobile,Impress,Video and Film,Web              */              var              preset              =              presets              [              0              ]              ;              var              docPreset              =              new              DocumentPreset              (              )              ;              //docPreset.title = "MyNewDocument"; // Untitled by default              docPreset              .              width              =              width              ;              docPreset              .              pinnacle              =              top              ;              docPreset              .              colorMode              =              DocumentColorSpace              .              RGB              ;              docPreset              .              units              =              RulerUnits              .              Millimeters              ;              //  set the ruler units to mm              // create a new document              var              md              =              app              .              documents              .              addDocument              (              preset              ,              docPreset              ,              false              )              ;              // shift origin              medico              .              rulerOrigin              =              [              0              ,              meridian              ]              ;              // insert drawing code here              // the document is setup with origin (0,00 in the superlative left corner. Note: Positioning in the y direction is negative (ie -y).            

Primitives

This example covers the nuts of drawing and styling primitive shapes such as rectangles, rounded rectangles, ellipses, lines, and closed paths. Information technology also introduces a preprocessor directive to include some helper functions for working with color.

#include              "../lib/colour.js"              // define the document width (in points)              var              width              =              100              ;              // define the certificate superlative (in points)              var              height              =              100              ;              // create a new document              var              doc              =              app              .              documents              .              add              (              DocumentColorSpace              .              RGB              ,              width              ,              height              )              ;              // shift origin              dr.              .              rulerOrigin              =              [              0              ,              superlative              ]              ;              // add to existing layer              var              layer              =              doc              .              layers              [              0              ]              ;              // coordinates (in points)              var              y              =              0              ;              var              x              =              0              ;              var              west              =              10              ;              var              h              =              ten              ;              // draw rectangle              var              rect              =              layer              .              pathItems              .              rectangle              (              -              y              ,              ten              ,              w              ,              h              )              ;              rect              .              fillColor              =              makeColorRGB              (              0              ,              0              ,              255              )              ;              rect              .              stroked              =              imitation              ;              // draw rounded rectangle              var              roundRect              =              layer              .              pathItems              .              roundedRectangle              (              -              y              ,              x              +              10              ,              w              ,              h              ,              1              ,              1              ,              false              )              ;              roundRect              .              fillColor              =              makeColorRGB              (              255              ,              0              ,              0              )              ;              roundRect              .              stroked              =              simulated              ;              // draw ellipse              var              ellipse              =              layer              .              pathItems              .              ellipse              (              -              y              ,              x              +              20              ,              w              ,              h              )              ;              ellipse              .              fillColor              =              makeColorRGB              (              0              ,              255              ,              0              )              ;              ellipse              .              stroked              =              false              ;              // draw line              var              p              =              layer              .              pathItems              .              add              (              )              ;              var              lineList              =              new              Array              (              [              ten              ,              -              20              ]              ,              [              20              ,              -              20              ]              )              ;              p              .              setEntirePath              (              lineList              )              ;              p              .              filled              =              imitation              ;              p              .              strokeWidth              =              1              ;              p              .              strokeColor              =              makeColorRGB              (              0              ,              0              ,              255              )              ;              // draw closed path              var              p              =              layer              .              pathItems              .              add              (              )              ;              var              lineList              =              [              [              30              ,              -              twenty              ]              ,              [              fifty              ,              -              xxx              ]              ,              [              xl              ,              -              15              ]              ]              ;              p              .              setEntirePath              (              lineList              )              ;              p              .              closed              =              true              ;              p              .              filled              =              false              ;              p              .              strokeCap              =              StrokeCap              .              ROUNDENDCAP              ;              p              .              strokeJoin              =              StrokeJoin              .              ROUNDENDJOIN              ;              p              .              strokeWidth              =              2              ;            

lib/color.js

              // Represents the "none" color. Assigning a NoColor object to the fill or stroke color of an art item is equivalent to setting the filled or stroked property to false.              role              noColor              (              )              {              return              new              NoColor              (              )              ;              }              // necessary since RGBColor course has no constructor              function              makeColorRGB              (              r              ,              one thousand              ,              b              )              {              var              c              =              new              RGBColor              (              )              ;              c              .              red              =              r              ;              c              .              green              =              g              ;              c              .              bluish              =              b              ;              render              c              ;              }              // necessary since CMYKColor grade has no constructor              function              makeColorCMYK              (              c              ,              yard              ,              y              ,              chiliad              )              {              var              ink              =              new              CMYKColor              (              )              ;              ink              .              cyan              =              c              ;              ink              .              magenta              =              m              ;              ink              .              yellow              =              y              ;              ink              .              black              =              thousand              ;              render              ink              ;              }            

Save Files

This example covers how to programmatically salvage files in a different formats and for different versions of Illustrator. Information technology creates a directory called "test" and saves out the following file types: AI, PDF, EPS, JPG, PNG, and SVG. Helper functions for each file type can exist establish in the /lib/files.js file.

#include              "../lib/color.js"              #include              "../lib/files.js"              //#include "../lib/utils.js"              // ascertain the document width (in points)              var              width              =              100              ;              // define the certificate height (in points)              var              acme              =              100              ;              // create a new document              var              doc              =              app              .              documents              .              add together              (              DocumentColorSpace              .              RGB              ,              width              ,              superlative              )              ;              // shift origin              doc              .              rulerOrigin              =              [              0              ,              peak              ]              ;              // add together to existing layer              var              layer              =              dr.              .              layers              [              0              ]              ;              // coordinates (in points)              var              y              =              0              ;              var              x              =              0              ;              var              west              =              10              ;              var              h              =              x              ;              // draw rectangle              var              rect              =              layer              .              pathItems              .              rectangle              (              -              y              ,              x              ,              w              ,              h              )              ;              rect              .              fillColor              =              makeColorRGB              (              0              ,              0              ,              255              )              ;              rect              .              stroked              =              fake              ;              // draw rounded rectangle              var              roundRect              =              layer              .              pathItems              .              roundedRectangle              (              -              y              ,              x              +              10              ,              w              ,              h              ,              1              ,              i              ,              false              )              ;              roundRect              .              fillColor              =              makeColorRGB              (              255              ,              0              ,              0              )              ;              roundRect              .              stroked              =              fake              ;              // describe ellipse              var              ellipse              =              layer              .              pathItems              .              ellipse              (              -              y              ,              x              +              xx              ,              west              ,              h              )              ;              ellipse              .              fillColor              =              makeColorRGB              (              0              ,              255              ,              0              )              ;              ellipse              .              stroked              =              fake              ;              // specify output dir and filename              var              dirName              =              "test"              ;              var              fileName              =              "output"              ;              //var fileName = "output-" + dateTimeStr(); // utils.js include required              // make a new directory if needed              var              dir              =              new              Folder              (              '~/Desktop/'              +              dirName              )              ;              if              (              !              dir              .              exists              )              {              dir              .              create              (              )              ;              }              // save ai file              saveAI              (              dir              +              "/"              +              fileName              +              ".ai"              )              ;              // default              saveAI              (              dir              +              "/"              +              fileName              +              "-cc"              +              ".ai"              ,              "CC"              )              ;              saveAI              (              dir              +              "/"              +              fileName              +              "-cs6"              +              ".ai"              ,              "CS6"              )              ;              saveAI              (              dir              +              "/"              +              fileName              +              "-cs2"              +              ".ai"              ,              "CS2"              )              ;              // saveAI("~/Desktop/output-cc.ai", "CC");              // saveAI("~/Desktop/output-cs6.ai", "CS6");              // saveAI("~/Desktop/output-cs2.ai", "CS2");              // save pdf file              savePDF              (              dir              +              "/"              +              fileName              +              ".pdf"              )              ;              // default              // save eps file              saveEPS              (              dir              +              "/"              +              fileName              +              ".eps"              )              ;              // default              //saveEPS(dir + "/" + fileName + "-cc" + ".eps", "CC");              //saveEPS(dir + "/" + fileName + "-cs6" + ".eps", "CS6");              //saveEPS(dir + "/" + fileName + "-cs2" + ".eps", "CS2");              // saveEPS("~/Desktop/output-cc.eps", "CC");              // saveEPS("~/Desktop/output-cs6.eps", "CS6");              // saveEPS("~/Desktop/output-cs2.eps", "CS2");              // salvage jpg              saveJPG              (              dir              +              "/"              +              fileName              +              ".jpg"              )              ;              // default              saveJPG              (              dir              +              "/"              +              fileName              +              "-2x"              +              ".jpg"              ,              2              )              ;              // scaled by 2              saveJPG              (              dir              +              "/"              +              fileName              +              "-4x"              +              ".jpg"              ,              4              )              ;              // scaled by 4              // saveJPG("~/Desktop/output-2x.jpg", ii); // scaled by 2              //saveJPG("~/Desktop/output-4x.jpg", iv); // scaled by 4              // relieve png              savePNG              (              dir              +              "/"              +              fileName              +              ".png"              ,              1              ,              false              )              ;              // default              savePNG              (              dir              +              "/"              +              fileName              +              "-2x"              +              ".png"              ,              2              ,              false              )              ;              // scaled by 2              savePNG              (              dir              +              "/"              +              fileName              +              "-4x"              +              ".png"              ,              4              ,              false              )              ;              // scaled by 4              // save svg              saveSVG              (              dir              +              "/"              +              fileName              +              ".svg"              )              ;              // default            

Brand Document

This example demonstrates a manner to simplify the document creation process. It makes it easy to define a width, pinnacle, and units for a new document in one line. Helper functions can be found in the /lib/doc.js file.

#include              "../lib/units.js"              #include              "../lib/doc.js"              // make new dr. in pts (default)              var              doc              =              makeDocument              (              100              ,              100              )              ;              // brand new doctor in mm              //var dr. = makeDocument(100, 100, "MM");              // brand new doc in cm              //var doctor = makeDocument(100, 100, "CM");              // make new doc in inches              //var physician = makeDocument(100, 100, "IN");            

Preprocessor Directives

This example demonstrates how to include a single "library" file chosen main.js using the #include preprocessor directive. main.js in plough includes other js files.

#include              "../lib/master.js"              // This preprocessor directive at the top of the file includes functionality from the lib/chief.js file.            

Layers

This case demonstrates how to work with layers. It creates a document, several layers, and so adds primitives to the layers. It proceeds to manipulate layer names, colors, and layer state (locked / unlocked).

#include              "../lib/color.js"              // ascertain the document width (in points)              var              width              =              100              ;              // define the document height (in points)              var              height              =              100              ;              // create a new certificate              var              doc              =              app              .              documents              .              add              (              DocumentColorSpace              .              RGB              ,              width              ,              summit              )              ;              // shift origin              doc              .              rulerOrigin              =              [              0              ,              height              ]              ;              // add new layers              // layers are appended to the front of the array, meaning, each layer added is in layers[0].              var              layer1              =              doc              .              layers              [              0              ]              ;              // default layer for new document              var              layer2              =              physician              .              layers              .              add              (              )              ;              var              layer3              =              physician              .              layers              .              add together              (              )              ;              doctor              .              layers              .              add together              (              )              ;              // add "Layer 4"              doc              .              layers              .              add together              (              )              ;              // add together "Layer 5"              // physician.layers by 5th add together()              // [0] Layer v              // [1] Layer four              // [two] Layer 3              // [3] Layer two              // [4] Layer 1              // access "Layer iv" in position i              var              layer4              =              doc              .              layers              [              1              ]              ;              // access "Layer 5" in position 0 and rename information technology              var              layer5              =              doc              .              layers              [              0              ]              ;              layer5              .              name              =              "myLayer"              ;              md              .              layers              .              add              (              )              ;              // add "Layer 6"              // access "Layer six" in position 0 and lock it              var              layer6              =              doc              .              layers              [              0              ]              ;              layer6              .              locked              =              truthful              ;              // make 3 more layers ("Layer seven, 8, 9")              for              (              var              i              =              0              ;              i              <              iii              ;              i              ++              )              {              doc              .              layers              .              add              (              )              ;              }              // make 3 more layers ("Layer 10, 11, 12") and change color              for              (              var              i              =              0              ;              i              <              3              ;              i              ++              )              {              var              layer              =              medico              .              layers              .              add together              (              )              ;              layer              .              color              =              makeColorRGB              (              255              ,              255              ,              0              )              ;              layer              .              locked              =              i              ==              1              ?              true              :              false              ;              // if i == 1, set to true (Consequence: Lock "Layer 11")              }              // make 4 more layers ("Layer xiii, 14, 15, xvi") and provisional rename with a range              for              (              var              i              =              0              ;              i              <              4              ;              i              ++              )              {              var              layer              =              doc              .              layers              .              add together              (              )              ;              layer              .              color              =              makeColorRGB              (              255              ,              100              ,              0              )              ;              //layer.proper noun = "my_layer_" + (thirteen + i);              layer              .              proper noun              =              i              ==              two              ?              "foo"              :              "my_layer_"              +              (              thirteen              +              i              )              ;              // if i == two, set proper name to "foo" else "my_layer_##"              }              // coordinates (in points)              var              y              =              0              ;              var              x              =              0              ;              var              westward              =              10              ;              var              h              =              10              ;              // draw rectangle              var              rect              =              layer1              .              pathItems              .              rectangle              (              -              y              ,              x              ,              w              ,              h              )              ;              rect              .              fillColor              =              makeColorRGB              (              0              ,              0              ,              255              )              ;              rect              .              stroked              =              simulated              ;              // describe rounded rectangle              var              roundRect              =              layer2              .              pathItems              .              roundedRectangle              (              -              y              ,              x              +              x              ,              westward              ,              h              ,              1              ,              i              ,              false              )              ;              roundRect              .              fillColor              =              makeColorRGB              (              255              ,              0              ,              0              )              ;              roundRect              .              stroked              =              fake              ;              // draw rectangle              var              rect              =              layer3              .              pathItems              .              rectangle              (              -              y              -              20              ,              ten              +              xx              ,              w              ,              h              )              ;              rect              .              fillColor              =              makeColorRGB              (              0              ,              0              ,              0              )              ;              rect              .              stroked              =              true              ;              rect              .              strokeColor              =              makeColorRGB              (              255              ,              0              ,              0              )              ;              rect              .              strokeWidth              =              1              ;              // describe ellipse              var              ellipse              =              layer4              .              pathItems              .              ellipse              (              -              y              ,              10              +              30              ,              west              ,              h              )              ;              ellipse              .              fillColor              =              makeColorRGB              (              0              ,              255              ,              0              )              ;              ellipse              .              stroked              =              false              ;            

Future Examples

  • Text
  • Groups
  • Iteration
  • Shape Grids
  • Line Grids
  • Text Types
  • Working with Information

And more!

References

Illustrator Scripting

  • Adobe Illustrator CC 2017 Scripting References
  • Adobe Illustrator CC 2017 Scripting Guide (pdf)
    • Chapter 5: Scripting with JavaScript
  • Adobe Illustrator CC 2017 Scripting Reference: Javascript (pdf)
  • ExtendScript Toolkit ReadMe.pdf (Plant under Applications/Adobe ExtendScript Toolkit CC)
  • Illustrator Scripting Guide by aenhancers
  • Adobe Illustrator Scripting Forum
  • Illustrator Object Model aka DOM
  • Graphic Design Stack Substitution
  • Sample Lawmaking
    • Found under Applications/Adobe Illustrator CC/Scripting/Sample Scripts/JavaScript
  • Tutorials
    • scripting-for-illustrator-tutorial by JT Nimoy (jtnimoy)
    • Apply AppleScript to perform batch actions in Illustrator
  • Tools
    • Adobe CC Scripts Console

ExtendScript

  • ExtendScript References And Links - Useful resources for scripting
  • ExtendScript Wiki
  • Adobe Illustrator Type Library
  • Documentation for the ExtendScript API by Yearbook - Great alternative for building your own reference documentation from the ExtendScript API.

UI Scripting

  • JavaScript Tools Guide CC (Institute under Applications/ExtendScript Toolkit CC/SDK)
  • JavaScript Tools Guide (Online) - A slap-up reference on other topics such as UI Tools, Interapplication Communication, etc
  • Jongware ScriptUI
  • Jongware Illustrator (CS6)
  • Peter Kahrel's ScriptUI for Dummies
  • Sample Lawmaking
    • ScriptUI Samples (Found under Applications/ExtendScript Toolkit CC/SDK/Samples)

Cantlet IDE Based Workflow

  • process-palette atom package
  • Apple Scripting
    • Apple Scripting
    • Creating a Script
    • The Ultimate Beginner's Guide To AppleScript
  • osascript
    • osascript manual
    • Run AppleScript from the Command Line in Mac Os 10 with osascript

Donate

If you lot find this tutorial useful in your piece of work, please consider donating via PayPal. I'd love to put more than time and energy into developing acessible content such equally this. Thx for reading! 🙂

kingrenturem.blogspot.com

Source: https://github.com/rjduran/adobe-scripting

0 Response to "Svg Could Not Read the File Because the Plug-in Could Not Read This File Illustratro"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel