can you tell us what doesn't work? what error?
1 person found this helpful
I think I know what the problem is with this code.
You can lock and hide a *regular* page item, but not an image. An Image is something *inside* a regular page item; it's something you select with the *white* arrow, not the usual black selection arrow. If you want to hide and/or lock the image, you have to do so with its *parent* -- which is the object 'in' which the image appears.
You already retrieve the parent of all of your items near the top of the loop, but you only have to do so for the "Image" case.
(Post-Thought Edit) Hmm ... are you sure that 'allPageItems' include "Image" objects as well? After all, as I said above, an 'image' is *not* a regular 'page item'.
There are no error while script is working, but the layer don't lock and don't hide at end.
And some graphic and text frame aren't scanned by the script. Only one is find.
How specifically lock the item when conditions are validated ?
How to use the item function ?
What is the correct structure to use page item ?
Thanks Jongware for your help, when i try
Test[a].parent.locked = true;
All work good here
But now, some TextFrame in my document have Tag XML, so they are not empty.
When the sript is run, the file is in the final part of execution, we no longer need XML Tag on the empty elements.
I search a part of code for untag TextFrame who are empty.
Some TextFrame have been tagged several times and appear like this :
[NAME] [/NAME] [NAME] [/NAME]
Anyone can help me ?
I find a part of code for search with GREP and the code work when i do Find/Remplace in my indesign, but not directly on the script.
Message was edited by: oxyde68
After few tests, script work good with graphics but not with text.
When i test if textframe is empty, all the textframe don't be affected because some have XML tags inside.
I think there are some ways to explore :
- Untag text frame and test if content is empty or equal to " " ( = some spaces ) and delete it.
=> When i untag textFrame, some style and text move, it's not a good solution.
I think test if length is less 5 : untag it.
- Do a search ( like search/replace in indesign app ) with GREP (
search(/^[\s\r\n]+$/))and if is true, delete it.
I find this method on some forums, when i use the formula in indesign with Search/Replace GREP it work, but when i use the same formula in the script it find nothing ...
- Get the exact code ( with invisible characters and tag ) for test if the content is the same
But how to get the code of invisible characters ?