Copy link to clipboard
Copied
Hello guys! How do I display the width size of the current document inside a text box in a dialog box? The unit of measurement will be in centimeters. (cm)
#target photoshop
var doc = activeDocument;
app.preferences.rulerUnits = Units.CM;
dlg = new Window('dialog','Final Width Size');
dlg.gp = dlg.add('group');
dlg.gp.stxt = dlg.gp.add('statictext',undefined,'Width Size');
dlg.gp.etxt = dlg.gp.add('edittext',undefined,parseFloat (doc.width));
dlg.gp.meas = dlg.gp.add('statictext',undefined,'cm');
dlg.btn = dlg.add('button',undefined,'Close');
dlg.btn.onClick = function (){
dlg.close();
}
dlg.show();
Copy link to clipboard
Copied
#target photoshop
var doc = activeDocument;
app.preferences.rulerUnits = Units.CM;
alert(doc.width)
Copy link to clipboard
Copied
Hi Chuck Uebele Great job, 50% positive .... 100% will be if this value is displayed in a text box equal to the picture illustration below. It would be possible? Thank you for your help.
Copy link to clipboard
Copied
#target photoshop
var doc = activeDocument;
app.preferences.rulerUnits = Units.CM;
dlg = new Window('dialog','Final Width Size');
dlg.gp = dlg.add('group');
dlg.gp.stxt = dlg.gp.add('statictext',undefined,'Width Size');
dlg.gp.etxt = dlg.gp.add('edittext',undefined,parseFloat (doc.width));
dlg.gp.meas = dlg.gp.add('statictext',undefined,'cm');
dlg.btn = dlg.add('button',undefined,'Close');
dlg.btn.onClick = function (){
dlg.close();
}
dlg.show();
Copy link to clipboard
Copied
Very good! Beautiful work. Thank you very much Chuck Uebele
Copy link to clipboard
Copied
Chuck Uebele, just curious and for the sake of studying and learning, how do I execute this function through a button eg "doc width"? Thanks again
Copy link to clipboard
Copied
#target photoshop
var doc = activeDocument;
app.preferences.rulerUnits = Units.CM;
dlg = new Window('dialog','Final Width Size');
dlg.gp = dlg.add('group');
dlg.gp.stxt = dlg.gp.add('statictext',undefined,'Width Size');
dlg.gp.etxt = dlg.gp.add('edittext',undefined,'');
dlg.gp.etxt.size = [90,12]
dlg.gp.meas = dlg.gp.add('statictext',undefined,'cm');
dlg.getSize = dlg.add('button',undefined,'Get Doc Width');
dlg.btn = dlg.add('button',undefined,'Close');
dlg.getSize.onClick = function(){
dlg.gp.etxt.text =parseFloat(doc.width);
}
dlg.btn.onClick = function (){
dlg.close();
}
dlg.show();
Copy link to clipboard
Copied
Hi Chuck Uebele thanks for the quick support! There is an error pointing to line 16, with you worked out?
Copy link to clipboard
Copied
Do you have a file open?
Copy link to clipboard
Copied
Fixed it. Forgot to capitalize the "F" in parseFloat.
Copy link to clipboard
Copied
Now it worked perfect! thank you very much for sharing your knowledge friend Chuck Uebele A big hug for you