• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Display the width of the current document

Contributor ,
Sep 19, 2017 Sep 19, 2017

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)

TOPICS
Actions and scripting

Views

857

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 19, 2017 Sep 19, 2017

#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();

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 19, 2017 Sep 19, 2017

Copy link to clipboard

Copied

#target photoshop

var doc = activeDocument;

app.preferences.rulerUnits = Units.CM;

alert(doc.width)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 19, 2017 Sep 19, 2017

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.

Screenshot_1.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2017 Sep 19, 2017

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();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 19, 2017 Sep 19, 2017

Copy link to clipboard

Copied

Very good! Beautiful work. Thank you very much Chuck Uebele

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 20, 2017 Sep 20, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2017 Sep 20, 2017

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();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 20, 2017 Sep 20, 2017

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?Screenshot_1.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

Do you have a file open?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

Fixed it. Forgot to capitalize the "F" in parseFloat.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 20, 2017 Sep 20, 2017

Copy link to clipboard

Copied

LATEST

Now it worked perfect! thank you very much for sharing your knowledge friend Chuck Uebele A big hug for you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines