Copy link to clipboard
Copied
Hello, hello
I'm learning scripting for Illustrator and Script UI and I have 2 problems but I will separate this 2 problems in 2 differents posts.
It's first problem.
I use ExtendScript Toolkit to test my scipt in Illustrator, I created a window catch a value from path item in illustrator.
This value is pathItem.top ("y" in info panel - on illustrator).
In my window, I have 2 controls : 1 edit text and 1 button.
When I click on button, script catch value (pathItem.top) and put it in edit text (in window).
Problem : When I move path Item in illusrtator with cursor, script can't give me new value (pathItem.top), he keep old value (script is "freezen").
Sometimes, script give me new value but I have move path Item in illustrator with transformation panel in illustrator.
I recorded a little movie from my computer to show you it, I give you link from Youtube (if you have a problem, tell me) : Refresh info from Illustrator - forum Illustrator Scripting - YouTube
My code is in end of this post, if you want I can send you file .jsx.
Can you give me your help, please.
Aaah and sorry for my bad english, I try to write good message to ask help, thank you, thank you.
-------------------------------------------------------------------------
My code is :
#target illustrator
var palette01 = 'palette\
{text: "Ma fenêtre",\
ed1: EditText{characters: 20},\
b1: Button{text: "Afficher les valeurs"},\
}';
var maFenetre = new Window(palette01);
var editTextPalette = maFenetre.ed1;
var button01Palette = maFenetre.b1;
var monDoc = app.activeDocument;
var monCalque = monDoc.layers["coucou"];
var atrace01 = monCalque.pathItems["01"];
var messagePalette01 = 'function aa()\
{\
var valeur;\
valeur = atrace01.position;\
editTextPalette.text = valeur;\
alert("Ca marche !")\
};\
aa()';
var aaPalette01 = new BridgeTalk;
aaPalette01.target = BridgeTalk.appName;
aaPalette01.body = messagePalette01;
button01Palette.onClick = function(){aaPalette01.send()};
maFenetre.show();
Ce message a été modifié par : Steven Charles-Charlery
the reference to your object needs to be inside the function you're sending through BridgeTalk. The reference needs to be recreated everytime you click the button.
I changed it to report selected object's position
...#target illustrator
var palette01 = "palette \
{text: 'Ma fenêtre', \
ed1: EditText{characters: 20}, \
b1: Button{text: 'Afficher les valeurs'}, \
}";
var maFenetre = new Window(palette01);
var editTextPalette = maFenetre.ed1;
var button01Palette = maFenetre.b1;
var monDoc = app.activeDoc
Copy link to clipboard
Copied
Unfortunately, Illustrator's JavaScript doesn't support such events and we can't get the correct value like your case.
If you are familiar about C++, You can make a plugin with Illustrator SDK that supports selectionChanged event.
Below article was written by Japanese. However, You can translate and reference it.
Copy link to clipboard
Copied
Oooh ok, if I learn HTML panel (HTML5, css3 and js) for Illustrator (CEP), i Can get correct value ?
Or I have learn C++ ?
Thank you
Copy link to clipboard
Copied
the reference to your object needs to be inside the function you're sending through BridgeTalk. The reference needs to be recreated everytime you click the button.
I changed it to report selected object's position
#target illustrator
var palette01 = "palette \
{text: 'Ma fenêtre', \
ed1: EditText{characters: 20}, \
b1: Button{text: 'Afficher les valeurs'}, \
}";
var maFenetre = new Window(palette01);
var editTextPalette = maFenetre.ed1;
var button01Palette = maFenetre.b1;
var monDoc = app.activeDocument;
//var monCalque = monDoc.layers["coucou"];
//var atrace01 = monCalque.pathItems["01"];
var messagePalette01 = "function aa()\
{\
var valeur;\
var atrace01 = selection[0];\
valeur = atrace01.position;\
editTextPalette.text = valeur;\
//alert('Ca marche !')\
};\
aa()";
var aaPalette01 = new BridgeTalk;
aaPalette01.target = BridgeTalk.appName;
aaPalette01.body = messagePalette01;
button01Palette.onClick = function(){aaPalette01.send()};
maFenetre.show();
Copy link to clipboard
Copied
Oh thank you, I will use this snippet and I will give you news about it
Copy link to clipboard
Copied
It's ok, it's good, thank you.
I don't saw this information in doc about BridgeTalk.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now