# OnMouseUp Script

The OnMouseUp script will be used in conjunction with the VisionPro Display, and will be invoked whenever a user releases the mouse on the display (the script presumes that the user was manipulating the graphic). The script will update the values of the rectAngle, rectCenterX, rectCenterY and rectSkew tags, based on the position, angle and skew of the rectangle.

1. Right-click on the left VisionPro Display control and select Scripts | On Mouse Up.

   1. Enter the following script:

          CogRectangleAffine aRect = (CogRectangleAffine)$myRect;
          $System.Log.Write("Invoking mouseup" + aRect.ToString());
          if (aRect != null)
          {
          	$System.Log.Write("with" + aRect.CenterX.ToString() + aRect.CenterY.ToString() + "and" + aRect.Rotation.ToString() + "and" + aRect.Skew.ToString());
          	$rectCenterX = aRect.CenterX;
          	$rectCenterY = aRect.CenterY;
          	$rectAngle = CogMisc.RadToDeg(aRect.Rotation);
          	$rectSkew = CogMisc.RadToDeg(aRect.Skew);
          	$System.Log.Write("Tag" + $rectCenterX);
          	$Tasks.CopyRegion.Run();
          }

2. In Properties, add using statements to the Code property.

3. Press the drop-down button, and in the blank text field, enter "Cognex.VisionPro" and "Cognex.VisionPro.Display".

4. Press the browse button of the References property, using the Script References dialog, from the Discovered References pane, add Cognex.VisionPro.dll, Cognex.VisionPro.Core.dll and Cognex.VisionPro.Display.Controls.dll to the Local References, and press the Accept button.

5. Press the Compile button to ensure the script correctly compiles.