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

Closing images

Hello,

I am new to programming macros in Image Pro. I want to batch process 1200 images. The batch process macro will:
  1.  flatten the image
  2. manually threshold objects (from a file) in the image
  3. Count objects
  4. Send count measurements to Data Collector
  5. Create a mask of the counted objects
  6. Save mask via quick publication
  7. Close mask and image
I can not get the mask and image to close. I need them to close otherwise the batch processing stops after 100 images due to too many images being open. How do I get the images to close? I have tried the close documents setting with batch processing but that only closes the image not the mask. I can't get close all to work inside my macro either. Please help. Here is the macro code if that helps.

Public Function Counting_3() As SimpleScript
Counting_3 = New SimpleScript
Dim doc1, image1, doc2, varList1

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

With Process.Filter.EnhancementCommands.Flatten(Counting_3)
.BrightOnDark = False
.FeatureWidth = 20
.Run(doc1, doc1)
End With

With Measure.ThresholdToolCommands.Open(Counting_3)
.FileName = ThisApplication.Path(mcPathType.mcptConfigurationFiles) & "Threshold, 6-21 vent-S7.rge"
.FilterIndex = 1
.Run(doc1)
End With

With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "CountSize"
.Active = False
.Run()
End With

With Measure.MeasurementsCommands.ExecuteCount(Counting_3)
.Run(doc1)
End With

With Measure.ThresholdTool.Gadgets.Histogram(Counting_3)
.CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Unchecked
.Run()
End With

With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "Share"
.Active = False
.Run()
End With

With Measure.Data.CollectorCommands.Collect(Counting_3)
.Image = .GetImage("Measure.Data.Collector.Collect")
.Run(New List({doc1}))
End With

With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "CountSize"
.Active = False
.Run()
End With

With Measure.Measurements.CreateCommands.Mask(Counting_3)
.Run(doc1, image1)
End With

With Application.DocumentCommands.Activate(Counting_3)
.Run(image1, doc2)
End With

With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "Capture"
.Active = False
.Run()
End With

With Application.WindowCommands.QuickSaveSelectedForPublication(Counting_3)
.Run(varList1)
End With

With Application.RibbonCommands.SelectRibbonTab(Counting_3)
.TabName = "View"
.Active = False
.Run()
End With

With Application.DocumentCommands.CloseAllViews(Counting_3)
.Run(ThisApplication.ActiveImage)
End With

With Application.DocumentCommands.Activate(Counting_3)
.Run(doc1, doc1)
End With

End Function

Best Answer

  • Accepted Answer
    Hi misbrit2128

    You can add CloseAll command in the end of the macro:

            With Application.WindowCommands.CloseAll(Counting_3)
                .Run()
            End With
    

    Yuri

Answers

Sign In or Register to comment.