Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Oct 20, 2022 Oct 20, 2022

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

TOPICS
Scripting
493
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Oct 20, 2022 Oct 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", und
...
Translate
Enthusiast ,
Oct 20, 2022 Oct 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);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2022 Oct 20, 2022
LATEST

Worked awesomely! Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines