4 Replies Latest reply on Apr 21, 2013 11:38 AM by CarlosCanto

    Is it possible to apply a Transform effect from Javascript ?

    orgicus Level 1

      I was wondering if it's possible to do what Effect > Distort & Transform > Transform does from JS.

      I had a look at the documentation and found nothing in that direction.

       

      The closest thing I found was PageItem.applyEffect(effectXML) looking at the Object Model Viewer in Extend Script Toolkit,

      but couldn't find documentation for it and I suspect it might have something to do with SVG filters perhaps ?

       

      In conclusion:

      1. Is it possible to apply a Transform effect from JS (and if so, how )?
      2. How can applyEffect be used ?

       

      Thanks,

      George

        • 1. Re: Is it possible to apply a Transform effect from Javascript ?
          CarlosCanto Adobe Community Professional & MVP

          up to CS5 you can't, the closest thing is to apply the effect (manually), save it as a Graphic Style (manually), then your script could access this saved Graphic Style and apply it to an object.

          1 person found this helpful
          • 2. Re: Is it possible to apply a Transform effect from Javascript ?
            orgicus Level 1
            up to CS5 you can't

             

            So you mean it's possible from CS5 upwards ? If so, how ?

             

            Also, in the meantime I had a look at the graphicStyles reference and thought that I can ease the manual styles creation a bit.

            For example if a packed extension needs this functionality, a graphic style preset can be packaged (as far as I can see it's just

            an ai document) then opened from JS so it can be applied.

             

            I tried this:

             

             

            var file = new File("/Applications/Adobe/Adobe\ Illustrator\ CS6/Presets.localized/en_US/Graphic\ Styles/Custom.ai");
            var options = new OpenOptions();
            options.openAs(LibraryType.ILLUSTRATORARTWORK);
            //var stylesDoc = app.open (f, DocumentColorSpace.RGB, OpenOptions.openAs(LibraryType.GRAPHICSTYLES));
            
            

             

            but I get an error:

            LiveObject() is not a function

            which isn't very descriptive to me. How can I open an .ai graphic style from js correctly ?

             

            Thank Carlos!

            • 3. Re: Is it possible to apply a Transform effect from Javascript ?
              CarlosCanto Adobe Community Professional & MVP

              you can open an ai file with the graphic styles in it, but it will behave exactly as if you open it manually in the user interface, the graphics styles will load in the Graphic Styles Libraries Palette, but you won't have access to them via scripting, you'll have to click on them (manually) to add them to the active document's Graphic Styles Palette...then you can access them via scripting.

               

              var fileRef = File("/Applications/Adobe/Adobe\ Illustrator\ CS6/Presets.localized/en_US/Graphic\ Styles/Custom.ai");
              if (fileRef != null) {
              var optRef = new OpenOptions();
              optRef.updateLegacyText = true;
              optRef.openAs = LibraryType.GRAPHICSTYLES;
              var docRef = open(fileRef, DocumentColorSpace.RGB, optRef);
              }
              
              • 4. Re: Is it possible to apply a Transform effect from Javascript ?
                CarlosCanto Adobe Community Professional & MVP

                So you mean it's possible from CS5 upwards ? If so, how ?

                no, I meant I don't have CS6 to be able to tell