Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

RegionsToMask run-time error

The CWIMAQ method 'RegionsToMask' fails with a run-time error if an annulus region is supplied where the start or end angle fall outside the range of 0 to 360 degrees. This behavior appears to be new since CWIMAQ.OCX v6.0. The same code ran successfully with earlier versions of cwimaq. The failing code is shown below:

Private Sub Form_Load()
Dim maskImage As New CWIMAQImage
Dim objAnnulus As New CWIMAQControlsLib.CWIMAQAnnulus
Dim objRegions As New CWIMAQControlsLib.CWIMAQRegions
Dim ModelImage As Variant
Dim dblAngle As Double

' Set model image to empty
ModelImage = Empty

'Create an annulus
objAnnulus.InnerRadius = 165
objAnnulus.OuterRadius = 195
objAnnulus.Center.X = 320
objAnnulus.Center.Y = 240
objAnnulus.StartAngle = 300
objAnnulus.EndAngle = 360

'Add it to regions
objRegions.AddAnnulus objAnnulus

'Call RegionsToMask: this call succeeds
CWIMAQVision1.RegionsToMask maskImage, objRegions, ModelImage, 255

'Remove last region
objRegions.RemoveAll

'Make End Angle > 360
objAnnulus.EndAngle = 361

'Add it to regions
objRegions.AddAnnulus objAnnulus

'Call RegionsToMask: this call fails with the following error:
'
' Run-time error '-2147417848(80010108)'
'
' Method 'RegionsToMask' of object '_DCWIMAQVision' failed
'
CWIMAQVision1.RegionsToMask maskImage, objRegions, ModelImage, 255

End Sub
0 Kudos
Message 1 of 2
(5,926 Views)
Hello mpu,

Thank you for using our discussion forums. I tried out your code with Vision 7.1 and did not see the error when using angles greater than 360 degrees for the annulus. It is possible that an error check was added with Vision 6.0 but it has been removed with Vision 7.1. Please let me know if there is anything else I can help you out with.

Regards,
Nipun M
National Instruments
0 Kudos
Message 2 of 2
(5,901 Views)