Image scripting..
Learn / Forums / InDesign User Groups / Image scripting..
Tagged: indesign script
- This topic has 17 replies, 4 voices, and was last updated 5 years, 11 months ago by Sayed Mohammed.
-
AuthorPosts
-
-
April 15, 2018 at 1:00 am #103086Sayed MohammedParticipant
Hi..
Is there any script to keep images on one layer on indesign?
Thanks to all
Sayed Mohammed
-
April 16, 2018 at 7:33 pm #103102Erica GametParticipant
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.
-
April 17, 2018 at 7:26 am #103103David BlatnerKeymaster
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/
-
April 18, 2018 at 1:34 am #103137Sayed MohammedParticipant
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 -
April 18, 2018 at 2:38 am #103138Michel Allio for FRIdNGEParticipant
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 -
April 18, 2018 at 5:57 am #103139David BlatnerKeymaster
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?
-
April 18, 2018 at 6:22 am #103140Michel Allio for FRIdNGEParticipant
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]!
… Really more expansive than “for free”, just because there’re 92 code lines! =D
Best,
Michel, from FRIdNGE
[email protected] -
April 18, 2018 at 8:03 am #103143David BlatnerKeymaster
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)
-
April 18, 2018 at 8:41 am #103146Michel Allio for FRIdNGEParticipant
Hi David,
Change: while (L–)
html tag?
Best,
Michel -
April 18, 2018 at 8:42 am #103147Michel Allio for FRIdNGEParticipant
Grrrr! …Thanks to type 2 en-dashs!
-
April 18, 2018 at 8:47 am #103148David BlatnerKeymaster
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";
-
April 18, 2018 at 8:51 am #103149Michel Allio for FRIdNGEParticipant
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 -
April 18, 2018 at 9:04 am #103152Michel Allio for FRIdNGEParticipant
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 -
April 18, 2018 at 9:08 am #103153David BlatnerKeymaster
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.
-
April 18, 2018 at 9:17 am #103154Michel Allio for FRIdNGEParticipant
“… Pour vous servir, Monseigneur !” [in French]
:-)
Michel -
April 19, 2018 at 4:00 am #103166Sayed MohammedParticipant
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] -
April 19, 2018 at 9:30 am #103168David BlatnerKeymaster
HI Sayed, here is an article about how to run scripts:
https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php -
April 22, 2018 at 12:39 am #103259Sayed MohammedParticipant
thanks Mr. David Blatner
-
-
AuthorPosts
- You must be logged in to reply to this topic.