Copy link to clipboard
Copied
Hi! Is there a way to produce a horizontal line using script. That is 30" long, 2pt line thickness, dashed (4pt dash 4pt gap) in 30% black, placed in the X, Y axis. And another line that is the same but vertical. Thanks!
You would want to settle on a measurement unit, so if you want to use Millimeters, set the length of the line in millimetrs rather than inchesā30" = 762mm
You create a line by adding it to the page. In my example the lines are getting added to the activePageāmy p variable:
var p = app.activeWindow.activePage;
The position of the line is set via the geometricBounds property, which is an array of 4 points [y1,x1,y2,x2], so a 3rd vertical line could be added as:
var vLine2 = p.graphicLines.
...
Copy link to clipboard
Copied
Sure, you'd use the Line object. What do you mean by "Placed on the X, Y axis"? Where exactly would it go in relation to the page. And what page are you building it on, every page? What is the use for this script as part of your workflow that can't be solved by leveraging parent pages?
Copy link to clipboard
Copied
I'm just looking for something like this but using script: https://community.adobe.com/t5/indesign-discussions/graphic-line-properties-apple-script-cs3-cs4/td-...
Copy link to clipboard
Copied
Hi @lalaland_ , Try this:
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var doc = app.activeDocument;
var p = app.activeWindow.activePage;
var l = 30;
var lp = {
strokeColor:"Black",
strokeWeight:2,
strokeType: "Dashed",
strokeTint: 30,
strokeDashAndGap: [4,4],
strokeAlignment:StrokeAlignment.CENTER_ALIGNMENT
}
var hLine = p.graphicLines.add({geometricBounds: [0,0,0,l*72]});
var vLine = p.graphicLines.add({geometricBounds: [0,0,l*72,0]});
hLine.properties = lp;
vLine.properties = lp;
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Copy link to clipboard
Copied
Thank you! Is there a way to place the lines on X: 100mm, Y: 0 for the vertical, and X:0, Y:100mm for the horizontal one?
Copy link to clipboard
Copied
Iāve set the measurement units as points, so 100mm = 283.465pts
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var doc = app.activeDocument;
var p = app.activeWindow.activePage;
var l = 30;
var xy = 283.465 //100mm as points
var lp = {
strokeColor:"Black",
strokeWeight:1,
strokeType: "Dashed",
strokeTint: 30,
strokeDashAndGap: [4,4],
strokeAlignment:StrokeAlignment.CENTER_ALIGNMENT
}
var hLine = p.graphicLines.add({geometricBounds: [xy,0,xy,l*72]});
var vLine = p.graphicLines.add({geometricBounds: [0,xy,l*72,xy]});
hLine.properties = lp;
vLine.properties = lp;
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Copy link to clipboard
Copied
Thank you Rob! Also how do you go about adding another vertical line on its own at X: 170mm, Y: 148mm?
Copy link to clipboard
Copied
You would want to settle on a measurement unit, so if you want to use Millimeters, set the length of the line in millimetrs rather than inchesā30" = 762mm
You create a line by adding it to the page. In my example the lines are getting added to the activePageāmy p variable:
var p = app.activeWindow.activePage;
The position of the line is set via the geometricBounds property, which is an array of 4 points [y1,x1,y2,x2], so a 3rd vertical line could be added as:
var vLine2 = p.graphicLines.add({geometricBounds: [148,170,148+l,170]});
vLine2.properties = lp;
Here the units are millimeters:
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
var doc = app.activeDocument;
var p = app.activeWindow.activePage;
var l = 762; //30" as millimeters
var xy = 100
var lp = {
strokeColor:"Black",
strokeWeight:1,
strokeType: "Dashed",
strokeTint: 30,
strokeDashAndGap: [4,4],
strokeAlignment:StrokeAlignment.CENTER_ALIGNMENT
}
var hLine = p.graphicLines.add({geometricBounds: [xy,0,xy,l]});
var vLine = p.graphicLines.add({geometricBounds: [0,xy,l,xy]});
hLine.properties = lp;
vLine.properties = lp;
//X: 170mm, Y: 148mm?
var vLine2 = p.graphicLines.add({geometricBounds: [148,170,148+l,170]});
vLine2.properties = lp;
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Copy link to clipboard
Copied
Thank you!!! I learnt a lot!