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

Number of frames

Hello

I'm trying to use the code below (from a previous forum post) to get the number of frames from a z stack

If ThisApplication.ActiveDocument Is Nothing Then Exit Sub 'No Document
        Dim imSet As McImageSet=ThisApplication.ActiveDocument.GetData(GetType(McImageSet),Nothing) 'populate imSet with image data
        If imSet Is Nothing Then Exit Sub 'not a set

It exits the code at the not a set. Are z stacks not classed as sets in which case which commands should I use. I found FrameCount in the automation help file under the title IMcImage Interface, but I can't figure out how to declare a variable to use it. 


Best Answer

  • Answer ✓
    David,

    The active document can be based on McImageSet or McImage depending on what source file it was loaded from. If it was just a TIF or SEQ file, then it can be McImage and the number of frames can be found as McImage.FrameCount property.

        Public Sub GetNumberOfFramesInImage
            If ThisApplication.ActiveDocument Is Nothing Then Exit Sub 'No Document
            Dim im As McImage=ThisApplication.ActiveDocument.GetData(GetType(McImage),Nothing) 'check if it's McImage
            If im Is Nothing Then Exit Sub 'not an image
            Debug.Print (im.FrameCount)
        End Sub
    

    Yuri

Answers

  • Hello Yuri

    That works and has also opened up some other commands I wasn't sure about.

    Thanks

Sign In or Register to comment.