GetSelectedPointFromViewer Method

NI Vision for Visual Basic

GetSelectedPointFromViewer Method

Syntax

CWMachineVision.GetSelectedPointFromViewer Viewer, Point [, Index]

Return Type

Long

On success, this method returns 0. On failure, this function returns a negative number.

Purpose

Returns a copy of the point at the specified index from the region of interest on the viewer.

Remarks

If a different shape is at the specified index, or the specified index is invalid, this method raises an error.

Parameters

Viewer As CWIMAQViewer

The viewer that contains the region of interest from which you want to get the point.

Point As CWIMAQPoint

On return, this parameter contains a copy of the point that is selected on the viewer.

Index As Variant

[Optional] The index of the Region in the CWIMAQViewer.Regions collection. Set this parameter to the appropriate index when the viewer contains multiple regions of interest.

Example

Private Sub Run_Click()
    'Inputs to LightMeterPoint
    Dim SearchArea As New CWIMAQPoint
    Dim Transformation As New CWMVCoordinateTransformation
    
    'Outputs of LightMeterPoint
    Dim MeasuredIntensity As Single
        
    'Get the search area from the viewer
    CWMachineVision1.GetSelectedPointFromViewer CWIMAQViewer1, SearchArea
    
    'Measure the intensity inside the search region
    CWMachineVision1.LightMeterPoint CWIMAQViewer1.Image, SearchArea, MeasuredIntensity, , _
                                     Transformation
                                     
    'Display the mean intensity in a text box
    Text1.Text = MeasuredIntensity
End Sub

See Also

SetupViewerForPointSelection

CWIMAQViewer.Regions

CWIMAQRegion.Shape

LightMeterPoint