Skip to main content
Participating Frequently
October 20, 2022
Resuelto

Create a Script for "Install ScriptUI Panel" without having 2 windows.

  • October 20, 2022
  • 1 respuesta
  • 697 visualizaciones

Hi all!

This may be a RTFM question, but I can´t find the correct way to use this function.

 

I made a script (copied below) and when I install it as Install ScriptUI Panel the result is 2 windows, as seen attached, one docable and one not. What am I doing wrong if I want to have only 1 window (the dockable one with the button inside it)

 

SCRIPT:

var panelRender = this;
var renderWindow = new Window("palette", "Tool", undefined);
var panelRender = renderWindow.add("panel", undefined, "QUEUE");
panelRender.orientation = "row";

var renderButton = panelRender.add("button", undefined, "OPEN APP");

renderButton.onClick = function() {
$.evalFile(File($.fileName).path + '/Tool_v001.jsx')
}

renderWindow.center();
renderWindow.show();

 

Thanks very much!
Nacho

Este tema ha sido cerrado para respuestas.
Mejor respuesta de Paul Tuersley

Typically I'd do something like this. You need to check if AE is giving the script a panel (i.e. this) or not then either add to that panel or create a new window if it isn't running as a panel.

 

function main(thisObj) {

	var renderWindow;
	if (thisObj instanceof Panel) renderWindow = thisObj;
	else renderWindow =  new Window("palette", "Tool", undefined, {resizeable:true});

	// could also write it as
	//var renderWindow = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Tool", undefined, {resizeable:true});

	var panelRender = renderWindow.add("panel", undefined, "QUEUE");
	panelRender.orientation = "row";
	var renderButton = panelRender.add("button", undefined, "OPEN APP");
	renderButton.onClick = function() {
		$.evalFile(File($.fileName).path + '/Tool_v001.jsx')
	}
	
	if (renderWindow instanceof Window) {
		renderWindow.center();
		renderWindow.show();
	} else {	
		renderWindow.layout.layout(true);
	}
}
main(this);

 

1 respuesta

Paul TuersleyRespuesta
Inspiring
October 20, 2022

Typically I'd do something like this. You need to check if AE is giving the script a panel (i.e. this) or not then either add to that panel or create a new window if it isn't running as a panel.

 

function main(thisObj) {

	var renderWindow;
	if (thisObj instanceof Panel) renderWindow = thisObj;
	else renderWindow =  new Window("palette", "Tool", undefined, {resizeable:true});

	// could also write it as
	//var renderWindow = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Tool", undefined, {resizeable:true});

	var panelRender = renderWindow.add("panel", undefined, "QUEUE");
	panelRender.orientation = "row";
	var renderButton = panelRender.add("button", undefined, "OPEN APP");
	renderButton.onClick = function() {
		$.evalFile(File($.fileName).path + '/Tool_v001.jsx')
	}
	
	if (renderWindow instanceof Window) {
		renderWindow.center();
		renderWindow.show();
	} else {	
		renderWindow.layout.layout(true);
	}
}
main(this);

 

Participating Frequently
October 20, 2022

Worked awesomely! Thanks!