Image scripting..

Learn / Forums / InDesign User Groups / Image scripting..

Viewing 17 reply threads
  • Author
    Posts
    • #103086
      Sayed Mohammed
      Participant

      Hi..

      Is there any script to keep images on one layer on indesign?

      Thanks to all

      Sayed Mohammed

    • #103102
      Erica Gamet
      Participant

      Do you already have the images on the page? You can select them all, then move the little colored proxy in the Layers panel to the layer you want to put them on.

    • #103103
      David Blatner
      Keymaster

      There is no way to keep them on one layer, but perhaps there could be a script to move them all to one layer. This script is similar, but it works on buttons: https://in-tools.com/article/scripts-blog/buttons-to-layer-script/

    • #103137
      Sayed Mohammed
      Participant

      Erica Gamet and David Blatner
      I would like to say something on this occasion, which is that I learned a lot from you, otherwise I would not have been able to complete many of the publications I have produced …

      Sayed MOhammed ali
      Accept my greetings

    • #103138

      Hi,

      If you talk about all the not-anchored images in the doc, a simple 2-code-lines script will be enough! ;-)

      Best,
      Michel, from FRIdNGE

    • #103139
      David Blatner
      Keymaster

      Sayed, I’m very happy that we have been able to be helpful to you!

      Michel, do you wish to share your two lines of code?

    • #103140

      Try:

      var myLinks = app.activeDocument.links, L = myLinks.length;
      while ( L– ) if ( myLinks[L].parent.parent.parent.constructor.name != “Character” && myLinks[L].parent.parent.itemLayer.name != “Layer 1” ) myLinks[L].parent.parent.itemLayer = “Layer 1”;

      … But there’re really 2 lines!

      I prefer this personal version [alert messages with counter + FRIdNGE logo + sku, global undo]!

      https://imgur.com/a/sZkBn

      … Really more expansive than “for free”, just because there’re 92 code lines! =D

      Best,
      Michel, from FRIdNGE
      [email protected]

    • #103143
      David Blatner
      Keymaster

      Michel, when you post code here, please use a the code html tag, or else the code get messed up (curly quotes, etc.)

      However, I tried to clean this up and it still does not work for me:

      var myLinks = app.activeDocument.links, L = myLinks.length;
      while ( L– ) if ( myLinks[L].parent.parent.parent.constructor.name != "Character" && myLinks[L].parent.parent.itemLayer.name != "Layer 1" ) myLinks[L].parent.parent.itemLayer = "Layer 1";

      I am getting an error that says: ) does not have a value and the offending text is )

    • #103146

      Hi David,

      Change: while (L–)

      html tag?

      Best,
      Michel

    • #103147

      Grrrr! …Thanks to type 2 en-dashs!

    • #103148
      David Blatner
      Keymaster

      Ah ha! Mercí! (Or is it mercì?)

      OK, now there is no syntax error, but the script does not move any of my images to a different layer. Should the following move all the images to Layer 2?


      var myLinks = app.activeDocument.links, L = myLinks.length;
      while (L--) if (myLinks[L].parent.parent.parent.constructor.name != "Character" && myLinks[L].parent.parent.itemLayer.name != "Layer 1") myLinks[L].parent.parent.itemLayer = "Layer 2";

    • #103149

      Not my day! … but not yours too! =D

      The Script checks all the images: as indicated, if not on “Layer 1”, they are moved on it!

      Best,
      Michel

    • #103152

      Of course, the Script checks if the image is “anchored”! If not, it can move it! ;-)
      We could add more checkings as if it’s a .pdf file or a .png file …

      Best,
      Michel

    • #103153
      David Blatner
      Keymaster

      Thank you, Michel! OK, I see my mistake. This script works if the layer is called “images” — of course, you can change that to any other layer name, but it must be changed in 2 places in the script.

      var myLinks = app.activeDocument.links, L = myLinks.length;
      while (L--) if (myLinks[L].parent.parent.parent.constructor.name != "Character" && myLinks[L].parent.parent.itemLayer.name != "images") myLinks[L].parent.parent.itemLayer = "images";

      I understand that you have written a more robust script that can do much more, and does error checking (and that people can pay you for that version). But thank you for sharing this simple free version.

    • #103154

      “… Pour vous servir, Monseigneur !” [in French]

      :-)
      Michel

    • #103166
      Sayed Mohammed
      Participant

      I would like to thank everyone who helped and answered the previous question, and I wish that if Mr. David take a snapshoot of the script and how use in th grib (on find and change).

      thanks again….
      Sayed MOhammed
      [email protected]

    • #103168
      David Blatner
      Keymaster
    • #103259
      Sayed Mohammed
      Participant

      thanks Mr. David Blatner

Viewing 17 reply threads
  • You must be logged in to reply to this topic.
>