4 Replies Latest reply on Mar 12, 2014 12:30 AM by vinomannu

    Alert message need to be added?

    vinomannu Level 1

      Hi All,

       

      I need  to add alert message of number of unlock items in the following script.

       

      #target illustrator

      var myDoc = app.activeDocument;

      var myPageItems = myDoc.pageItems;

      var count = myPageItems.length;

      for ( var i = count-1; i >= 0; i-- ) {if ( ! myPageItems[i].locked){ myPageItems[i].selected = true; }

      {myPageItems[i].locked = false;{ myPageItems[i].selected = true;}}};

       

       

      this script unlock the items, but i need the information of lock items.

       

      Any help.

       

      Regards,

      Vinoth

        • 1. Re: Alert message need to be added?
          W_J_T Level 4

          So you want:

           

          - The ones that were locked, unlocked

          - An alert of how many were unlocked

          - Then have all page items selected

           

          If so, then how about this:

           

          var doc = app.activeDocument;
          var docPageItems = doc.pageItems;
          var unLockedCount = 0;
          for (var i = docPageItems.length - 1; i >= 0; i--) {
              pItem = docPageItems[i];
              if (pItem.locked == true) {
                  pItem.locked = false;
                  unLockedCount += 1;
              }
              pItem.selected = true
          };
          alert("Total Unlocked:\n" + unLockedCount);
          
          
          • 2. Re: Alert message need to be added?
            vinomannu Level 1

            Excellent, its working fine for me.

             

            Additonal help i requried the alert only if they are any unlocked elements in the images, now for all images i am getting the alert.

             

            Could this be solved.

             

            Regards,

            Vinoth

            • 3. Re: Alert message need to be added?
              W_J_T Level 4

              vinomannu wrote:

               

              i requried the alert only if they are any unlocked elements ... Could this be solved.

               

              Does this help, it will only alert if something locked was found.

               

              if (unLockedCount > 0) {
                  alert("Total Unlocked:\n" + unLockedCount);
              }
              

               

              Hope that is what you meant and helps.

              1 person found this helpful
              • 4. Re: Alert message need to be added?
                vinomannu Level 1

                Thanks for the update, it works.