Skip to main content
bagonterman
Inspiring
January 19, 2011
Question

Get values for Measure Tool

  • January 19, 2011
  • 2 replies
  • 520 views

I am interested in getting the values from the measure tool. These appear in the info pallet. Specifically I am looking for the angle info. I can find Info and Measure tool through the menuAction but i can not find any properties for them. If this is possible I would like to know how to acess this.

This topic has been closed for replies.

2 replies

bagonterman
Inspiring
January 28, 2011

My hope is to get results similar to using the measure tool in Photoshop to get an arbitrary rotation.

bagonterman
Inspiring
January 28, 2011

I have looked around and I have been unable to find a possible way to access the info for Measure Tool. So I tried this.

var myInfoDialog = app.dialogs.add({name:"Alignment", canCancel:true});
    with(myInfoDialog){
    //Add a dialog column.
    with(dialogColumns.add()){
        //Create a border panel.
        with(borderPanels.add()){
            with(dialogColumns.add()){
                //The following line shows how to set a property as you create an object.
                staticTexts.add({staticLabel:"Please Choose Verticalor Horizontal  Alignment     "});
            }
        with(dialogColumns.add()){
        //Create a border panel.
        with(borderPanels.add()){
        var myOrient = radiobuttonGroups.add();    
    with(myOrient){
        radiobuttonControls.add({staticLabel:"Vertical", checkedState: true});
    radiobuttonControls.add({staticLabel:"Horizontal", checkedState: false});
    }
}
            }
        }
    }
}
var myResult = myInfoDialog.show();
if(myResult == true){
    if(myOrient.selectedButton ==1){
        var myAlignment=0;
        }
    else{
        var myAlignment=90;
        }
findAngle();
}
function findAngle(){
    myPath=app.selection[0];
   var lineStart = myPath.paths.item(0).pathPoints.item(0).anchor;
   var lineEnd = myPath.paths.item(0).pathPoints.item(-1).anchor;
   var a = Math.abs(lineStart[0]-lineEnd[0]);
   var o = Math.abs(lineStart[1]-lineEnd[1]);
    c = (180/Math.PI) * Math.atan2(o,a);
    c=c-myAlignment
   if(lineStart[0] < lineEnd[1]){
      c = -c;
   };
   var myRotateMatrix = app.transformationMatrices.add({counterclockwiseRotationAngle:c});
   myPath.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.CENTER_ANCHOR, myRotateMatrix);
   dSelect=app.selection=NothingEnum.NOTHING;
  
};

Unfortunatley it only works on the first rotation. For some reason on subsiquint rotations it fails to return to a 90 degree angle.

Any help with this would be great.

Inspiring
January 28, 2011

The property "rotationAngle" doesn't do what you need?

It also depends on the type of object you are trying to measure. This simple four-point object

is not rotated -- but your code would say it is.

bagonterman
Inspiring
January 28, 2011

If i create a rectangle and rotate it. The script works the first time. If i hit it again and choose either horizontal or vertical it rotates but not back to 90 degrees. I am wondering if the point of rotation is changing?