GetBoundingRectangle Method

NI Vision for Visual Basic

GetBoundingRectangle Method

Syntax

CWIMAQRotatedRectangle.GetBoundingRectangle BoundingRectangle

Purpose

Gets the bounding rectangle of the rotated rectangle.

Parameters

BoundingRectangle As CWIMAQRectangle

The rectangle into which to copy the bounding rectangle coordinates.

Example

Private Sub Run_Click()
    Dim RotatedRectangle1 As New CWIMAQRotatedRectangle
    Dim RotatedRectangle2 As New CWIMAQRotatedRectangle
    Dim BoundingRectangle As New CWIMAQRectangle
    
    'Initialize the first rotated rectangle
    RotatedRectangle1.Initialize 3, 23, 19, 81, 15
    
    'Copy the properties from the first rotated rectangle into the second rotated rectangle
    RotatedRectangle1.CopyTo RotatedRectangle2
    
    'Move the first rotated rectangle. This move does not affect the second rotated rectangle
    RotatedRectangle1.Center.X = RotatedRectangle1.Center.X + 70
    RotatedRectangle1.Center.Y = RotatedRectangle1.Center.Y + 70
    
    'Get the bounding rectangle of the first rotated rectangle
    RotatedRectangle1.GetBoundingRectangle BoundingRectangle
    
    'Add the rotated rectangles to the viewer's regions collection.
    CWIMAQViewer1.Regions.AddRotatedRectangle RotatedRectangle1
    CWIMAQViewer1.Regions.AddRotatedRectangle RotatedRectangle2
    
    'Add the bounding rectangle to the viewer's regions collection and change its color to red.
    CWIMAQViewer1.Regions.AddRectangle(BoundingRectangle).PenColor = vbRed
End Sub