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

How to prompt user for spatial calibration

I am capturing 4 different images to the image strip. Then I manually lock the selected images so that they appear in the image frame. I would like to prompt a ipp user to select a spatial calibration from a list and apply it to each of the 4 images, but I have no experience with VB or writing and editing macros. The spatial calibration would be the same for each of the 4 images, but the spatial calibration might be different for each group of 4. I recorded a macro of the sequence that would work if I always used the same spatial calibration, but I can't figure out how to show the list of available spatial calibrations and allow the user to select one. Any help is appreciated 

Best Answer

  • Answer ✓
    Hi Jeff,

    This macro will show calibration dialog prompting to select calibration and then applies it to all selected in the Image strip images:

        Public Function CalibrateSelectedImages() As SimpleScript
            CalibrateSelectedImages = New SimpleScript
    
            With Application.Gadgets.SpatialCalibration(CalibrateSelectedImages)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Interactive=True
                .Prompt="Please select calibration and click Ok"
                .InteractionPanel="SCalibration"
                .InteractionLocation=McCommand.InteractionPosition.OutsideLeft
                .FilterInput = False
                .Run()
            End With
    
            With Automate.ScriptingCommands.CodeCommand(CalibrateSelectedImages)
                If .Run() Then
                    ' User Code Here
                    For Each wnd As McWindow In ThisApplication.WindowsEx.SelectionManager.Items
                        Dim im As McImage=wnd.Document.Data
                        'apply selected calibration
                        If im IsNot Nothing Then
                            im.SpatialCalibration=Mediacy.Addins.SCalibration.modGlobals.m_SCalib
                        End If
                    Next
                End If
            End With
    
        End Function
    
    Regards,

    Yuri

Answers

  • Thanks Yuri. How do I actually make a macro to use this code. Where do I put it and how do I name it?
  • I placed your code as shown below, but, when I try to execute it, I receive the following error message:

    Expecting a valid data type (e.g. integer).
    Module 'Module1.vb',line 22, character 93.

    I've seen other posts about problems associated with having a spatial calibration labeled as "non" which contains nothing. Could that be the reason for the error?

    Here's how I added the code:

    Public Module Module1
     Public Function CalibrateSelectedImages() As SimpleScript
            CalibrateSelectedImages = New SimpleScript

            With Application.Gadgets.SpatialCalibration(CalibrateSelectedImages)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Interactive=True
                .Prompt="Please select calibration and click Ok"
                .InteractionPanel="SCalibration"
                .InteractionLocation=McCommand.InteractionPosition.OutsideLeft
                .FilterInput = False
                .Run()
            End With

            With Automate.ScriptingCommands.CodeCommand(CalibrateSelectedImages)
                If .Run() Then
                    ' User Code Here
                    For Each wnd As McWindow In ThisApplication.WindowsEx.SelectionManager.Items
                        Dim im As McImage=wnd.Document.Data
                        'apply selected calibration
                        If im IsNot Nothing Then
                            im.SpatialCalibration=Mediacy.Addins.SCalibration.modGlobals.m_SCalib
                        End If
                    Next
                End If
            End With

        End Function
    End Module


  • Hi Jeff,

    The error is related to a missiing reference or Import statement. When you record macro they are added automatically.
    Try to record a new macro where you open a calibration dialog. It should all necessary references to the project.

    Yuri

  • Sorry. You lost me on that one.
  • Ok, if it's new for you, I've attached a project that contains that macro (and all necessary references and imports), just double click on the IPX file, it will be opened by Premier, and then run CalibrateSelectedImages macro from this project.

    Yuri
  • Sorry, the previous project contained one wrong reference (for Premnier 3D). Please use the new attached project.(zipped)

    Yuri
  • Thanks again, but that generated the following error when I attempted to run it:

    Unexpected text.
    Project,'project1',module'Macros.vb',line 8,character 8
  • I don't see that error in my Premier 9.1.4. Line 8 is 
    Imports MediaCy.Commands
    
    you can disable it adding ' in front:

    'Imports MediaCy.Commands
    
    
    Let me know if it helps,

    Yuri
  • BTW, I see that you actually reported error in different project "project1", my project is "CalibrateSelected", so you should just close/remove all other projects that cause errors.

    Yuri
  • Thanks for your help.
Sign In or Register to comment.