Scott,
Here is an update of the script.
global proc MeasureAngleTool ()
{
//Written by Dane Shears with help from Eu Ming Lee and Rob James for remembering high school mathematics.
// This proc Creates a first degree EP curve and measures the angle from one to 180 degrees
// formed by the two lines. If you exceed 180 degrees it measures the angle from the other side.
// It works in all three dimensions.
// DELETE THE WINDOW -UI IF IT EXISTS //
if ( window -exists MeasureAngleTool
)
{
deleteUI MeasureAngleTool;
}
// INITIALIZE VARIABLES //
// BUILD THE UI //
window -widthHeight 150 200 MeasureAngleTool;
columnLayout -columnAttach "both" 5 -rowSpacing 5 -columnWidth 150;
string $b1 = button -label "Create Protractor"
;
string $b2 = button -label "Select Protractor"
;
string $b3 = button -label "Measure Angle"
;
setParent ..;
// ADD THE COMMANDS //
button -edit -command "createProtractor" $b1;
button -edit -command "select -r protractor1" $b2;
button -edit -command "MeasureAngle" $b3;
columnLayout -columnAttach "both" 5 -rowSpacing 5 -columnWidth 150;
separator;
text -label "Degrees" degreeText;
text -label "" angleText;
text -label "or the way it is" otherText;
text -label "" angle2Text;
setParent..;
showWindow MeasureAngleTool;
}
global proc createProtractor ()
{
changeSelectMode -object;
string $allProtractors [] = ls "protractor*"
;
print $allProtractors;
select -r $allProtractors;
delete ;
select -d;
// I should change the Y and Z axis before giving away
curve -d 1 -p 8 8 0 -p 0 0 0 -p 10 0 0;
string $tempRename1[] = ls -sl
;
string $oldName = $tempRename1[0];
rename $oldName protractor1;
}
global proc MeasureAngle ()
{
float $firstPointLocation [] = pointPosition protractor1.cv[0]
;
print $firstPointLocation;
float $secondPointLocation [] = pointPosition protractor1.cv[1]
;
print $secondPointLocation;
float $thirdPointLocation [] = pointPosition protractor1.cv[2]
;
print $thirdPointLocation;
vector $vectorBA = <>;
vector $vectorBC = <>;
float $firstPointX = $firstPointLocation[0];
float $firstPointY = $firstPointLocation[1];
float $firstPointZ = $firstPointLocation[2];
float $secondPointX = $secondPointLocation[0];
float $secondPointY = $secondPointLocation[1];
float $secondPointZ = $secondPointLocation[2];
float $thirdPointX = $thirdPointLocation[0];
float $thirdPointY = $thirdPointLocation[1];
float $thirdPointZ = $thirdPointLocation[2];
float $vectorBAX = ($secondPointX - $firstPointX);
float $vectorBAY = ($secondPointY - $firstPointY);
float $vectorBAZ = ($secondPointZ - $firstPointZ);
$vectorBA = <>;
float $vectorBCX = ($secondPointX - $thirdPointX);
float $vectorBCY = ($secondPointY - $thirdPointY);
float $vectorBCZ = ($secondPointZ - $thirdPointZ);
$vectorBC = <>;
float $finalAngle = rad_to_deg (angle $vectorBA $vectorBC
);
float $otherAngle = (180-$finalAngle);
//ron's mod
select -r protractor1.cv[0];
string $object[]=newCluster " -envelope 1"
;
string $locatorNames[]=spaceLocator
;
string $pCon[]=pointConstraint -offset 0 0 0 -weight 1 $object[1] $locatorNames[0]
;
delete $pCon[0];
select -r $locatorNames[0];
string $annotateShape=annotate -tx $finalAngle
;
setAttr .displayArrow 0;
setAttr .template 1;
select -tgl $locatorNames[0];
parent;
setAttr .translate 0 0 0;
string $annotateParent[]=listRelatives -f -p $annotateShape
;
parent $annotateParent[0] $object[1];
delete $locatorNames[0];
select -r $object[1];
//end ron's mod
print "\n";
print $finalAngle;
text -e -label $finalAngle angleText;
text -e -label $otherAngle angle2Text;
}
MeasureAngleTool;