Determining whether an image is calibrated or not . . .
All --
I'm writing application and am now up to IPP904.
If there is SPATIAL CALIBRATION on the ACTIVE IMAGE, the following returns the UNITS ABBREVIATION for the SPATIAL CALIBRATION
"ActiveX Automation: Object var is 'Nothing'."
via
ThisApplication.ActiveImage.SpatialCalibration.
and everything I've tried seems to generate an error if the image is not calibrated.
I can build upon this error handling concept to have the program handle the NOT CALIBRATED situation but my question is . . . .
Is there a more graceful way to handle sensing whether an image is calibrated?
Thanks.
-- Matt
I'm writing application and am now up to IPP904.
If there is SPATIAL CALIBRATION on the ACTIVE IMAGE, the following returns the UNITS ABBREVIATION for the SPATIAL CALIBRATION
'Learn the abbreviation for the active calibration unit Dim MySpatialCalibrationUnitAbbrev As String MySpatialCalibrationUnitAbbrev = ThisApplication.ActiveImage.SpatialCalibration.UnitAbbrevIf there is not a SPATIAL CALIBRATION on the ACTIVE IMAGE, the previous code returns the following ERROR
"ActiveX Automation: Object var is 'Nothing'."
via
'Set up error handling On Error GoTo MyHandler 'Learn the abbreviation for the active calibration unit Dim MySpatialCalibrationUnitAbbrev As String MySpatialCalibrationUnitAbbrev = ThisApplication.ActiveImage.SpatialCalibration.UnitAbbrev MyHandler: Debug.Print ErrorI've looked at all of the options behind
ThisApplication.ActiveImage.SpatialCalibration.
and everything I've tried seems to generate an error if the image is not calibrated.
I can build upon this error handling concept to have the program handle the NOT CALIBRATED situation but my question is . . . .
Is there a more graceful way to handle sensing whether an image is calibrated?
Thanks.
-- Matt
0
Best Answer
-
The correct syntax would be:
Sub PrintCalibration If ThisApplication.ActiveImage.SpatialCalibration IsNot Nothing Then Debug.Print ThisApplication.ActiveImage.SpatialCalibration.UnitAbbrev End If End Sub
0
Answers
-
Pierre --
Thank you for your example.
I've changed my code to:'Declare variables used within the if statement Dim MySpatialCalibrationUnitAbbrev As String Dim MySpatialCalibrationPixelSizeX As Single Dim MySpatialCalibrationPixelSizeY As Single 'If the imaage has a spatial calibration If ThisApplication.ActiveImage.SpatialCalibration IsNot Nothing Then 'Then learn the spatial calibration information 'Learn the abbreviation for the active spatial calibration MySpatialCalibrationUnitAbbrev = ThisApplication.ActiveImage.SpatialCalibration.UnitAbbrev 'Learn the pixel size x for the active spatial calibration MySpatialCalibrationPixelSizeX = ThisApplication.ActiveImage.SpatialCalibration.PixelSizeX 'Learn the pixel size y for the active spatial calibration MySpatialCalibrationPixelSizeY = ThisApplication.ActiveImage.SpatialCalibration.PixelSizeY Else 'simulate the spatial calibration information 'Set the abbreviation for the spatial calibration MySpatialCalibrationUnitAbbrev = "pix" 'Set the pixel size x for the spatial calibration MySpatialCalibrationPixelSizeX = 1.0 'Set the pixel size y for the spatial calibration MySpatialCalibrationPixelSizeY = 1.0 End If
Thanks again.
-- Matt
0 -
Oops . . . The EDITOR and I ended up with the THANKS AGAIN as part of the CODE and not part of the MESSAGE!!!
-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions