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

How is the best way to create a SEQUENCE from a number of INDIVIDUAL TIF IMAGE FILES?

All --

The following section of code was recorded while opening 6 TIF IMAGES as a SINGLE SEQUENCE.

    Public Function NewMacro() As SimpleScript
        NewMacro = New SimpleScript
        Dim docList1 = New List(1), doc1

        With Application.DocumentCommands.OpenSequence(NewMacro)
            .Filenames = New String() {"C:\GE123\Collage No. 001.tif","C:\GE123\Collage No. 002.tif","C:\GE123\Collage No. 003.tif","C:\GE123\Collage No. 004.tif","C:\GE123\Collage No. 005.tif","C:\GE123\Collage No. 006.tif"}
            .Run(docList1)
        End With

        With Application.DocumentCommands.Activate(NewMacro)
            .Run(docList1(0), doc1)
        End With

    End Function
The number of COLLAGE IMAGES in the GE123 FOLDER can vary so this code fragment needs to be changed to allow for this.

The LIST OF FILES in the .FILENAME line is a series of INDIVIDUAL COMPLETE FILE NAMES that is flanked by quote marks and separated with commas so I don't know how to have the program create a properly formatted list to feed to the OPEN SEQUENCE COMMAND.

I can use code like

    F = Dir("*.*")
    While F <> ""
        Debug.Print F
        F = Dir()
    EndWhile

to find all of the FILE NAMES but I don't know how to build the list and pass it to the OPEN SEQUENCE COMMAND.

Can someone please point me in the right direction.

Thanks.

-- Matt


Best Answer

  • Options
    Answer ✓
    Matt,

    Here is a macro to do that.

    Pierre

        Public Function OpenAsSequence() As SimpleScript
            OpenAsSequence = New SimpleScript
            Dim docList1 = New List(1), doc1
            ' User Code
            Dim files() As String
    
            With Automate.ScriptingCommands.CodeCommand(OpenAsSequence)
                If .Run() Then
                    ' User Code Here
                    files = system.IO.Directory.GetFiles(ThisApplication.Path(mcPathType.mcptSampleImages) & "HDR")
                End If
            End With
    
            With Application.DocumentCommands.OpenSequence(OpenAsSequence)
                .Filenames = files
                .Run(docList1)
            End With
    
            With Application.DocumentCommands.Activate(OpenAsSequence)
                .Run(docList1(0), doc1)
            End With
    
        End Function
    

Answers

  • Options
    Pierre --

    Thank you for the EXAMPLE CODE.

    I'll wire it in and give you FEEDBACK ASAP.

    Thanks again.

    -- Matt


  • Options
    Pierre --

    Thank you for the EXAMPLE CODE.

    I massaged it into the following SUBROUTINE that works exactly as I need.

    Thanks again.

    -- Matt

    **************************************************
        Private Sub button_CreateCollageSequence_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_CreateCollageSequence.Click
    
            'Declare local variables
            Dim MyDocList1 = New List(1)
            Dim MyFiles() As String
    
            'Close all open images without prompting user
            CloseAllForm.ClosingAllAction=CloseAllForm.CloseAllFormAction.actionNoAll
            ThisApplication.Windows.CloseAll()
    
            'Create a list of the TIF FILES in the NAMED FOLDER
            MyFiles = _
                system.IO.Directory.GetFiles("C:\GE123","*.TIF")
    
            'If TIF FILES were found
            If ( UBound (MyFiles) >= 0 ) _
                Then
    
                    'Open the TIF IMAGES as a SEQUENCE
                    With Application.DocumentCommands.OpenSequence(Nothing)
                        .Filenames = MyFiles
                        .Run(MyDocList1)
                    End With
    
                End If
    
        End Sub


Sign In or Register to comment.