Snapshotting Several Files

ansonmccosh wrote on 2/4/2025, 7:18 PM

I don't know if anyone could help me create in a script in which i batch render snapshots of several images in one action. Initially i was thinking of something that can snapshot wherever a marker was placed. or indivudally snapshotting images in 4 different layers..i don't know which would easier...

Any ideas would be great..thanks in advance

Comments

Thiago_Sase wrote on 2/5/2025, 5:08 AM

@ansonmccosh Hello, maybe this script can help you.

1º - Set the Markers;
2º - Run the Script;
3º - Set folder path destination.
 

using System;
using System.IO;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    private Vegas myVegas;

    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;

        // Initialize a string variable for the output folder path
        string outputFolder = string.Empty;

        // Create a SaveFileDialog to select a folder (simulating your example)
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.Title = "Select Output Folder";
        saveFileDialog.Filter = "PNG files (*.png)|*.png"; // Set filter to PNG
        saveFileDialog.FileName = "Snapshot.png"; // Default file name

        // Show the dialog and check if the user selects a folder
        if (saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            // Get the directory from the selected file path
            outputFolder = Path.GetDirectoryName(saveFileDialog.FileName);
        }

        // Check if a folder was selected
        if (string.IsNullOrEmpty(outputFolder))
        {
            MessageBox.Show("No folder selected. Exiting script.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return;
        }

        // Get the project markers
        int markerCount = myVegas.Project.Markers.Count;
        if (markerCount == 0)
        {
            MessageBox.Show("No markers found in the timeline.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return;
        }

        // Iterate through each marker
        for (int i = 0; i < markerCount; i++)
        {
            Marker marker = myVegas.Project.Markers[i];

            // Move the cursor to the marker's position
            myVegas.Transport.CursorPosition = marker.Position;

            // Generate the snapshot file name
            string snapshotFileName = Path.Combine(outputFolder, "Snapshot_" + (i + 1) + ".png"); // Change extension to PNG

            // Save snapshot to file in PNG format
            myVegas.SaveSnapshot(snapshotFileName, ImageFileFormat.PNG); // Correctly saving as PNG
        }

        MessageBox.Show("Snapshots have been saved to: " + outputFolder, "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}

jetdv wrote on 2/5/2025, 9:00 AM

ansonmccosh wrote on 2/5/2025, 1:44 PM

Thanks..this solved my issue