Changing the height of the rectangle from 0 up does not work
Hello,
I encountered a problem and out of curiosity I would like to solve it.
I wrote a simple script to present the problem. After creating the rectangle, you can increment the value, but when you reduce it to 0, you lose the ability to increment it again. Realistically, in Illustrator, after creation, the rectangle can have a value of 0.
I don't need this in my project, but thanks to you and solving these types of problems, it becomes better.
var mm = new UnitValue(1 + " " + "mm").as('pt');
var doc = app.activeDocument;
var cyanColor = new CMYKColor();
cyanColor.black = 0;
cyanColor.cyan = 100;
cyanColor.magenta = 0;
cyanColor.yellow = 0;
var myH = 3;
var rect = doc.pathItems.rectangle(0, 0, 60*mm, myH*mm);
rect.stroked = false;
rect.filled = true;
rect.fillColor = cyanColor;
doc.views[0].centerPoint = [0,0];
doc.views[0].zoom = 3.0;
redraw();
var dialog = new Window('dialog {orientation:"row"}');
var txt = dialog.add("statictext", undefined, undefined, {name: "txt"});
txt.text = myH;
var button1 = dialog.add('button', undefined, '-', {name:'button1'});
button1.onClick = function() {
// if(myH > 1) { // works
if(myH > 0) { // when we go to 0, line 39 will no longer execute, but 38 will
myH--;
txt.text = myH;
doc.pathItems[0].height = myH * mm;
redraw();
};
};
var button2 = dialog.add('button', undefined, '+', {name:'button2'});
button2.onClick = function() {
myH++;
txt.text = myH;
doc.pathItems[0].height = myH * mm; // doesn't work
redraw();
};
dialog.show();
