Copy link to clipboard
Copied
Hello everyone,
I have this layer, and I want to script a subtraction of a rectangle that is the lower 40% of the canvas height from my selection.
this way:
END RESULT :
any tips?
...function selMake(t,l,b,r,E,M) { //Top, Left, Bottom, Right, true = Elipse false=Rectangular?, Mode(0=select, 1=add, 2 = subs, 3 = inter)
try{
var desc1324 = new ActionDescriptor();
var ref496 = new ActionReference();
ref496.putProperty( cTID('Chnl'), cTID('fsel') );
desc1324.putReference( cTID('null'), ref496 );
var desc1325 = new ActionDescriptor();
desc1325.putUnitDouble( cTID('Top '), cTID('#Pxl'), parseFloat(t) );
desc1325.putUnitDouble( cTID('Left
Copy link to clipboard
Copied
function selMake(t,l,b,r,E,M) { //Top, Left, Bottom, Right, true = Elipse false=Rectangular?, Mode(0=select, 1=add, 2 = subs, 3 = inter)
try{
var desc1324 = new ActionDescriptor();
var ref496 = new ActionReference();
ref496.putProperty( cTID('Chnl'), cTID('fsel') );
desc1324.putReference( cTID('null'), ref496 );
var desc1325 = new ActionDescriptor();
desc1325.putUnitDouble( cTID('Top '), cTID('#Pxl'), parseFloat(t) );
desc1325.putUnitDouble( cTID('Left'), cTID('#Pxl'), parseFloat(l) );
desc1325.putUnitDouble( cTID('Btom'), cTID('#Pxl'), parseFloat(b) );
desc1325.putUnitDouble( cTID('Rght'), cTID('#Pxl'), parseFloat(r) );
if (E) desc1324.putObject( cTID('T '), cTID('Elps'), desc1325 );
else desc1324.putObject( cTID('T '), cTID('Rctn'), desc1325 );
desc1324.putBoolean( cTID('AntA'), true );
switch(M){
case 0:{
executeAction( cTID('setd'), desc1324, DialogModes.NO );
break;
}
case 1:{
executeAction( cTID('AddT'), desc1324, DialogModes.NO );
break;
}
case 2:{
executeAction( cTID('SbtF'), desc1324, DialogModes.NO );
break;
}
case 3:{
executeAction( cTID('IntW'), desc1324, DialogModes.NO );
break;
}
default:
break;
}
}catch(er){}
};
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
function cTT(v) {return charIDToTypeID(v)};
function sTT(v) {return stringIDToTypeID(v)}
var h = app.activeDocument.height
var w = app.activeDocument.width
selMake((h*0.6),0,h,w,false,2)
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
I tried this now in 2024, but it did not work for me, do you guys maby know why ?