Copy link to clipboard
Copied
I'm trying to learn to use .idjs and I keep runing into the error: UXPScript Error! Error String: app is not defined. It's a very simple script to test and I think it should work but it doesn't. Anyone have any guidence.
let myInDesign = require("indesign");
let myDoc = myInDesign.app.activeDocument;
let myLayer = myDoc.layers.item("Layer 1");
if (!myDoc.layers.itemByName("DIGITAL").isValid) {
myDoc.layers.add({ name: "DIGITAL" });
}
if (myDoc.layers.itemByName("Layer 1").isValid) {
myLayer.remove();
}
Ok, well this is embarrassing. I had duplicated the the script to work on it from vscode and instead of working on the one in inDesign I added it to vscode. Doh! So I did get it to work now if I could just get it to work from the uxp plugin. Thanks for the help all.
Copy link to clipboard
Copied
Try defining the app at the start
#target indesign
Copy link to clipboard
Copied
Unfortunately that doesn't work.
Copy link to clipboard
Copied
Hi @davidn5918184, I just ran your code on ID 19.1, MacOS 14.2.1, and it worked as expected (created a layer and removed the other). I executed the script via the script panel. Can you give more info on your set up? Are you running via the script panel?
- Mark
Copy link to clipboard
Copied
Ok, well this is embarrassing. I had duplicated the the script to work on it from vscode and instead of working on the one in inDesign I added it to vscode. Doh! So I did get it to work now if I could just get it to work from the uxp plugin. Thanks for the help all.