Unable to Create a New Path Using Photoshop API in UXP: batchPlay Returns Error

Hello,

I’m attempting to create a new path in Adobe Photoshop using the UXP API, and I’ve encountered some issues. Below is the code snippet I’ve been trying to use:

const batchPlay = require("photoshop").action.batchPlay;

async function createPath() {
  await batchPlay(
    [
      {
        "_obj": "make",
        "_target": [
          {
            "_ref": "path",
            "_name": "My Path"
          }
        ],
        "using": {
          "_obj": "path",
          "knotVector": [
            {
              "_obj": "pathPointInfo",
              "anchor": [100.0, 100.0]
            },
            {
              "_obj": "pathPointInfo",
              "anchor": [200.0, 200.0]
            }
          ]
        },
        "_options": {
          "dialogOptions": "dontDisplay"
        }
      }
    ],
    {}
  );
}

await require('photoshop').core.executeAsModal(async () => {
  createPath().catch(console.error)
});

When running this code, I receive the photoshop alert:

Perspective Tool: The ‘Make’ command is currently unavailable

I am running this code within an open document and have also attempted to switch to different tools, but the issue persists.

Can anyone offer some guidance? Much appreciated!