SetRegion Method

NI Vision for Visual Basic

SetRegion Method

Syntax

CWIMAQRegion.SetRegion Shape, XPointArray, YPointArray [, External = True]

Purpose

Obsolete Programmatically modifies many region properties with one method call.

Remarks

To add a region, create a shape object of the appropriate type, set its properties, and then use the appropriate CWIMAQRegions.Add method. The example below illustrates how to convert from the old code to the new code.

This method is valid only for the following shapes :

cwimaqRegionBrokenline
cwimaqRegionFreeline
cwimaqRegionFreeregion
cwimaqRegionLine
cwimaqRegionOval
cwimaqRegionPoint
cwimaqRegionPolygon
cwimaqRegionRect

Parameters

Shape As CWIMAQRegionShapes

The new shape of the region. The following are valid values for this parameter:

cwimaqRegionBrokenline
cwimaqRegionFreeline
cwimaqRegionFreeregion
cwimaqRegionLine
cwimaqRegionOval
cwimaqRegionPoint
cwimaqRegionPolygon
cwimaqRegionRect

XPointArray As Variant

The array of new x-coordinates for the region.

YPointArray As Variant

The array of new y-coordinates for the region.

External As Variant

[Optional] The new contour identifier for the region.

This parameter has a default value of True.

Example

Private Sub Run_Click()
    ' Add a red rectangular region to the viewer using 1.0 functions
    CWIMAQViewer1.Regions.DefaultRegionColor = vbRed
    Dim Region As CWIMAQRegion
    Set Region = CWIMAQViewer1.Regions.Add
    Region.SetRegion cwimaqRegionRect, Array(10, 99), Array(10, 99)

    ' Add a green rectangular region to the viewer using 6.0 functions
    CWIMAQViewer1.Regions.DefaultRegionColor = vbGreen
    CWIMAQViewer1.Regions.AddRectangle CWIMAQVision1.MakeRectangle(10, 10, 90, 90)
End Sub