Hey,
I’m building my first PS Plugin and got a problem with placedLayerReplaceContents.
I have this function:
async function selectArtwork() {
console.log("Starting selectArtwork function");
try {
// Dateiauswahldialog
const file = await fs.getFileForOpening({ types: ["png", "jpg", "jpeg", "webp"] });
if (!file) {
console.log("No file selected");
return;
}
await require("photoshop").core.executeAsModal(async () => {
try {
const artLayerId = 10512; // Die ID des Artlayers
// Dann den Inhalt ersetzen
const token = await fs.createSessionToken(file);
await batchPlay(
[
{
_obj: "placedLayerReplaceContents",
null: { _path: token },
_target: [{ _ref: "layer", _id: artLayerId }]
}
],
{ synchronousExecution: true }
);
console.log("Artwork updated successfully");
} catch (error) {
console.error("Error updating artwork:", error);
}
});
} catch (error) {
console.error("Error in selectArtwork function:", error);
}
console.log("selectArtwork function completed");
}
Whenever i select an img (btw is there a possibility to just say “all img types”? I found fileTypes.images in the FileSystemProvider JavaScript Reference Examples but fileTypes is not declared…) it just runs perfectly but doesn’t change the Layer Content.
I have “localFileSystem”: “fullAccess” in my Manifest.
I also tried to select the Layer first but this didn’t change anything.
Thanks
Azami