AddFreeregion Method

NI Vision for Visual Basic

AddFreeregion Method

Syntax

CWIMAQRegions.AddFreeregion Freeregion

Return Type

CWIMAQRegion

The region object that was added.

Purpose

Adds a Freeregion to the regions collection.

Remarks

This method makes a copy of the input Freeregion.

Parameters

Freeregion As CWIMAQFreeregion

The Freeregion to add.

Example

Private Sub Run_Click()
    Dim Brokenline As New CWIMAQBrokenline
    Dim Freeline As New CWIMAQFreeline
    Dim Polygon As New CWIMAQPolygon
    Dim Freeregion As New CWIMAQFreeregion
    
    'Initialize the polylines
    Brokenline.Points.Initialize Array(20, 80, 50, 50, 20, 80), Array(20, 20, 20, 120, 120, 120)
    Freeline.Points.Initialize Array(100, 115, 130, 145, 160), Array(120, 20, 120, 20, 120)
    Polygon.Points.Initialize Array(180, 210, 240, 225, 195), Array(120, 20, 120, 70, 70)
    Freeregion.Points.Initialize Array(300, 310, 300, 280, 270, 260, 260, 270, 280, 300, 310, 320, 320, 310, 320), _
                                 Array(100, 110, 120, 120, 110, 90, 50, 30, 20, 20, 30, 50, 90, 110, 120)
    
    'Add the shapes to the viewer's regions collection.
    CWIMAQViewer1.Regions.AddBrokenline Brokenline
    CWIMAQViewer1.Regions.AddFreeline Freeline
    CWIMAQViewer1.Regions.AddPolygon Polygon
    CWIMAQViewer1.Regions.AddFreeregion Freeregion

    If TypeName(Brokenline) = "Nothing" Then
    MsgBox "Number of broken lines exceeded!"
    Else
    MsgBox "You added a broken line." 
    End If

    If TypeName(Freeline) = "Nothing" Then
    MsgBox "Number of free lines exceeded!"
    Else
    MsgBox "You added a free line." 
    End If

    If TypeName(Polygon) = "Nothing" Then
    MsgBox "Number of polygons exceeded!"
    Else
    MsgBox "You added a polygon." 
    End If

    If TypeName(Freeregion) = "Nothing" Then
    MsgBox "Number of free regions exceeded!"
    Else
    MsgBox "You added a free region."
    End If

End Sub

See Also

CWIMAQBrokenline

CWIMAQFreeline

CWIMAQPolygon

AddBrokenline

AddFreeline

AddPolygon