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

Error -2146233070 - Method 'MediaCy.Commands.Features.FeaturesManager.SetType.Run' not found

HI folks, 
Can anybody tell me what happens here? 

I am running parent child analyses, first using a mask in which I measure the parents, then I load the parents as objects and ROIs onto the original with the children... 

Code works fine with few parents but now an error is thrown. The only difference is that there are many more objects thus parents. 

Here the code of this sub (don't mind surroundings...):

 
    Public Function MeasureParentMask2() As SimpleScript
        MeasureParentMask2 = New SimpleScript
    MeasureParentMask2.SaveUndoSteps = False
 
Dim docList2 = New List(1), doc1, doc2, image1
 
On Error GoTo Ferror
With Automate.ScriptingCommands.CodeCommand(MeasureParentMask2)
If .Run() Then
 
        With Application.DocumentCommands.Active(MeasureParentMask2)
            .Run(doc1)
        End With
 
        With Application.DocumentCommands.OpenImage(MeasureParentMask2)
            .Filenames = New String() {MaskReloadName}
            .Run(docList2)
        End With
 
        With Application.DocumentCommands.Activate(MeasureParentMask2)
            .Run(docList2(0), doc2)
        End With
 
 
       With Automate.ScriptingCommands.CodeCommand(MeasureParentMask2)
            If .Run() Then
                If decDilateMask = True Then
                DilateMask
                End If
                If decErodeMask = True Then
                ErodeMask
                End If
            End If
        End With
 
 
 
        With Measure.MeasurementsCommands.Options(MeasureParentMask2)
            .Classes = New System.Collections.Generic.List(Of MMClassDescr)
                .Classes.Add(New MMClassDescr("Class 1",System.Drawing.Color.Blue,ePointShape.LargeTarget90))
            .ActiveClass = 1
            .Run(doc2)
        End With
 
        With Measure.Measurements.OptionsCommands.Open(MeasureParentMask2)
            .FileName = "D:\IPP\Premier_macros\MeasurementOptions\ParentAb10_with_split.iqo"
            .FilterIndex = 1
            .Run(doc2)
        End With
 
 
        With Measure.ThresholdToolCommands.Thresholds(MeasureParentMask2)
            .AllowOverlap = False
            .Interpretation = eInterpretation.Mono
            .Classes = New System.Collections.Generic.List(Of SegmentationClass)
            .Classes.Add(New SegmentationClass("Parent",System.Drawing.Color.Black,New Double(){2,255}))
            .Run(doc2)
        End With
 
 
 
        With Measure.MeasurementsCommands.ExecuteCount(MeasureParentMask2)
            .Run(doc2)
        End With
 
 
 
GetParentChildDataSub()
 
 
 
        With Select.FeaturesManagerCommands.FeaturesManager(MeasureParentMask2)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
            .Run()
        End With
 
 
 
        With Select.FeaturesManagerCommands.RemoveAll(MeasureParentMask2)
            .Run()
        End With
 
              With Select.FeaturesManagerCommands.Add(MeasureParentMask2)
            .Source = FeaturesManager.SourceType.All
            .Collection = 0
            .Feature = -1
            .Run(doc2)
        End With
 
        With Application.DocumentCommands.Activate(MeasureParentMask2)
            .Run(doc1, doc1)
        End With
 
        With Select.RoiCommands.DeleteAll(MeasureParentMask2)
            .Run(ThisApplication.ActiveImage)
        End With
 
 
        With Select.FeaturesManagerCommands.SetType(MeasureParentMask2)
            .Collection = 0
            .Feature = 0
            .Destination = FeaturesManager.mcCollectionType.mcctMeasurements
            .Run(ThisApplication.ActiveImage)
        End With
 
 
        With Select.FeaturesManagerCommands.Apply(MeasureParentMask2)
            .Collection = 0
            .Feature = 0
            .Item = -1
            .Run(ThisApplication.ActiveImage)
        End With
 
        With Select.FeaturesManagerCommands.SetType(MeasureParentMask2)
            .Collection = 0
            .Feature = 0
            .Destination = FeaturesManager.mcCollectionType.mcctROIs
               .Run(ThisApplication.ActiveImage)
        End With
 
        With Select.FeaturesManagerCommands.Apply(MeasureParentMask2)
            .Collection = 0
            .Feature = 0
            .Item = -1
                .Run(ThisApplication.ActiveImage)
        End With
 
End If
End With
 
Ferror:
MsgBox ( _
        "The following error was thrown" & vbLf & vbLf & _
        Str( Err.Number ) & " -- " & Err.Description , _
        vbOkOnly, _
        "whatever it is . . . ")
 
 
 
 
 
    End Function


It's those  lines when the error is reported
.Destination = FeaturesManager.mcCollectionType.mcctROIs
               .Run(ThisApplication.ActiveImage)

Thx
Dan

Answers

  • Hi Dan,

    Look like the order of the commands is not correct. Please take a look on general macro to convert measurements to ROIs (ConvertMeasurementsToROIs).

    Thanks,
    Nikita.

        Public Function ConvertMeasurementsToROIs() As SimpleScript
            ConvertMeasurementsToROIs = New SimpleScript
            Dim doc1
    
            'get active document
            With Application.DocumentCommands.Active(ConvertMeasurementsToROIs)
                .Run(doc1)
            End With
    
            'delete all ROIs
            With [Select].RoiCommands.DeleteAll(ConvertMeasurementsToROIs)
                .Run(doc1)
            End With
    
            'delete all features in features manager
            With [Select].FeaturesManagerCommands.RemoveAll(ConvertMeasurementsToROIs)
                .Run()
            End With
    
            'deselect all measurements 
            With Measure.MeasurementsCommands.Selection(ConvertMeasurementsToROIs)
                .SelectionFlag = McMeasurements.enumMMSelTypes.mcmmsfAddWithReset
                .Run(doc1, Nothing)
            End With
    
            'import all measurements into features manager
            With [Select].FeaturesManagerCommands.Add(ConvertMeasurementsToROIs)
                .Source = FeaturesManager.SourceType.Measurements
                .Collection = -1
                .Feature = -1
                .Run(doc1)
            End With
    
            'convert measurements into ROIs
            With [Select].FeaturesManagerCommands.SetType(ConvertMeasurementsToROIs)
                .Collection = 0
                .Feature = 0
                .Destination = FeaturesManager.mcCollectionType.mcctROIs
                .Run()
            End With
    
            'export ROIs into document
            With [Select].FeaturesManagerCommands.Apply(ConvertMeasurementsToROIs)
                .Collection = 0
                .Feature = 0
                .Item = -1
                .Run(doc1)
            End With
    
        End Function
  • Thanks Nikita, 
    I'll try this out - though to mention that the code generally worked. The error just appeared when there were many objects.... 

    Cheers
    Dan
Sign In or Register to comment.