Home Image-Pro Automation (Macros, Apps, Reports)

Problem with SPATIAL CALIBRATION FUNCTION . . . .

2017-03-06-104936

All --

I recorded the following FUNCTION into a PREMIER 9.2 APP.

No errors were generated during the RECORDING but during the LOAD that happens after the STOP RECORDING BUTTON is presssed, the following ERROR is displayed




which then points to the beginning of the word DEFINE in line 555




When recording these same general steps into a NEW PROJECT, the IMPORTS that are generated are

Imports MediaCy.Addins.SCalibration
Imports MediaCy.Addins.SCalibration.Commands

These are in the PROJECT / APP that is throwing the ERRORS also.

Can someone please direct me to the resolution for this issue?

Thanks.

-- Matt

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

    Public Function NewMacro() As SimpleScript
        NewMacro = New SimpleScript
        Dim var1 = "Ricetec-Pollen-Neubauer-Grid", spcal1
        Dim var2 = "OCVR WETTING 01", spcal2
        Dim var3 = "OCVR WETTING 01(2)", spcal3, doc1

        With Measure.Calibration.SpatialCommands.Define(NewMacro)
            .Run(var1, spcal1)
        End With

        With Measure.Calibration.SpatialCommands.SetActive(NewMacro)
            .Comment = "Ricetec-Pollen-Neubauer-Grid: 2.278 x 2.278 µm"
            .FilterInput = True
            .Run(spcal1)
        End With

        With Application.Gadgets.SpatialCalibration(NewMacro)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
            .Run()
        End With

        With Measure.Calibration.SpatialCommands.Define(NewMacro)
            .Run(var2, spcal2)
        End With

        With Measure.Calibration.SpatialCommands.Define(NewMacro)
            .Run(var3, spcal3)
        End With

        With Measure.Calibration.SpatialCommands.Modify(NewMacro)
            .Name = "OCVR WETTING 01(2)"
            .Run(spcal3)
        End With

        With Measure.Calibration.SpatialCommands.SetActive(NewMacro)
            .Comment = "OCVR WETTING 01(2): 0.005 x 0.005 in"
            .FilterInput = True
            .Run(spcal3)
        End With

        With Measure.Calibration.SpatialCommands.Modify(NewMacro)
            .Name = "OCVR WETTING 01(2)"
            .Run(spcal3)
        End With

        With Application.DocumentCommands.Active(NewMacro)
            .Run(doc1)
        End With

        With Measure.Calibration.SpatialCommands.Apply(NewMacro)
            .Comment = "OCVR WETTING 01(2): 0.005 x 0.005 in"
            .Run(doc1, spcal3)
        End With

        With Application.Gadgets.SpatialCalibration(NewMacro)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
            .Run()
        End With

    End Function

Best Answer

  • Accepted Answer
    Matt, try to remove all unwanted references and keep only MediaCy.AddIn.Measurements.dll

    Thanks,
    Nikita.

Answers

  • 2017-03-06-110050

    All --

    I forgot to say this was happening within PREMIER 3D V9.3.

    Sorry.

    -- Matt


  • Hi Matt,

    You macro is very specific to your calibrations set. As you can see there are many calibration names recorded in your macro. Please make sure that all these calibrations are present when you run the macro.

    Yuri

  • 2017-03-06-123010

    Yuri --

    Thank you for your quick response.

    This macro was RECORDED and all of the CALIBRATIONS listed are in PREMIER.

    Is there anything else that would generate this ERROR?

    Thanks.

    -- Matt
  • Shouldn't be, just check that the calibration name defined by "var1" exists in your list.

    Yuri

  • 2017-03-06-132433

    Yuri --

    Let's start with a fresh slate . . .

    I have a macro that is operating properly that has a COMBOBOX that is populated with a list of the SPATIAL CALIBRATIONS found within PREMIER.

    When I copy that routine into a NEW PROJECT / APPLICATION, it does not work.

    When this routine is in the BOUNDARY POINTS PROJECT / APP, and LOAD is pressed, the ERROR that is displayed and the CODE that seems to be the issues are shown by PREMIER as



    This LOAD TIME ERROR from PREMIER seems to be disliking the .DEFINE rather than complaining that the requested SPATIAL CALIBRATION is not accessible.

    I performed the RECORD MACRO submitted earlier because I thought that recording a similar macro would set up the IMPORTS and REFERENCES needed to support the SPATIAL CALIBRATION COMMANDS.

    The CODE for the SUBROUTINE that should apply a SELECTED SPATIAL CALIBRATION based on the COMBOBOX.

    This SUBROUTINE is working within another PROJECT / APP.

    Your assistance resolving this issue will be much appreciated.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

        Public Sub ApplySelectedSpatialCalibrationFunction ()
    
            'Declare local variables
            Dim var1 = comboBox_SpatialCalibration.SelectedItem, spcal1
    
            Debug.Print comboBox_SpatialCalibration.SelectedItem
    
            'Connect with the appropriate spatial calibration
            With Measure.Calibration.SpatialCommands.Define(Nothing)
                .Run(var1, spcal1)
            End With
    
            'Activate the appropriate spatial calibration
            With Measure.Calibration.SpatialCommands.SetActive(Nothing)
                .FilterInput = True
                .Run(spcal1)
            End With
    
            'Set the active calibration To be the SYSTEM CALIBRATION
            With Measure.Calibration.SpatialCommands.SetSystem(Nothing)
                .Run(spcal1)
            End With
    
            'If there are any images open
            If ( ThisApplication.Documents.Values.Count > 0 ) _
                Then
    
                    'Apply the ACTIVE CALIBRATION to the ACTIVE IMAGE
                    With Measure.Calibration.SpatialCommands.Apply(Nothing)
                        .Run(ThisApplication.ActiveDocument, spcal1)
                    End With
    
                End If
    
        End Sub

  • Matt,

    A simple trick to resolve these dependency issues is to go to the module where the code works, export the dependencies using the tool of the same name on the Edit tab of the Project Workbench and then go to the new project, switch to Edit mode and import the dependencies using the .DEP file created on the first project.

    Pierre
  • 2017-03-06-142127

    Pierre --

    Thank you for the suggestion.

    I did that and it did not resolve the problem.

    I then did the RECORD MACRO using similar steps because I though this would set up the IMPORTS and DEPENDENCIES.

    Then I submitted the question to the FORUM.

    Would one of you folks be available to WEBEX to debug this issue?

    Thanks.

    -- Matt

  • Matt,

    Please post or email your project and we will take a look.

    Pierre
  • Hi Matt,

    Do you have comboBox_SpatialCalibration combo box where you copy your ApplySelectedSpatialCalibrationFunction function?

    Thanks,
    Nikita.
  • 2017-03-06-144014

    Pierre --

    I have created and sent an IPX FILE and a TIF FILE per your request above.

    I addressed the e-mail to you and YURI.

    Your assistance with this is much appreciated.

    -- Matt
  • 2017-03-06-144329

    Nikita --

    There are no controls triggered by the COMBOBOX_SPATIALCALIBRATION.

    I populate it in the LOAD and then I use the SELECTEDITEM that it generates in the APPLY ROUTINE shown previously.

    I have just e-mailed a copy of the IPX FILE for this PROJECT to PIERRE and YURI.

    I hope this information is helpful.

    -- Matt

  • Matt,

    It looks like you added all Mediacy references to your project. We found that one reference is not supposed to be added. We will fix it in the next patch, but for now just remove the reference to Mediacy.Automation.Proxy:



    It should fix the problem.

    Yuri
  • 2017-03-06-155442

    Nikita --

    I attempted to follow your suggestion by

        WORKBENCH + SCRIPT RIBBON + REFERENCES

    and unchecking everything (that wasn't locked) except

        MediaCy.AddIn.Measurements.dll

    After that I tested the PROJECT / APP in PREMIER 2D 9.2 and PREMIER 3D 9.3.

    No ERRORS were generated during LOADING or RUNNING the APP.

    YAAAAAAAY!!!

    It seems that some of the REFERENCES were not compatible with each other!

    :-(

    Thank very very much for you for your assistance on this.

    :-)

    -- Matt

Sign In or Register to comment.