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!
Unable to select line created by script
-
Mike Hale
Unable to select line created by script
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.
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.