Graphic Lines script
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!
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!
Thank you Rob! Also how do you go about adding another vertical line on its own at X: 170mm, Y: 148mm?
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;
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.