Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Script to move images to seperate layer

Return to Member Forum

  • Author
    Posts
    • #111828

      Hi all.

      Does anyone have a script that would move all images(in their frames) in a document, to a layer named Images?

      Or Help me with the obviously wrong script here.

      I’m trying to select all graphics. Or is it all graphic frames. I have no hair left!
      Ideas appreciated

      L = app.activeDocument.layers.item (‘Images’);
      app.activeDocument.allGraphics.everyItem().itemLayer = L;

      Thanks

      Bill

    • #111829
      Aaron Troia
      Participant

      Bill,

      I think I had this question a few years back and someone answered and gave me a script that I feel I should pass on.

      
      //Get a collection of graphics in the doc
      var imgs = app.activeDocument.allGraphics;
      
      //Loop through the graphics in the collection
      for(i=0; i<imgs.length;i++) {     
      	//use function move(to) to place graphics in layer named myLayer
      	imgs[i].parent.move(app.activeDocument.layers.item('Images'));
      }
      
      //Set myLayer layer options to be not visible and not printable
      app.activeDocument.layers.item('images').visible=true; 
      app.activeDocument.layers.item('images').printable=true;
      

      Aaron

      • #111831

        Aaron,

        Thanks you very much. Really thank you.
        This worked a treat!

        Time to regrow my hair!

        Thanks again

        Bill
        :)

    • #111833

      There’s really something that bothers me more and more in all the forums:

      When a guy [especially a scripter] works really hard to learn something [as awesome and magic as Javascript] and finally decides to share it without directly asking something in return, it’s really painful for me to read someone can “obliterate” his[her] name and however use his[her] work.

      Lots here [and elsewhere] don’t appreciate my sincere outspokenness! … [and I don’t care!]
      Aaron, I appreciate you enough [especially on your “Grep” knowledge and contribution on this forum] to not truly having something personal against you! …

      This script, as simplistic for a scripter, was graciously posted by Loïc Aigon 10 years ago on Adobe’s InDesign Scripting Forum!

      I hope he will appreciate someone remembered his signing and his real and appreciable knowledge!

      Best,
      Michel

      • #111834
        Aaron Troia
        Participant

        Michel,

        I fully agree and thank you for calling me out on that. I didn’t mean to initially steal Loic’s code, I should have waited and done my due diligence to find the dev’s name before posting it. Had I remembered (or found the original post) I would have linked directly to it without hesitation.

        I will remember this anytime I post code from here on out, I have gotten so much help in this forum and don’t want to get a reputation for not giving recognition where it is due.

        Aaron

      • #111835

        ;-)

    • #111968
      Anonymous
      Inactive

      …posted by Loïc Aigon 10 years ago on Adobe’s InDesign Scripting Forum!

      hence my shock looking at the code 10 years later. Definitively worth a rewrite.

    • #113681

      Hi
      Totally new to JS (native Applescript speaker ;) )
      I used this “simple” script to learn the syntax of ExtendScript, a great start, also found a small fault in it.
      in:
      imgs[i].parent.move(app.activeDocument.layers.item(‘Images’));
      Images is with capital “I”
      and
      app.activeDocument.layers.item(‘images’).visible=true;
      app.activeDocument.layers.item(‘images’).printable=true;
      ..images is with lower case “i”

      After change the script runs great!
      Thank you for teaching me! =)
      Cheers
      Johan

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Forum Ads