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

How to display vertex coordinates of Polygonal Lasso Tool?

Community Beginner ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

I use Polygonal Lasso Tool to form a selection like the screenshot below:

Untitled2.png

Now I want to record the accurate vertex coordinates of the Polygonal Lasso Tool. Do you know how to display these coordinates somewhere in Photoshop so that I can record them manually in a notebook or automatically as a file? Thanks a lot.

PS: I'm using Photoshop CC 2019 on Windows 10.

Views

1.2K

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 , Feb 02, 2019 Feb 02, 2019

The price is a bottle of red wine don't go overboard a $15 bottle will do.

// enable double-clicking from Mac Finder or Windows Explorer

#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events

app.bringToFront();

// Save the current preferences

var startRulerUnits = app.preferences.rulerUnits;

// Set Photoshop to use pixels

app.preferences.rulerUnits = Units.PIXELS;

var thePath = selectedPath();

if (thePath == undefined) {

   alert("No

...

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

You may be able to write a Photoshop Script to do that. The script would have Photoshop convert the selection to a Path them process path to get the control points coordinates. There may be  extra points the script could also  write the path to a log file. Set guide line marking the points so you can read them on the rulers and switch between ruler unites  just record the point you want in the unites you want. A path can have many points a list may not fit on your display.

Capture.jpg

JJMack

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 Beginner ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

@JJMack: Thank you. I have no knowledge of writing script in Photoshop and my time budget does not allow me to study it. Could you please share your script with me? I can pay you for the script.

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 ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

hengz80545720  wrote

Do you have a lot or a few of these to do?

Would it work for you to:

  • Convert your selection to a path in the Paths panel
  • Open the Info panel
  • Select an anchor point with the Direct Selection tool (white arrow)
  • Copy the info from the X and Y

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 ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

The price is a bottle of red wine don't go overboard a $15 bottle will do.

// enable double-clicking from Mac Finder or Windows Explorer

#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events

app.bringToFront();

// Save the current preferences

var startRulerUnits = app.preferences.rulerUnits;

// Set Photoshop to use pixels

app.preferences.rulerUnits = Units.PIXELS;

var thePath = selectedPath();

if (thePath == undefined) {

   alert("No Path Selected");

}

else {

   var myPathInfo = extractSubPathInfo(thePath); 

  var pathPoints = "Path Points\n"

   for(var k=0;k<myPathInfo.length;k++){ 

       pathPoints = pathPoints + "Path" + (k+1) + "\n";

       for(var j=0;j<myPathInfo.entireSubPath.length;j++){

           pathPoints = pathPoints  + "X " + myPathInfo.entireSubPath.anchor[0] + " Y " + myPathInfo.entireSubPath.anchor[1] +"\n";

           MarkX(myPathInfo.entireSubPath.anchor[0]);

          MarkY(myPathInfo.entireSubPath.anchor[1]);

      }

   }

   alert(pathPoints);

}

////// determine selected path //////

function selectedPath () {

   try {

      var ref = new ActionReference();

      ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

      var desc = executeActionGet(ref);

      var theName = desc.getString(charIDToTypeID("PthN"));

      return app.activeDocument.pathItems.getByName(theName)

   }

   catch (e) {

      return undefined

   }

};

// Return the app preferences

app.preferences.rulerUnits = startRulerUnits;

////// michael l hale’s code //////

function extractSubPathInfo(pathObj){ 

    var pathArray = new Array();// each element can be used as the second arugment in pathItems.add ie doc.pathItems.add("myPath1", [pathArray[0]]); 

    var pl = pathObj.subPathItems.length; 

    for(var s=0;s<pl;s++){ 

        var pArray = new Array(); 

          for(var i=0;i<pathObj.subPathItems.pathPoints.length;i++){ 

             pArray = new PathPointInfo; 

             pArray.kind = pathObj.subPathItems.pathPoints.kind; 

             pArray.anchor = pathObj.subPathItems.pathPoints.anchor; 

//alert("Anchor " + pathObj.subPathItems.pathPoints.anchor );

             pArray.leftDirection = pathObj.subPathItems.pathPoints.leftDirection; 

             pArray.rightDirection = pathObj.subPathItems.pathPoints.rightDirection; 

          }; 

        pathArray[pathArray.length] = new Array(); 

        pathArray[pathArray.length - 1] = new SubPathInfo(); 

        pathArray[pathArray.length - 1].operation = pathObj.subPathItems.operation; 

        pathArray[pathArray.length - 1].closed = pathObj.subPathItems.closed; 

        pathArray[pathArray.length - 1].entireSubPath = pArray; 

    }; 

    return pathArray; 

};

function MarkX(x) {

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc61 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc62 = new ActionDescriptor();

        var idPstn = charIDToTypeID( "Pstn" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc62.putUnitDouble( idPstn, idPxl, x);

        var idOrnt = charIDToTypeID( "Ornt" );

        var idOrnt = charIDToTypeID( "Ornt" );

        var idVrtc = charIDToTypeID( "Vrtc" );

        desc62.putEnumerated( idOrnt, idOrnt, idVrtc );

    var idGd = charIDToTypeID( "Gd  " );

    desc61.putObject( idNw, idGd, desc62 );

executeAction( idMk, desc61, DialogModes.NO );

}

function MarkY(y) {

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc63 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc64 = new ActionDescriptor();

        var idPstn = charIDToTypeID( "Pstn" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc64.putUnitDouble( idPstn, idPxl, y );

        var idOrnt = charIDToTypeID( "Ornt" );

        var idOrnt = charIDToTypeID( "Ornt" );

        var idHrzn = charIDToTypeID( "Hrzn" );

        desc64.putEnumerated( idOrnt, idOrnt, idHrzn );

    var idGd = charIDToTypeID( "Gd  " );

    desc63.putObject( idNw, idGd, desc64 );

executeAction( idMk, desc63, DialogModes.NO );

}

JJMack

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 Beginner ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

@JJMack: Thank you so much for the script. May I ask one more question: I saved the script into C:\Program Files\Adobe\Adobe Photoshop CC 2019\Presets\Scripts\ShowCoord.jsx. This script now shows up in menu File -> Scripts. Then I initiated the Polygon Lasso Tool and made a selection. But when I clicked the menu to run the script, I was given a message "No Path Selected". I tried to call the script via File -> Scripts -> Browse ... but got the same alert. I checked the script and found it is because line 12 returns undefined. I guess the script thought the selection is not selected (or activated), but it is indeed selected:

Untitled3.png

Could you please tell me how to use the script correctly? Thank you 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 ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

Open the path panel and click on the icon in the bottom to convert the selection to a path the message states you have no path.

Capture.jpg

JJMack

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 Beginner ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

It is working now! I'm so grateful for your help. Thank 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
Community Expert ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

Send the red my way.

JJMack

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
New Here ,
Apr 24, 2023 Apr 24, 2023

Copy link to clipboard

Copied

LATEST

Is there updated code for this?

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