Copy link to clipboard
Copied
Hi guys, I am new to AI scripting and I am trying to build an dockable palette simillar that we can have in AE
I creating new palette and runing my script code, once I run the code from VScode the palette is popping up, however the script stops exectuing at
Error: there is no document"
If i change in new Window() 'palette' to 'dialog' everything runs normally. What can be the reason. Is palettes allowed in AI and if no, then is there a way to prevent freezing app until the panel isn't closed (this what happens with dialog panels)?
function buildUI(ob){
var dialog = (ob instanceof Panel) ? ob : new Window("dialog", "Outliner", undefined, {closeButton: true});
dialog.text = "Dialog";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var button1 = dialog.add("button", undefined, undefined, {name: "button1"});
button1.text = "Button";
button1.onClick = function(){
var sourceFolder = Folder.selectDialog( "Select the folder" );
runMyScript(sourceFolder)
}
return dialog
}
var panel = buildUI(this)
panel.center();
panel.show();
function runMyScript(sourceFolder){
if(sourceFolder == null) return
var files = sourceFolder.getFiles("*.pdf");
if(files.length == 0) {alert('Please select folder with PDF files'); return}
//CODE STOPS HERE - Error: there is no document
var initializeDoc = app.open(files[0], DocumentColorSpace.RGB);
Hi,
Below is the link that explains the issue
Copy link to clipboard
Copied
Hi,
Below is the link that explains the issue
Copy link to clipboard
Copied
Thank you, it seems to work for me! Btw is there a way to pass nested functions as a string for "script" for bridgeTalk?
Copy link to clipboard
Copied
For me, a palette doesn't run unless the script starts with
#targetengine "session";
Copy link to clipboard
Copied
Doesn't run the script in my case 😞