3 Replies Latest reply on Sep 5, 2011 5:03 AM by JJMack

    How to Perform File->Place via Scripting (CS5)

    mlavie Level 1

      Hi all,

       

      Photoshop contains the option of directly placing one graphic file onto the currently active layer via the menu with File-> Place.

       

      How do I do this in scripting?

       

      TIA,

      mlavie

        • 1. Re: How to Perform File->Place via Scripting (CS5)
          xbytor2 Level 4
          function placeFile(imageFile) {
            function cTID(s) { return app.charIDToTypeID(s); };
          
              var desc18 = new ActionDescriptor();
              desc18.putPath( cTID('null'), imageFile );
              desc18.putEnumerated( cTID('FTcs'), cTID('QCSt'), cTID('Qcsa') );
                  var desc19 = new ActionDescriptor();
                  desc19.putUnitDouble( cTID('Hrzn'), cTID('#Pxl'), 0.000000 );
                  desc19.putUnitDouble( cTID('Vrtc'), cTID('#Pxl'), 0.000000 );
              desc18.putObject( cTID('Ofst'), cTID('Ofst'), desc19 );
              executeAction( cTID('Plc '), desc18, DialogModes.NO );
          };
          

           

           

          This will place an image just fine. After that, you have to worry about transforming the layer to the size and location

          you want it at as well as rasterizing it if you just want pixels instead of a smart object.

          • 2. Re: How to Perform File->Place via Scripting (CS5)
            mlavie Level 1

            @xbytor2: Thanks for the quick response.

             

            I noticed that File->Place does not bring the image's clipping path along with the image. Does your example do that, and if not, would you have any idea how?

             

            TIA,

            mlavie

            • 3. Re: How to Perform File->Place via Scripting (CS5)
              JJMack Most Valuable Participant

              File Place bring in a copy of the file it is embedded in the smart object layer.  So if the file you place in is a layered file like a psd file that has a path the path is in the smart object layer embedded object.  When you double click on the layer's smart object icon in the layers palette and photoshop will open the embedded copy of the psd file in Photoshop you can then update layers and paths in it. When you save your updates Photoshop will update the embedded smart object in your placed smart object layer in your document. Just close the open smart object you noo longer need it open in the document ring.

              1 person found this helpful