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

ROI Selection

Hello

I'm writing a macro where the user selects the measured cells they are interested in and they are added to the Features manager so that the outline can be applied somewhere else. I recorded the code to do this but when I go back over it, it doesn't work. Code below

Dim var1 = "P1R1", meas1
        Dim doc1
        With Measure.MeasurementsCommands.Define(Nothing)
           .Run(var1, meas1)
        End With

       With Measure.MeasurementsCommands.Selection(Nothing)
           .SelectionFlag = McMeasurements.enumMMSelTypes.mcmmsfAddWithReset
           .Run(doc1, meas1)
       End With

       With Select.FeaturesManagerCommands.Add(Nothing)
           .Source = FeaturesManager.SourceType.Measurements
           .Collection = 0
           .Feature = -1
           .Run(doc1)
       End With


I'm using Premier 3D 64-bit Version 9.1.2 Build 5429, is the record not adding the correct references. I've had a look but can't see any obvious references to add.

Any help appreciated

Dave

Best Answer

  • Options
    edited June 2014 Answer ✓
    David,

    Your code specifically selects "P1R1" subfeature and if the image doesn't have it' it gives an error. Also doc1 is not defined either, which can give you another error.
    If you want to do interactive selection, you should activate Interactive option, as in the macro below:

        Public Function SelectMacro() As SimpleScript
            SelectMacro = New SimpleScript
            Dim meas1, doc1
    
            With Application.DocumentCommands.Active(SelectMacro)
                .Run(doc1)
            End With
    
            With Measure.MeasurementsCommands.Selection(SelectMacro)
                .SelectionFlag = McMeasurements.enumMMSelTypes.mcmmsfAddWithReset
                .Interactive = True
                .Run(doc1, meas1)
            End With
    
            With Measure.MeasurementsCommands.ShowSelected(SelectMacro)
                .Action = McMeasurements.enumShowMeasFlags.smfShowSel
                .FeatureClass = -1
                .Run(doc1)
            End With
    
            With Select.FeaturesManagerCommands.Add(SelectMacro)
                .Source = FeaturesManager.SourceType.Measurements
                .Collection = 0
                .Feature = -1
                .Run(doc1)
            End With
    
        End Function
    

    Please test the macro as it is and let me know if it works for you.

    Regards,

    Yuri

Answers

  • Options

    Hello Yuri

    Yes and the interactive bit does it much better than the way I was going to do it

    Thanks

    David

Sign In or Register to comment.