Hi folks!
I’m trying to figure out how to place an image into a layer.
Anyone know the proper BatchPlay syntax for placing the image, using a storage Entry?
If I use a string for the _path I get: “invalid file token used,” which I expected.
If I use the Entry, I get: NAPI API failure: String expected.
The latter suggests I’m running the wrong BatchPlay command. Not having any luck finding the proper one. Any suggestions?
Here’s a code snippet from my plugin:
// Place an image in the document, creating a new layer.
// "asset" is a simple object containing data about the image.
// "asset.file" is the string location of the image on the local file system
MGR.PlaceImage = async function (asset, log) {
var layer, x, y, w, h, file;
// SDK.IO.getEntry returns a UXP storage Entry
file = await SDK.IO.getEntry(asset.file);
// Build the BatchPlay command
const cmd = [{
"_obj": "placeEvent",
"null": {
"_path": file, // I've tried both the Entry and the plain string here to no avail
"_kind": "local"
},
"offset": {
"_obj": "offset",
"horizontal": {
"_unit": "pixelsUnit",
"_value": 0
},
"vertical": {
"_unit": "pixelsUnit",
"_value": 0
}
},
"_isCommand": true
}];
// Run the place.
try {
// MGR.Batch runs the BatchPlay command.
await MGR.Batch(cmd);
} catch (ex) {
return { error: ex, command: 'PlaceImage', file: asset.file };
}
Here’s what MGR.Batch looks like:
And this is what the file Entry looks like: