2 Replies Latest reply on Sep 27, 2010 3:50 PM by Muppet Mark-QAl63s

    Please help in converting applescript to javascript/VB Script

    karthikb1987 Level 1

      Please help in converting applescript to javascript/VB Script

       

       

      tell application "Adobe Illustrator"
         activate
         tell document 1
         
          set visible of layer myLayerName to true
          try
           set (visible of layers whose name is not myLayerName) to false
          end try
         
          set selection to {}
          try
           set selection to (page items of layer myLayerName whose class is not placed item)
           if selection is {} then return
           set theTargetBounds to visible bounds
          end try
          copy
         end tell
        end tell

       

      Thanks

        • 1. Re: Please help in converting applescript to javascript/VB Script
          [Jongware] Most Valuable Participant

          This is an AppleScript for Illustrator, not for InDesign. You probably meant to ask in the Illustrator Scripting forum.

           

          (There are no differences in the language Javascript between InDesign and Illustrator, but the actual commands that interface with the base program -- the Document Object Model -- differ wildly.

          I'm still surprised how many features the Illustrator DOM misses. That is enough to warrant just about a full re-write of every script for Illustrator, mainly 'dumbing it down'. A Big Missed Opportunity from the Illustrator programming team, if you ask me.)

          • 2. Re: Please help in converting applescript to javascript/VB Script
            Muppet Mark-QAl63s Level 4

            I'm still surprised how many features the Illustrator DOM misses. That is enough to warrant just about a full re-write of every script for Illustrator, mainly 'dumbing it down'. A Big Missed Opportunity from the Illustrator programming team, if you ask me.)

             

            me too…

             

            #target illustrator
            
            var docRef = app.activeDocument;
            
            var docLayers = docRef.layers;
            
            for (var i = 0; i < docLayers.length; i++) {
                 docRef.layers[i].visible = false;
            }
            
            var myLayer = docRef.layers.getByName('Foo'); // Change to your name here…
            myLayer.visible = true;
            docRef.selection = null;
            
            for (var j = 0; j < myLayer.pageItems.length; j++) {
                 if (myLayer.pageItems.typename != 'PlacedItem') {
                      myLayer.pageItems[j].selected = true;
                 }
            }
            
            app.redraw();
            var targetBounds = docRef.visibleBounds;
            //$.writeln(targetBounds);
            if (myLayer.hasSelectedArtwork) app.copy();
            

             

            The above should be fairly close (or so I think). You did NOT define your layer variable so the posted AppleScript did NOT work for me? I don't know what you are using the bounds for either? Im only CS2 so no app.copy() for me to test with…

            1 person found this helpful