Initialize Method

NI Vision for Visual Basic

Initialize Method

Syntax

CWIMAQRotatedRectangle.Initialize CenterX, CenterY, Width, Height, Angle

Purpose

Sets all the properties of the rectangle with one method call.

Parameters

CenterX As Single

The x-coordinate of the center point of the rotated rectangle.

CenterY As Single

The y-coordinate of the center point of the rotated rectangle.

Width As Single

The width of the rotated rectangle.

Height As Single

The height of the rotated rectangle.

Angle As Single

The angle of the rotated rectangle.

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