Skip to main content
Participant
November 8, 2021
Answered

Palette can't access active document

  • November 8, 2021
  • 1 reply
  • 510 views

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 ?

This topic has been closed for replies.
Correct answer CarlosCanto

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

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
November 8, 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

Participant
November 9, 2021

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.