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

Can I set the PREMIER 9.1.4 + FEATURES MANAGER + SAVE + SELECTED FEATURES OPTION with CODE?

All --

I've been using the FEATURES MANAGER to SAVE and OPEN .ROI FILES that contain ROIS and MEASUREMENTS.

It looks like some problems can occur if the

    PREMIER 9.1.4 + FEATURES MANAGER + SAVE + SELECTED FEATURES OPTION

gets turned ON.

Is there a way that I can make sure this option is OFF using CODE?

I've attempted to RECORD MACRO but this option does not seem to RECORD.

Thanks.

-- Matt

Best Answers

  • Accepted Answer
    Oh, sorry for confusion. 9.1.4 doesn't like optional parameters:

        Public Sub XYZTurnOffSelected()
            ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)
        End Sub

  • Accepted Answer
    Matt, in your macro a new command is created and it doesn't know if the Features Manager is open or not. You need to use the command from the main command's collection. I've modified the macro:
        Public Sub XYZTurnOffSelected2()
            Debug.Clear
    
            If ThisApplication.Commands("Select.FeaturesManager.FeaturesManager").Checked Then
                Debug.Print "FEATURES MANAGER IS OPEN"
                MsgBox "The FEATURES MANAGER is OPEN.  Please TURN OFF the SAVE SELECTED FEATURES OPTION"
    
            Else
                Debug.Print "FEATURES MANAGER IS CLOSED"
                ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)
    
            End If
        End Sub

Answers

  • Hi Matt,

    This option exposed as "Selected" in the Save command and holds an array of the selected features. So, you do not need to turn it off for the macros. 
    If you need to turn it off in UI (Features manager should be closed) call: Application.Settings(, "FeaturesManager").Set("cbSelected", False)

    Thanks,
    Nikita.
  • Nikita --

    Thank you for your prompt response to my question.

    I've created the following SUBROUTINE to test your solution.

        Public Sub TurnOffSelectedFeatureSaveWithinFeaturesManager()
    
            Application.Settings(, "FeaturesManager").Set("cbSelected", False)
    
        End Sub
    When I run this SUBROUTINE, I get an error that says

        "Expecting a valid data type (eg. Integer)."

    at CHAR 28 within the line that starts APPLICATION.SETTINGS.

    Since my EDITOR is not showing SETTINGS as a PROPERTY or METHOD for APPLICATION, can you help me resolve this please?

    Thanks.

    -- Matt


  • Matt,

    You should use 

    ThisApplication.Settings(, "FeaturesManager").Set("cbSelected", False)

    Yuri
  • Yuri --

    Thank you for your contribution.

    I've tried to implement your suggestion with

        Public Sub XYZTurnOffSelected()
    
            'Application.Settings(, "FeaturesManager").Set("cbSelected", False)
            ThisApplication.Settings(, "FeaturesManager").Set("cbSelected", False)
    
        End Sub
    I can LOAD the code but when I try to run the SUBROUTINE, I get an error that says

        "Ambiguous match found."

    This happens whether the FEATURES MANAGER is OPEN or CLOSED.

    I thought that might be due to the LONG name I originally gave this routine but shortening the name did not resolve the issue.

    Can you please direct me to the problem?

    Thanks.

    -- Matt


  • Nikita and Yuri --

    The combination solution of

        Public Sub XYZTurnOffSelected()
            ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)
        End Sub
    works (when the FEATURES MANAGER is CLOSED).

    Just an LEARNING OPPORTUNITY, I tried to make a version of the SUBROUTINE that would sense whether the FEATURES MANAGER is OPEN or CLOSED.

    I was not successful with

        Public Sub XYZTurnOffSelected2()
    
            Debug.Clear
    
            If ( _
                Select.FeaturesManagerCommands.FeaturesManager(Nothing).CheckState = _
                MediaCy.IQL.Application.McCommand.mcCheckState.Checked _
                ) _
                Then
    
                    Debug.Print "FEATURES MANAGER IS OPEN"
    
                    MsgBox "The FEATURES MANAGER is OPEN.  Please TURN OFF the SAVE SELECTED FEATURES OPTION"
    
                Else
    
                    Debug.Print "FEATURES MANAGER IS CLOSED"
    
                    ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)
    
                End If
    
        End Sub
    Is there a way to correct this routine?

    I know that I can close the FEATURES MANAGER with something like

        Public Function NewMacro2() As SimpleScript
            NewMacro2 = New SimpleScript
    
            With Select.FeaturesManagerCommands.FeaturesManager(NewMacro2)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
                .Run()
            End With
    
        End Function
    but I'm trying to learn the INS and OUTS of PROGRAMMING PREMIER.

    Thanks.

    -- Matt
  • Nikita --

    Thanks for the INFO and the CODE.

    I'll try out ASAP.

    Thanks again.

    -- Matt
  • Nikita and Yuri --

    I have tried the CODE below and it is now a great example of how to handle these two aspects of programming PREMIER.

    Thank you

    -- Matt

        Public Sub XYZTurnOffSelected2()
            Debug.Clear
    
            If ThisApplication.Commands("Select.FeaturesManager.FeaturesManager").Checked Then
                Debug.Print "FEATURES MANAGER IS OPEN"
                MsgBox "The FEATURES MANAGER is OPEN.  Please TURN OFF the SAVE SELECTED FEATURES OPTION"
    
            Else
                Debug.Print "FEATURES MANAGER IS CLOSED"
                ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)
    
            End If
        End Sub


Sign In or Register to comment.