Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Subtract Selection

Engaged ,
May 27, 2019 May 27, 2019

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?

TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 27, 2019 May 27, 2019

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

...
Translate
Adobe
Explorer ,
May 27, 2019 May 27, 2019

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 27, 2019 May 27, 2019

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 14, 2024 Oct 14, 2024
LATEST

I tried this now in 2024, but it did not work for me, do you guys maby know why ? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines