def _place_file(self, path, sg_publish_data):
        """
        Import contents of the given file into the scene.

        :param path: Path to file.
        :param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
        """

        # We can't import in an empty scene.
        if not ph_app.activeDocument:
            QtGui.QMessageBox.warning(None, "Add To Layer", "Please open a document first.")
            return

        # When File->Place'ing a PSD on top of another, here's what the Script Listener generates.
        # (Download at http://helpx.adobe.com/photoshop/kb/plug-ins-photoshop-cs61.html#id_68969)
        # // =======================================================
        # var idPlc = charIDToTypeID("Plc ");
        #     var placeActionDesc = new ActionDescriptor();
        #     var idnull = charIDToTypeID("null");
        #     placeActionDesc.putPath( idnull, new File("/Users/boismej/Documents/1.psd") );
        #     var idFTcs = charIDToTypeID("FTcs");
        #     var idQCSt = charIDToTypeID("QCSt");
        #     var idQcsa = charIDToTypeID("Qcsa");
        #     placeActionDesc.putEnumerated( idFTcs, idQCSt, idQcsa );
        #     // ... I have omitted the transform parameters. We'll take the defaults for now.
        # executeAction( idPlc, placeActionDesc, DialogModes.NO );

        # Get some shortcuts to functions we need to use often.
        stringIDToTypeID = ph_app.stringIDToTypeID

        # For clarity sake, we'll use string IDs instead of charIDs. You can find the Photoshop Rosetta Stone here:
        # http://www.pcpix.com/photoshop/enum.htm

        # Create an action descriptor that will be used to identify which PSD to place in the current one.
        placeActionDesc = RemoteObject("com.adobe.photoshop::ActionDescriptor")
        placeActionDesc.putPath(stringIDToTypeID("null"), RemoteObject("flash.filesystem::File", path))

        # FIXME: Not sure why these are set, but they are mandatory and seem to be transform related. Omitting them
        # makes the Place action fail, even if we don't specify a transform. These flags seem to be poorly documented
        # and code samples found on the web using the Place action uses them without any mention as to what they
        # mean.
        placeActionDesc.putEnumerated(
            stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"),
            stringIDToTypeID("QCSAverage")
        )

        # Everything is setup. Adds the layer to the document.
        ph_app.executeAction(
            stringIDToTypeID("placeEvent"), placeActionDesc, requestStatic("com.adobe.photoshop.DialogModes", "NO")
        )
 def _open_file(self, path, sg_publish_data):
     """
     Import contents of the given file into the scene.
     
     :param path: Path to file.
     :param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
     """
     f = RemoteObject('flash.filesystem::File', path)
     ph_app.load(f)
    def _place_file(self, path, sg_publish_data):
        """
        Import contents of the given file into the scene.

        :param path: Path to file.
        :param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
        """

        # We can't import in an empty scene.
        if not ph_app.activeDocument:
            QtGui.QMessageBox.warning(
                None, "Add To Layer", "Please open a document first."
            )
            return

        # When File->Place'ing a PSD on top of another, here's what the Script Listener generates.
        # (Download at http://helpx.adobe.com/photoshop/kb/plug-ins-photoshop-cs61.html#id_68969)
        # // =======================================================
        # var idPlc = charIDToTypeID("Plc ");
        #     var placeActionDesc = new ActionDescriptor();
        #     var idnull = charIDToTypeID("null");
        #     placeActionDesc.putPath( idnull, new File("/Users/boismej/Documents/1.psd") );
        #     var idFTcs = charIDToTypeID("FTcs");
        #     var idQCSt = charIDToTypeID("QCSt");
        #     var idQcsa = charIDToTypeID("Qcsa");
        #     placeActionDesc.putEnumerated( idFTcs, idQCSt, idQcsa );
        #     // ... I have omitted the transform parameters. We'll take the defaults for now.
        # executeAction( idPlc, placeActionDesc, DialogModes.NO );

        # Get some shortcuts to functions we need to use often.
        stringIDToTypeID = ph_app.stringIDToTypeID

        # For clarity sake, we'll use string IDs instead of charIDs. You can find the Photoshop Rosetta Stone here:
        # http://www.pcpix.com/photoshop/enum.htm

        # Create an action descriptor that will be used to identify which PSD to place in the current one.
        placeActionDesc = RemoteObject("com.adobe.photoshop::ActionDescriptor")
        placeActionDesc.putPath(
            stringIDToTypeID("null"), RemoteObject("flash.filesystem::File", path)
        )

        # FIXME: Not sure why these are set, but they are mandatory and seem to be transform related. Omitting them
        # makes the Place action fail, even if we don't specify a transform. These flags seem to be poorly documented
        # and code samples found on the web using the Place action uses them without any mention as to what they
        # mean.
        placeActionDesc.putEnumerated(
            stringIDToTypeID("freeTransformCenterState"),
            stringIDToTypeID("quadCenterState"),
            stringIDToTypeID("QCSAverage"),
        )

        # Everything is setup. Adds the layer to the document.
        ph_app.executeAction(
            stringIDToTypeID("placeEvent"),
            placeActionDesc,
            requestStatic("com.adobe.photoshop.DialogModes", "NO"),
        )