Skip to main content
Inspiring
December 5, 2024
Answered

Script to apply arrowhead in Stroke (Indesign). Help?

  • December 5, 2024
  • 1 reply
  • 339 views

Can someone help me create a script? I'm trying to create a script to create a path and then apply "arrowheads" to it. I can't apply "arrowheads" to a created path, only create the path. I've tried other possibilities, but I can't. Can anyone solve this?

 

var doc = app.activeDocument;
var page = doc.pages[0];

// Create a line with a stroke
var line = page.graphicLines.add();
line.strokeWeight = 2;
line.strokeColor = doc.swatches.itemByName("Black");

// Set the start and end points of the line (example coordinates)
line.paths[0].entirePath = [[10, 10], [40, 10]];

// Apply a start arrowhead to the line
line.paths[0].startArrowhead = ArrowHead.TRIANGLE_ARROW_HEAD;

// Apply an end arrowhead to the line
line.paths[0].endArrowhead = ArrowHead.TRIANGLE_ARROW_HEAD;

 

 

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#GraphicLine.html#d1e223036

 

There is left and right - not start / end. 

 

1 reply

Robert at ID-Tasker
Robert at ID-TaskerCorrect answer
Legend
December 5, 2024
eusoujpAuthor
Inspiring
December 6, 2024

That's right, it makes perfect sense. I couldn't make the connection between the code and the sides either. Thanks!

if (myGraphicLine instanceof GraphicLine) {
myGraphicLine.leftLineEnd = ArrowHead.SIMPLE_ARROW_HEAD;

myGraphicLine.rightLineEnd = ArrowHead.TRIANGLE_ARROW_HEAD;
}