Can the presence of a selection be set to a Boolean ?
Hey!
I am writing a script to check if a path item overlaps the canvas bounds.
As of now my script...
Selects the entire layer/Canvas
Selects the border of the Canvas by a width 3 Pixels,
Makes an Intersect Selection of the path specified
Then checks for a selection in the document.
If selection is present I would like it to return True
If selection isn't present I would like it to return False.
As of now it returns the same Boolean value either way.
I also checked selection bounds and they exist for both, even when there is no visible selection present.
There may be a better method for this, this was just the first idea I had.
Here is the current Code I have
var doc = app.activeDocument
var old_units = app.preferences.rulerUnits;
var ERRORXTARTLAYERS = false
var ERRORXTPATHITEMS = false
app.preferences.rulerUnits = Units.PIXELS;
edgeIntersection();
alert (edgeIntersection())
//alert (ERRORXTARTLAYERS)
//alert (ERRORXTPATHITEMS)
//Functions
function edgeIntersection(){
var edgeIntersectionBool = (intersectSelection())
app.activeDocument.selection.selectAll()
app.activeDocument.selection.selectBorder(2)
if(app.activeDocument.artLayers.length === 1)
{
intersectSelection();
return edgeIntersectionBool;
}
else {
app.activeDocument.selection.deselect()
return ERRORXTARTLAYERS = true;
}
}
function intersectSelection ()
{
if (app.activeDocument.pathItems.length === 1 ){
activeDocument.pathItems[0].makeSelection(0, true, SelectionType.INTERSECT);
if (app.activeDocument.selection){
return true;
}
else {
return false;
}
}
else {
return ERRORXTPATHITEMS = true;
}
}