1 Reply Latest reply on Jan 31, 2012 8:18 AM by Paul Riggott

    How to Select an Entire Document and Create a WorkPath from the Selection

    mlavie

      For PS Extended 64 bit on Windows 7, using ActionScript

       

      I am trying to create a WorkPath which encompasses an entire Document. Piece of cake, right? WRONG!

       

      I have the following code in ActionScript (ActionScript is close enough to JavaScript that I assume the JS experts here can help).

       

       

      activeDocument.selection.selectAll();

      activeDocument.selection.makeWorkPath(2.0);

       

      After the selectAll, I see in the debugger what looks to me like valid boundaries in the Selection object. However, the makeWorkPath() call fails with "The document does not contain a selection". However, after the code chokes, when I look at the Photoshop screen I see that the document has indeed been selected and if from the Paths window I press the "Make path from selection" icon in the status bar, a Work Path is indeed correctly created. Also, thinking that perhapas the intial backgroundLayer was a special case, i tried copying the layer, making the new layer active and then doing selectAll - but no joy.

       

      TIA,

      mlavie

        • 1. Re: How to Select an Entire Document and Create a WorkPath from the Selection
          Paul Riggott Level 6

          You could use AM code IE:

           

           

          activeDocument.selection.selectAll();
          makeWorkPath(2);
           
          function makeWorkPath(tolerance) {
          var desc = new ActionDescriptor();
          var ref = new ActionReference();
          ref.putClass( charIDToTypeID('Path') );
          desc.putReference( charIDToTypeID('null'), ref );
          var ref2 = new ActionReference();
          ref2.putProperty( charIDToTypeID('csel'), charIDToTypeID('fsel') );
          desc.putReference( charIDToTypeID('From'), ref2 );
          desc.putUnitDouble( charIDToTypeID('Tlrn'), charIDToTypeID('#Pxl'),tolerance );
          executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
          };