1 Reply Latest reply on Dec 19, 2016 9:08 AM by williamadowling

    Alternative to convert to paths

    tobiask57942968

      Hey everyone,

       

      I am new to Illustrator scripting. I made a script to made outlines out of text, but i discovered it doesn't work well. Because convert to paths make a lot of problems while using the Expand method and sadly not the Create Outlines command from the menu.

       

      So I looked for a solution, but I didn't find it. So my question is, is there a solution?

       

      At the moment I use Apple Script, but when there is a way with Java Script will use JS.

       

      Here is my snippet, oh and I use CS 6, on Mac OS X - I will upgrade to CC in the next month, but at the moment this isn't possible.

       

        tell application "Adobe Illustrator"

        open IllustratorFileString as alias without dialogs

        set countLayers to count every layer of document 1

        repeat with i from 1 to countLayers

        if visible of layer i of document 1 is false then

        set visible of layer i of document 1 to true

        end if

        if locked of layer i of document 1 is true then

        set locked of layer i of document 1 to false

        end if

        end repeat

        convert to paths (every text frame of document 1)

        repeat with i from 1 to countLayers

        if locked of layer i of document 1 is false then

        set locked of layer i of document 1 to true

        end if

        end repeat

        save current document as Illustrator with options {embed ICC profile:true, PDF compatible:false}

        close document 1 !

        end tell

       

      Thank you for your help!

      Tobi

        • 1. Re: Alternative to convert to paths
          williamadowling Level 4

          If you're using CS6+ and are open to using javascript instead of applescript, you could do this:

           

          function test()

          {

              var docRef = app.activeDocument;

              var layers = docRef.layers;

              var aB = docRef.artboards;

              var swatches = docRef.swatches;

              var obj = {};

              var arr = [];

           

              for(var a=0;a<layers.length;a++)

              {

                  var thisLayer = layers[a];

                  if(thisLayer.locked)

                  {

                      thisLayer.locked = false;

                  }

                  if(!thisLayer.visible)

                  {

                      thisLayer.visible = true

                  }

              }

           

              app.executeMenuCommand("Text Objects menu item");

              app.executeMenuCommand("outline");

           

              var saveOpts = new IllustratorSaveOptions();

              saveOpts.embedICCProfile = true;

              saveOpts.pdfCompatible = false;

           

              var dest = "~/Desktop/"

              var saveFile = new File(dest + "myFile.ai");

           

              docRef.saveAs(saveFile,saveOpts);

              docRef.close();

           

           

          }

          test();