3 Replies Latest reply on Apr 17, 2010 2:23 AM by HarboSenior

    Deleting frame of a certain color [CS3, JS]

    HarboSenior

      Could someone please tell me how to target and delete a frame which has a certain fill color?

       

      In the project I'm working on, one frame of unassigned content has a fill color named "NEW_M_RED" and I have been trying to get rid of the frame.

       

      I have a loop which successfully deletes text frames with a certain content

       

      So I tried slotting in a bit to check if the current item in the loop (irrespective of its constructor) is the one I'm looking for...

       

      if(myPageItems[i].fillColor == app.activeDocument.swatches.item("NEW_M_RED"))

       

      But the script is halting with the the error message "the content of this object has multiple values for this graphic attribute".

       

      I've not been having much luck in my searches of the forum... So, help!

        • 1. Re: Deleting frame of a certain color [CS3, JS]
          HarboSenior Level 1

          Sorted it with the help of my old pals, try and catch.

           

          Been out of the game for a couple of months. Rust sets in quickly!

          • 2. Re: Deleting frame of a certain color [CS3, JS]
            [Jongware] Most Valuable Participant

            I think if you check the page(s) where it fails on, you might find some groups. As I recently learned on this very forum, both the group itself and all of its contents are included into allPageItems.

             

            You might be able to remove the try..catch if you first check the 'current' settings for the color. It should be 'undefined' in a mixed setting. (I'm not sure if it's worth removing try..catch -- the script might run just a little bit faster. But I'm a stickler for details.)

            1 person found this helpful
            • 3. Re: Deleting frame of a certain color [CS3, JS]
              HarboSenior Level 1

              Thanks for the reply, Mr J, I'll be getting back to this next week. I've had the fun part: having the idea and making it work. Now I'm going to tighten it up and make it work consistently. While I'm at it I'll experiment along the lines you suggested. It'll be good to get a handle on how to deal with groups. Some of our designers seem to act under the assumption that Mr Clumsy is going to be the next person to open their page, so they create grouped and locked fortresses! I'm their worst nightmare, Mr Demolition Man...