AddRotatedRectangle Method

NI Vision for Visual Basic

AddRotatedRectangle Method

Syntax

CWIMAQRegions.AddRotatedRectangle RotatedRectangle

Return Type

CWIMAQRegion

The region object that was added.

Purpose

Adds a rotated rectangular region to the regions collection.

Remarks

This method makes a copy of the input rotated rectangle.

Parameters

RotatedRectangle As CWIMAQRotatedRectangle

The rotated rectangle to add.

Example

Private Sub Run_Click()
    Dim RotatedRectangle As New CWIMAQRotatedRectangle
    Dim BoundingRectangle As New CWIMAQRectangle
    
    'Create a rotated rectangle
    RotatedRectangle.Initialize 120, 150, 200, 100, 45
    
    'Add the rotated rectangle to the viewer regions.
    CWIMAQViewer1.Regions.AddRotatedRectangle RotatedRectangle

    If TypeName(RotatedRectangle) = "Nothing" Then
    MsgBox "Number of rotated rectangles exceeded!"
    Else
    MsgBox "You added a rotated rectangle." 
    End If
    
    'Add a second rotated rectangle with a different angle to the viewer regions.
    RotatedRectangle.Angle = 15
    CWIMAQViewer1.Regions.AddRotatedRectangle RotatedRectangle

    If TypeName(RotatedRectangle) = "Nothing" Then
    MsgBox "Number of rotated rectangles exceeded!"
    Else
    MsgBox "You added a rotated rectangle." 
    End If
    
    'Get the bounding rectangle of the viewer regions
    CWIMAQViewer1.Regions.GetBoundingRectangle BoundingRectangle
    
    'Add the bounding rectangle to the viewer regions
    CWIMAQViewer1.Regions.AddRectangle BoundingRectangle
    If TypeName(BoundingRectangle) = "Nothing" Then
    MsgBox "Number of bounding rectangles exceeded!"
    Else
    MsgBox "You added a bounding rectangle." 
    End If
    CWIMAQViewer1.Regions(CWIMAQViewer1.Regions.Count).PenColor = vbYellow

End Sub