Unable to select line created by script

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

poortip

Unable to select line created by script

Post by poortip »

Hi,

I encountered a problem today. I wrote a script to draw a line on active layer. The script works fine. The line is drawn as part of the selected layer. The script doesn't create a separate shape layer for it. Now, when I try to select that line using the Selection tool, but unable to select it.


Here is the code for the script to draw the line:
Code: Select allfunction drawLine(doc, start, stop)
{
var startPoint = new PathPointInfo();
startPoint.anchor = start;
startPoint.leftDirection = start;
startPoint.rightDirection = start;
startPoint.kind = PointKind.CORNERPOINT;
var stopPoint = new PathPointInfo();
stopPoint.anchor = stop;
stopPoint.leftDirection = stop;
stopPoint.rightDirection = stop;
stopPoint.kind = PointKind.CORNERPOINT;
var spi = new SubPathInfo();
spi.closed = false;
spi.operation = ShapeOperation.SHAPEXOR;
spi.entireSubPath = [startPoint, stopPoint];
var line = doc.pathItems.add("Line", [spi]);
line.strokePath(ToolType.PENCIL);
line.remove();
};
drawLine(app.activeDocument, [100,100], [100,200]);

Can anyone help me out here..?
Thanks!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Unable to select line created by script

Post by Mike Hale »

You could add a layer before creating the line.
If you are sure of the brush size the stroke you may be able to make a selection using the start/end points.
If you want a shape layer you could use scriptlistener to create a solid fill layer, create the path without stroking, then make a vector mask from the path.