Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Palette can't access active document

Community Beginner ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

Hello !

 

I am working on a randomizer script for illustrator, and i am stubling on a problem.

I would like my script to be a palette, but when i change 

 

new Window("dialog", ...)

 

to 

 

new Window("palette", ...)

 

my script can no longer call app.activeDocument .

 

Here are the bits of code interesting :

 

#target illustrator
#targetengine "session"

var dialogUI = (function () {
	var palette = new Window("palette", undefined, undefined, {closeButton: true, resizeable: true}); 
	[...]
	var apply = group_button.add("button", undefined, undefined, {name: "apply"}); 
	apply.text = "apply"; 

	apply.addEventListener("click",function(){
		MyDoc = app.activeDocument;
		MySelection = MyDoc.selection;
		if(MySelection instanceof Array){
			if(tab_selectionnee == tab_fill_colour){
				random_background_color()
			}
		}
		app.redraw()
	})
	
	palette.show();
}());

 

The error is where MyDoc = app.activeDocument; is, and MySelection = ... is never called

 

Does anyone have an idea on how to solve this ?

TOPICS
Scripting

Views

48

Likes

Translate

Translate

Report

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

Adobe Community Professional , Nov 08, 2021 Nov 08, 2021
it's a known issue, you must use BridgeTalk to have a Palette talk to Illustrator and vice versa. check this thread for a sample https://community.adobe.com/t5/illustrator-discussions/got-an-error-using-palette-in-illustrator-script/m-p/11689893

Likes

Translate

Translate
Adobe Community Professional ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

it's a known issue, you must use BridgeTalk to have a Palette talk to Illustrator and vice versa.

 

check this thread for a sample

https://community.adobe.com/t5/illustrator-discussions/got-an-error-using-palette-in-illustrator-scr...

Likes

Translate

Translate

Report

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 ,
Nov 09, 2021 Nov 09, 2021

Copy link to clipboard

Copied

LATEST

Thanks a lot !

I saw a  forum post from 2014 but i hoped Adobe would have solved this issue (is this an issue ?).

Anyway, it is working just fine even if it is a pain in the ass :D.

 

Have a great day sir.

Likes

Translate

Translate

Report

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