Hello.
Sorry in advance for my english everything is translated by google translator.
I wrote a simplified script to solve this problem. The script works, but I have the impression that changes in illustrator, i.e. changing the width, work too slowly. Sure, this change could work much faster, but that's where my knowledge ends. I need help in this subject.
Thank you in advance!
#targetengine main;
var mm = 2.834645;
var doc = app.activeDocument;
var rec = doc.pathItems.rectangle(0,0,100*mm,100*mm);
// PAlETTE
var palette = new Window("palette");
palette.text = "rectangle";
palette.alignChildren = ["center","top"];
palette.spacing = 10;
palette.margins = 16;
// GROUP1
var group1 = palette.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","center"];
group1.spacing = 10;
group1.margins = 0;
var statictext1 = group1.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "W:";
var statictext2 = group1.add("statictext", undefined, undefined, {name: "statictext2"});
statictext2.text = rec.width/mm;
var button1 = group1.add("button", undefined, undefined, {name: "button1"});
button1.text = "-";
button1.preferredSize.width = 50;
var button2 = group1.add("button", undefined, undefined, {name: "button2"});
button2.text = "+";
button2.preferredSize.width = 50;
// onClick
button1.onClick = function() {
statictext2.text = Number(statictext2.text)-1;
fun1();
};
button2.onClick = function() {
statictext2.text = Number(statictext2.text)+1;
fun2();
};
palette.show();
// FUNCTION
function fun1() {
var bt = new BridgeTalk();
bt.target = "illustrator";
var message = "rec.width = rec.width - (1*mm);";
bt.body = message;
bt.send();
};
function fun2() {
var bt = new BridgeTalk();
bt.target = "illustrator";
var message = "rec.width = rec.width + (1*mm);";
bt.body = message;
bt.send();
};