I'm a long time pre-presser, but just *gasp* discovered scripts. Being self taught sometimes results in not realizing what's available.
I'm guessing this already exists, but I've searched and can't find it easily -
I'm looking for an InDesign (5.0) script that would label a selected object with it's height and width. I've seen a script that gives the percentage, which is close, but not quite what I need. In a perfect world I'd get two labels, one for the width and one for the height, but I'm not picky – right now I'm doing this by hand so any automation would speed my life along.
Can you make a mock-up image of what it should look like?
The percentage thingy you found may well have been mine; it creates a text frame the size of the original image on a new layer and writes the size into this, so you can easily switch off all labels at once. It's a piece a cake to have it write out width and height, in any measurement unit you like and with as much precision decimals as you can care about.
Attachment one.jpg is what I'm doing by hand, now.
Attachment two.jpg shows what I'm guessing would be possible – either one line showing height x width (3 decimals, always in inches is what I need to show) or maybe the two text boxes – one showing height and one showing width so I can scoot them to their locations. Actually, one line would be easier – I can just draw the rules to match and leave the text either above or below the graphic (wherever is easiest for the script to place it).
Post edited 4:23 pm – January 13, 2012 by Jongware
… Actually, one line would be easier – I can just draw the rules to match and leave the text either above or below the graphic (wherever is easiest for the script to place it).
Actually, all of the above is possible using regular scripting No extra plug-in needed, just a bit of know-how.
1. Run on a single, plain selection — one with the black arrow. It will add labels and lines for width and height. The current selected object will stay selected.
2. It puts the labels and lines on a layer called "ImageLabel", which is set to non-printing on creation. If the layer already exists, it doesn't change the existing settings. (If you always want to have it print: to remove the default non-printing setting, change 'printable: false' to 'printable: true' in line 17.) This layer is colored ghastly green by default.
3. The lines and text use a custom swatch called "ImageLabel". It's an RGB color (because presumably it's just for viewing), but of course I can make it a real CMYK color as well. As per above, you can also run the script once and then adjust the settings — the script won't change it if it already exists.
4. The text has a paragraph style called "ImageLabel" by default. It's set to Helvetica at 12 pt, but you can change these values in the script (for new defaults) in line 30, or simply change the "ImageSize" paragraph style. Same as above.
5. The labels appear centered in their text frames, so the left one has to be wide enough for three decimals. The text frames are set to ignore all text wrappings to prevent unexpected overset text.
6. You didn't ask for this, but it groups the text frames and lines together for each image. Might come in handy; but if you find yourself ungrouping everything every time because stuff is just not In The Right Place (and that's always a different place (*)), delete the entire line near the bottom that says "app.activeDocument.groups.add …"
(*) I mean, if you find that everything is always off by exactly 0.1″, it's easier to change the script. If the value is always different, remove that grouping line.
7. It comes with an Undo! Undoing will, uh, undo everything the script did. If you ran it twice, a first Undo will remove the last labels it added. The second time it will also remove the layer, paragraph style, and swatch (but only if it created them in the first place).
… That's about it. I tested with CS4 but I'm totally fairly reasonable sure it'll work on CS5 and later as well. If not, yell and I'll think about what needs tinkering with.
removed from post — sorry, it was too complicated for the forum
That is totally freakin' awesome. And the way you documented it made me kinda sorta understand how you did it.
We do need the layer to always be printable (but it doesn't matter if it's RGB or CMYK – it just needs to print on the hard copy production proofs that go out to production, then we delete the layer when we set up for plates/film/whatever the thing becomes)., so I changed that. Everything else is just amazing – it runs just fine in 5.0.
Not sure what I can offer in return, but you've cut my workload a heap!
Ok, so now there's a little trouble. This script works great for me. I made only one mod – I changed "false" to "true" regarding the print state of the new layer.
But when I shared it with a co-worker, his gives us the attached error. He can run other scripts, but not this one. Any idea where to start?
Can you check if this copy is complete? The very first thing the script does is checking if the layer, paragraph style, and swatch "ImageLabel" exist — and if any of them don't, it creates them! So theoretically, this error — what it says is basically 'I don't have access to this style called "ImageLabel"' — ought not have happened.
Can you verify on a simple rectangle in a blank new document if the layer, paragraph style, and swatch are created correctly?
Unfortunately, we already thought about that, and he gets that same error on a new document that only has a blank rectangle.
But – my other co-worker (there are three of us) has no trouble with the script.
We are all running CS5.0. We tried to poke about for differences between the 3 machines, but we're all running the same system. Those two are running Version 7.0 of CS5, I'm running 7.04 (you'd think I'd be the one with trouble since I'm odd man out).
But here's something you didn't ask but we tried anyway – if we set up a Paragraph Style called ImageLabel before we run it, it works. We didn't make it match the specs of ImageLabel in the script – we just renamed one of our existing styles, so the text overset the box, but it didn't crash and it drew the rules.
Errors out when using with IDCS3. Shame I was looking for this exact script two weeks ago… Sounds like maybe it has some CS4+ code in the JS, maybe someoen can offer some suggestions for modifying it.
Oh the irony — in a script from the writer of Add Undo to Your Script! I forgot to include the magic lines at the top that checks the InDesign version.
This is a quick fix: Insert the following lines below the 5th line (if (app.docu…), above the 6th line (app.doScript ..):
if (app.version < 6)
labelItem(app.selection[0]);
else
– it ought to get the main part of the script up and running. Unfortunately, it's still possible that that in turn may contain CS4-specific constructions, so if it still fails call me back in the morning.
I really love the narrative in this thread! What a community. If we made a commercial for InDesignSecrets I think just scrolling through the posts from top to bottom would be a Clio winner. Thank you so much, jongware, especially! (And collywolly to the rescue!)
This script is great! I've managed to alter the script to make the labels and lines black, make their layer printing, have them display in millimeters with mm after it and now I'm going through adjusting the lines and boxes to be in mm instead as well. Great fun an very useful!