1 person found this helpful
Well you've come to the right place :-)
First of all, have you searched the internet for scripts?
There's a good chance that someone else have done the same as you want to do, or at least something very similar.
If you can find a script that do, or allmost do, what you need, you could learn to modify it, or perhaps someone here will do it for you :-)
Thomas B. Nielsen
1 person found this helpful
One of the sample scripts installed by InDesign is called cropmarks.jsx. I guess that it will have some pointers for you.
Thanks for the advice - I have done a search here and over the net but not been able to find what I need unfortunately.
Thanks for the tip on the free script, again unfortunately I've already looked at this, but having zero experience or knowledge of scripting (other than creating "actions" which gives me no info on how the codes created) I don't really have a clue what refers to what.
Thanks - i did see these but will take another look and try to figure it out....
As said above, we can walk you through a custom script step by step
Let me get you started with this: the ESTK Help -- or one of its variants -- is your biggest friend!
"1. Find document size"
Use app.activeDocument.documentPreferences.pageWidth and app.activeDocument.documentPreferences.pageWidth for these.
"2. Add a horizontal line at 0.1 pt size,
Length = document width + 20mm
X axis = document width divided by 2 (line sits centrally, hanging 10mm over left and right edges)
Y Axis = 0mm"
app.activeDocument.graphicLines.add () adds a new graphic line on a default position. You can then move it into position.
Doing the math results in this little script to add the first line:
newLine = app.activeDocument.graphicLines.add();
newLine.paths.pathPoints.anchor = [ -20, 0 ];
newLine.paths.pathPoints.anchor = [ app.activeDocument.documentPreferences.pageWidth+20, 0 ];
newLine.strokeWeight = 0.1;
newLine.strokeColor = app.activeDocument.swatches.item("Registration");
newLine.strokeStyle = app.strokeStyles;
A 'line' can consist of a number of paths (consider a compound path), but usually has only one single path. A new line only has two endpoints -- the anchors --, and you can move these around by setting the coordinates with an array of [ x y ] values. Important: These values are in your current measurement units! I'm assuming, for convenience, that you have mm for this. If you see 20 inch wide lines popping up, you know why :-) Another important point: the rulers' zero point must be in the top left of your document. All "absolute" values are relative to this zero point.
It is perfectly possible to have the script set the correct measurements and move the zero point for you, but now you know why it has to do that.
Notice you don't explicitly move the center of the new line; in this case, it's easier to immediately move each end point into its correct place.
There are a few other things you can do to make the script misbehave. The new line is created with the active defaults in your document. You could have the script change the defaults to the correct settings, but that's not really user friendly. Instead, you can change everything by applying new values to the new line only. You can see I set its weight, color, and stroke style.
A few points on these latter three settings:
- Didn't I just tell you all values are in current measurement units? Well, line widths are always in points (as is font size and line spacing).
- The correct line color is grabbed by asking for a swatch called "Registration" -- you might want to replace this with another swatch name.
- The stroke style is grabbed by blindly using the very first stroke style in InDesign. I found out the hard way using "Solid" (or what is it called) does not work across different languages. Much later I learned there is a language-independent way of using the names, but hey, that's harder to remember.
Wow!! Thank you Jongware, that's really helpful!!
I'v never done anything like this before so I'll have a go as soon as i get chance and let you know how i get on.
Thanks very much!
Thanks very much for your help on this - i've been able to get what I initially wanted working so all's good! Now I'm goign to try and tweek it to do other things!
Everyone's input was greatly appreciated.
Happy tweeking. You won't (hopefully) find it hard to adjust this script to draw vertical lines, or lines not spanning the entire document. (Etc.) From here on, The World Is Your Lobster.
I finally remembered the language-independent way of accessing 'named' items, but on testing ... my InDesign failed! It seems a gremlin struck, and instead of changing the strokeStyle of the new line, I should have changed the strokeType (which is changed to another strokeStyle -- hence the confusion).
app.selection.strokeType = app.activeDocument.strokeStyles.item("$ID/Thick - Thick");