This thread is dedicated to Only VEGAS Pro SCRIPTS.
so if you have created any script which can be helpful for VEGAS Users.
then share it here.
Conditions.
@iEmby, no, you've been making standard scripts - just compiled into a DLL - that can be found under Tools - Scripting (- Run Script.)
I gave you the information for creating a custom command. Just go through my Custom Command playlist.
There's a blank "Custom Command" you can download listed in one of the descriptions and then change 9 (I think it was 9) main pieces of information - all related to the naming of the Custom Command and where it appears in VEGAS. Then move all of your code (including your form) into that blank custom command. A custom command MUST be compiled into a DLL to work and must be placed in the proper folder for VEGAS to find it upon startup.
You should set it up so that it will be found under "View - Extensions." The other options are "Edit - Extensions" and "Tools - Extensions." Once it's a Custom Command, you'll be able to dock it and it will always be available without having to "start" it each time.
ok sir... let me check those playlist
Close Gaps Advanced | SCRIPT
This Script will close gaps in a lot of scenarios.
using System;
using System.Collections.Generic;
using ScriptPortal.Vegas;
namespace Test_Script
{
public class Class1
{
public Vegas myVegas;
public void Main(Vegas vegas)
{
myVegas = vegas;
// Define the gap duration (e.g., 0 second)
Timecode gapDuration = new Timecode("00:00:00:00");
// List to hold all selected video events and their grouped audio counterparts
List<List<TrackEvent>> eventGroups = new List<List<TrackEvent>>();
foreach (Track track in myVegas.Project.Tracks)
{
foreach (TrackEvent trackEvent in track.Events)
{
if (trackEvent == null || !trackEvent.Selected) continue;
if (trackEvent.Group != null)
{
// Only add the group if it's not already added
bool groupExists = false;
foreach (var group in eventGroups)
{
if (group.Contains(trackEvent))
{
groupExists = true;
break;
}
}
if (!groupExists)
{
// Create a group to store all grouped events (video and audio)
List<TrackEvent> eventGroup = new List<TrackEvent>();
foreach (TrackEvent groupedEvent in trackEvent.Group)
{
eventGroup.Add(groupedEvent);
}
eventGroups.Add(eventGroup);
}
}
else
{
// Handle non-grouped events individually
eventGroups.Add(new List<TrackEvent> { trackEvent });
}
}
}
// Sort event groups by the start time of the first event in each group
eventGroups.Sort((a, b) => a[0].Start.CompareTo(b[0].Start));
// Close gaps between event groups
if (eventGroups.Count > 0)
{
// Initialize current start time with the first event's start time
Timecode currentStartTime = eventGroups[0][0].Start;
foreach (var group in eventGroups)
{
// Find the earliest start time in the current group
Timecode earliestStart = group[0].Start;
foreach (var trackEvent in group)
{
if (trackEvent.Start < earliestStart)
{
earliestStart = trackEvent.Start;
}
}
// Calculate the offset needed to move the earliest event to the current start time
Timecode offset = currentStartTime - earliestStart;
// Apply the offset to all events in the group
foreach (var trackEvent in group)
{
trackEvent.Start += offset;
}
// Find the latest end time in the current group after moving
Timecode latestEndTime = Timecode.FromFrames(0);
foreach (var trackEvent in group)
{
Timecode end = trackEvent.Start + trackEvent.Length;
if (end > latestEndTime)
{
latestEndTime = end;
}
}
// Set the start time for the next group to avoid overlap
currentStartTime = latestEndTime + gapDuration;
}
}
}
}
}
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
Test_Script.Class1 test = new Test_Script.Class1();
test.Main(vegas);
}
}
Ducking Audio Effect | SCRIPT
This Script will do a Ducking audio Effect on a selected Audio Event.
using System;
using System.IO;
using System.Windows.Forms;
using ScriptPortal.Vegas;
namespace Test_Script
{
public class Class1
{
public Vegas myVegas;
public void Main(Vegas vegas)
{
myVegas = vegas;
try
{
// Configuration parameters
AudioConfig config = InitializeConfig();
// Calculate the duration for fading
Timecode fadeDuration = CalculateFadeDuration(config.FadeMode, config.FadeMilliseconds);
// Locate the selected audio event
TrackEvent audioEvent = FindSelectedAudioEvent(myVegas);
if (audioEvent == null)
throw new Exception("Please select an audio event.");
// Retrieve or create the volume envelope
Envelope volumeEnvelope = GetOrCreateVolumeEnvelope(audioEvent.Track);
// Set envelope points for the audio ducking
AddFadePoints(volumeEnvelope, audioEvent, fadeDuration, config);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private AudioConfig InitializeConfig()
{
// Default configuration
return new AudioConfig
{
FadeMode = 2,
FadeMilliseconds = 2000,
HighVolume = 1.0,
LowVolume = 0.25
};
}
private Timecode CalculateFadeDuration(int fadeType, double fadeMilliseconds)
{
double adjustedFadeMs = fadeType == 2 ? fadeMilliseconds * 0.5 : fadeMilliseconds;
return new Timecode(adjustedFadeMs);
}
private TrackEvent FindSelectedAudioEvent(Vegas vegas)
{
foreach (Track track in vegas.Project.Tracks)
{
if (track.IsAudio())
{
foreach (TrackEvent evt in track.Events)
{
if (evt.Selected)
{
return evt;
}
}
}
}
return null;
}
private Envelope GetOrCreateVolumeEnvelope(Track track)
{
Envelope volumeEnv = LocateEnvelope(track, EnvelopeType.Volume);
if (volumeEnv == null)
{
volumeEnv = new Envelope(EnvelopeType.Volume);
track.Envelopes.Add(volumeEnv);
}
return volumeEnv;
}
private Envelope LocateEnvelope(Track track, EnvelopeType type)
{
foreach (Envelope env in track.Envelopes)
{
if (env.Type == type)
{
return env;
}
}
return null;
}
private void AddFadePoints(Envelope volumeEnv, TrackEvent audioEvent, Timecode fadeDuration, AudioConfig config)
{
Timecode eventStart = audioEvent.Start;
Timecode eventLength = audioEvent.Length;
// Set fade-in points
volumeEnv.Points.Add(new EnvelopePoint(eventStart - fadeDuration, config.HighVolume));
if (config.FadeMode == 2)
{
volumeEnv.Points.Add(new EnvelopePoint(eventStart + fadeDuration, config.LowVolume));
}
else
{
volumeEnv.Points.Add(new EnvelopePoint(eventStart, config.LowVolume));
}
// Set fade-out points
if (config.FadeMode == 2)
{
volumeEnv.Points.Add(new EnvelopePoint(eventStart + eventLength - fadeDuration, config.LowVolume));
}
else
{
volumeEnv.Points.Add(new EnvelopePoint(eventStart + eventLength, config.LowVolume));
}
volumeEnv.Points.Add(new EnvelopePoint(eventStart + eventLength + fadeDuration, config.HighVolume));
}
// Class to hold audio configuration
private class AudioConfig
{
public int FadeMode { get; set; }
public double FadeMilliseconds { get; set; }
public double HighVolume { get; set; }
public double LowVolume { get; set; }
}
}
}
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
Test_Script.Class1 test = new Test_Script.Class1();
test.Main(vegas);
}
}
Add Video or Audio Track, Above or Bellow of a Selected Event | SCRIPT
If you select an Event, then a Video Track or Audio Track will be added Above or Bellow of that selection. Also, have an option to delete a selected track with Events.
using System;
using System.Drawing;
using System.Windows.Forms;
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Create a form
Form form = new Form();
form.Text = "Add Tracks";
form.StartPosition = FormStartPosition.CenterScreen;
form.FormBorderStyle = FormBorderStyle.Sizable; // Make the form movable
form.MaximizeBox = false;
form.MinimizeBox = false;
form.Size = new Size(180, 280); // Adjusted size to provide more space
form.BackColor = Color.FromArgb(40, 40, 40); // Dark background color
// Set Segoe UI font
Font commonFont = new Font("Segoe UI", 10, FontStyle.Regular);
form.Font = commonFont;
form.ForeColor = Color.White;
// Video Track Title
Label lblVideoTrack = new Label();
lblVideoTrack.Text = "Add Video Track:";
lblVideoTrack.Size = new Size(150, 20);
lblVideoTrack.Location = new Point(20, 15); // Moved to the left
lblVideoTrack.ForeColor = Color.White;
// Video Track Buttons
Button btnAddVideoAbove = new Button();
btnAddVideoAbove.Text = "▲"; // Up arrow
btnAddVideoAbove.Size = new Size(40, 35);
btnAddVideoAbove.Location = new Point(20, 40); // Moved to the left
btnAddVideoAbove.BackColor = Color.FromArgb(60, 60, 60);
btnAddVideoAbove.ForeColor = Color.White;
btnAddVideoAbove.FlatStyle = FlatStyle.Flat;
btnAddVideoAbove.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
// Add hover effect
btnAddVideoAbove.MouseEnter += (sender, e) => btnAddVideoAbove.BackColor = Color.FromArgb(100, 149, 237);
btnAddVideoAbove.MouseLeave += (sender, e) => btnAddVideoAbove.BackColor = Color.FromArgb(60, 60, 60);
btnAddVideoAbove.Click += (sender, e) =>
{
AddTrack(vegas, TrackType.Video, true);
form.Close(); // Close the form
};
Button btnAddVideoBelow = new Button();
btnAddVideoBelow.Text = "▼"; // Down arrow
btnAddVideoBelow.Size = new Size(40, 35);
btnAddVideoBelow.Location = new Point(80, 40); // Moved to the left
btnAddVideoBelow.BackColor = Color.FromArgb(60, 60, 60);
btnAddVideoBelow.ForeColor = Color.White;
btnAddVideoBelow.FlatStyle = FlatStyle.Flat;
btnAddVideoBelow.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
// Add hover effect
btnAddVideoBelow.MouseEnter += (sender, e) => btnAddVideoBelow.BackColor = Color.FromArgb(100, 149, 237);
btnAddVideoBelow.MouseLeave += (sender, e) => btnAddVideoBelow.BackColor = Color.FromArgb(60, 60, 60);
btnAddVideoBelow.Click += (sender, e) =>
{
AddTrack(vegas, TrackType.Video, false);
form.Close(); // Close the form
};
// Audio Track Title
Label lblAudioTrack = new Label();
lblAudioTrack.Text = "Add Audio Track:";
lblAudioTrack.Size = new Size(150, 20);
lblAudioTrack.Location = new Point(20, 90); // Moved to the left
lblAudioTrack.ForeColor = Color.White;
// Audio Track Buttons
Button btnAddAudioAbove = new Button();
btnAddAudioAbove.Text = "▲"; // Up arrow
btnAddAudioAbove.Size = new Size(40, 35);
btnAddAudioAbove.Location = new Point(20, 115); // Moved to the left
btnAddAudioAbove.BackColor = Color.FromArgb(60, 60, 60);
btnAddAudioAbove.ForeColor = Color.White;
btnAddAudioAbove.FlatStyle = FlatStyle.Flat;
btnAddAudioAbove.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
// Add hover effect
btnAddAudioAbove.MouseEnter += (sender, e) => btnAddAudioAbove.BackColor = Color.FromArgb(100, 149, 237);
btnAddAudioAbove.MouseLeave += (sender, e) => btnAddAudioAbove.BackColor = Color.FromArgb(60, 60, 60);
btnAddAudioAbove.Click += (sender, e) =>
{
AddTrack(vegas, TrackType.Audio, true);
form.Close(); // Close the form
};
Button btnAddAudioBelow = new Button();
btnAddAudioBelow.Text = "▼"; // Down arrow
btnAddAudioBelow.Size = new Size(40, 35);
btnAddAudioBelow.Location = new Point(80, 115); // Moved to the left
btnAddAudioBelow.BackColor = Color.FromArgb(60, 60, 60);
btnAddAudioBelow.ForeColor = Color.White;
btnAddAudioBelow.FlatStyle = FlatStyle.Flat;
btnAddAudioBelow.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
// Add hover effect
btnAddAudioBelow.MouseEnter += (sender, e) => btnAddAudioBelow.BackColor = Color.FromArgb(100, 149, 237);
btnAddAudioBelow.MouseLeave += (sender, e) => btnAddAudioBelow.BackColor = Color.FromArgb(60, 60, 60);
btnAddAudioBelow.Click += (sender, e) =>
{
AddTrack(vegas, TrackType.Audio, false);
form.Close(); // Close the form
};
// Delete Selected Track Title
Label lblDeleteTrack = new Label();
lblDeleteTrack.Text = "Delete Selected Track:";
lblDeleteTrack.Size = new Size(150, 15);
lblDeleteTrack.Location = new Point(20, 165); // Moved to the left
lblDeleteTrack.ForeColor = Color.White;
// Delete Selected Track Button
Button btnDeleteTrack = new Button();
btnDeleteTrack.Text = "Delete";
btnDeleteTrack.Size = new Size(90, 35);
btnDeleteTrack.Location = new Point(20, 190); // Moved to the left
btnDeleteTrack.BackColor = Color.FromArgb(60, 60, 60);
btnDeleteTrack.ForeColor = Color.White;
btnDeleteTrack.FlatStyle = FlatStyle.Flat;
btnDeleteTrack.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
// Add hover effect
btnDeleteTrack.MouseEnter += (sender, e) => btnDeleteTrack.BackColor = Color.FromArgb(100, 149, 237);
btnDeleteTrack.MouseLeave += (sender, e) => btnDeleteTrack.BackColor = Color.FromArgb(60, 60, 60);
btnDeleteTrack.Click += (sender, e) =>
{
DeleteSelectedTrack(vegas);
form.Close(); // Close the form
};
// Add controls to the form
form.Controls.Add(lblVideoTrack);
form.Controls.Add(btnAddVideoAbove);
form.Controls.Add(btnAddVideoBelow);
form.Controls.Add(lblAudioTrack);
form.Controls.Add(btnAddAudioAbove);
form.Controls.Add(btnAddAudioBelow);
form.Controls.Add(lblDeleteTrack);
form.Controls.Add(btnDeleteTrack);
// Set focus to the form itself, so no button is focused by default
form.Shown += (sender, e) => form.ActiveControl = null;
// Show the form
form.ShowDialog();
}
private void AddTrack(Vegas vegas, TrackType trackType, bool above)
{
Track selectedTrack = GetSelectedTrack(vegas);
if (selectedTrack != null)
{
int index = above ? selectedTrack.Index : selectedTrack.Index + 1;
if (trackType == TrackType.Video && !selectedTrack.IsAudio())
{
VideoTrack newTrack = new VideoTrack(index);
vegas.Project.Tracks.Add(newTrack);
}
else if (trackType == TrackType.Audio && selectedTrack.IsAudio())
{
AudioTrack newTrack = new AudioTrack(index);
vegas.Project.Tracks.Add(newTrack);
}
}
else
{
MessageBox.Show("Please select a track.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DeleteSelectedTrack(Vegas vegas)
{
Track selectedTrack = GetSelectedTrack(vegas);
if (selectedTrack != null)
{
vegas.Project.Tracks.Remove(selectedTrack);
}
else
{
MessageBox.Show("No track is selected. Please select a track to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private Track GetSelectedTrack(Vegas vegas)
{
foreach (Track myTrack in vegas.Project.Tracks)
{
foreach (TrackEvent evnt in myTrack.Events)
{
if (evnt.Selected)
{
return myTrack;
}
}
}
return null;
}
private enum TrackType
{
Video,
Audio
}
}
Duplicate Events to Up, Down, Right and Left directions | SCRIPT
This Script Duplicate selected Events to up, down, right and left direction. It was made with the guidance of @jetdv.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using ScriptPortal.Vegas;
namespace DuplicateEventLeftRightUp
{
public class Class1
{
public Vegas myVegas;
public void Main(Vegas vegas, string direction)
{
myVegas = vegas;
List<TrackEvent> selectedEvents = new List<TrackEvent>();
Dictionary<TrackEvent, Track> eventTrackMap = new Dictionary<TrackEvent, Track>();
// List to store the new duplicated events
List<TrackEvent> newEvents = new List<TrackEvent>();
// Find all selected events and their tracks
foreach (Track track in myVegas.Project.Tracks)
{
foreach (TrackEvent evnt in track.Events)
{
if (evnt.Selected)
{
selectedEvents.Add(evnt);
eventTrackMap[evnt] = track;
}
}
}
// Check if any events are selected
if (selectedEvents.Count > 0)
{
// Sort selected events by their start time to handle them in order
selectedEvents.Sort((a, b) => a.Start.CompareTo(b.Start));
// Find the maximum end time of all selected events manually
Timecode lastGlobalEventEnd = new Timecode(0);
foreach (TrackEvent evnt in selectedEvents)
{
if (evnt.End > lastGlobalEventEnd)
{
lastGlobalEventEnd = evnt.End;
}
}
Timecode beginning = null;
foreach (TrackEvent selectedEvent in selectedEvents)
{
Track myTrack = eventTrackMap[selectedEvent];
TrackEvent currentEvent = selectedEvent;
Timecode eventLength = selectedEvent.Length;
if (beginning == null)
{
beginning = selectedEvent.Start;
}
// Reset the position for the current event's duplicates
Timecode lastEventEnd = currentEvent.End > lastGlobalEventEnd ? currentEvent.End : lastGlobalEventEnd;
TrackEvent newEvent = null;
Timecode newEventStart = currentEvent.Start; // Initialize to avoid unassigned error
if (direction == "Left")
{
newEventStart = beginning - eventLength;
beginning = newEventStart;
}
else if (direction == "Right")
{
// Calculate the start time for the next duplicate to avoid overlap
newEventStart = lastEventEnd;
}
else if (direction == "Up" && myTrack.Index > 0)
{
Track targetTrack = myVegas.Project.Tracks[myTrack.Index - 1];
if (myTrack.IsAudio() && targetTrack.IsAudio())
{
AudioTrack aTrack = (AudioTrack)targetTrack;
newEvent = (AudioEvent)currentEvent.Copy(aTrack, currentEvent.Start);
}
else if (myTrack.IsVideo() && targetTrack.IsVideo())
{
VideoTrack vTrack = (VideoTrack)targetTrack;
newEvent = (VideoEvent)currentEvent.Copy(vTrack, currentEvent.Start);
}
}
else if (direction == "Down" && myTrack.Index < myVegas.Project.Tracks.Count - 1)
{
Track targetTrack = myVegas.Project.Tracks[myTrack.Index + 1];
if (myTrack.IsAudio() && targetTrack.IsAudio())
{
AudioTrack aTrack = (AudioTrack)targetTrack;
newEvent = (AudioEvent)currentEvent.Copy(aTrack, currentEvent.Start);
}
else if (myTrack.IsVideo() && targetTrack.IsVideo())
{
VideoTrack vTrack = (VideoTrack)targetTrack;
newEvent = (VideoEvent)currentEvent.Copy(vTrack, currentEvent.Start);
}
}
if (direction == "Left" || direction == "Right")
{
if (myTrack.IsAudio())
{
AudioTrack aTrack = (AudioTrack)myTrack;
newEvent = (AudioEvent)currentEvent.Copy(aTrack, newEventStart);
}
else if (myTrack.IsVideo())
{
VideoTrack vTrack = (VideoTrack)myTrack;
newEvent = (VideoEvent)currentEvent.Copy(vTrack, newEventStart);
}
// Update the end position of the last duplicate event and the global tracker
lastEventEnd = newEvent.End;
lastGlobalEventEnd = lastEventEnd;
}
if (newEvent != null)
{
newEvents.Add(newEvent);
}
}
}
else
{
MessageBox.Show("Please select events to duplicate.");
}
}
}
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Create the form
Form form = new Form();
form.Text = "Duplicate Events";
form.StartPosition = FormStartPosition.CenterScreen;
form.BackColor = Color.FromArgb(40, 40, 40);
form.ForeColor = Color.White;
form.FormBorderStyle = FormBorderStyle.Sizable;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.Size = new Size(195, 190);
form.Font = new Font("Segoe UI", 10, FontStyle.Regular);
// Create panel to hold the buttons
Panel buttonPanel = new Panel();
buttonPanel.Size = new Size(160, 200);
buttonPanel.Location = new Point(10, 10);
buttonPanel.BackColor = Color.FromArgb(40, 40, 40);
// Common button properties
Size buttonSize = new Size(40, 35);
Color buttonBackColor = Color.FromArgb(60, 60, 60);
Color hoverColor = Color.FromArgb(100, 149, 237);
// Up arrow
Button duplicateUpButton = new Button();
duplicateUpButton.Text = "↑"; // Up arrow symbol
duplicateUpButton.Font = new Font("Segoe UI", 20, FontStyle.Bold);
duplicateUpButton.Size = buttonSize;
duplicateUpButton.Location = new Point(60, 10);
duplicateUpButton.BackColor = buttonBackColor;
duplicateUpButton.ForeColor = Color.White;
duplicateUpButton.FlatStyle = FlatStyle.Flat;
duplicateUpButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
duplicateUpButton.MouseEnter += (sender, e) => duplicateUpButton.BackColor = hoverColor;
duplicateUpButton.MouseLeave += (sender, e) => duplicateUpButton.BackColor = buttonBackColor;
// Down arrow
Button duplicateDownButton = new Button();
duplicateDownButton.Text = "↓"; // Down arrow symbol
duplicateDownButton.Font = new Font("Segoe UI", 20, FontStyle.Bold);
duplicateDownButton.Size = buttonSize;
duplicateDownButton.Location = new Point(60, 90);
duplicateDownButton.BackColor = buttonBackColor;
duplicateDownButton.ForeColor = Color.White;
duplicateDownButton.FlatStyle = FlatStyle.Flat;
duplicateDownButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
duplicateDownButton.MouseEnter += (sender, e) => duplicateDownButton.BackColor = hoverColor;
duplicateDownButton.MouseLeave += (sender, e) => duplicateDownButton.BackColor = buttonBackColor;
// Left arrow
Button duplicateLeftButton = new Button();
duplicateLeftButton.Text = "←"; // Left arrow symbol
duplicateLeftButton.Font = new Font("Segoe UI", 20, FontStyle.Bold);
duplicateLeftButton.Size = buttonSize;
duplicateLeftButton.Location = new Point(10, 50);
duplicateLeftButton.BackColor = buttonBackColor;
duplicateLeftButton.ForeColor = Color.White;
duplicateLeftButton.FlatStyle = FlatStyle.Flat;
duplicateLeftButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
duplicateLeftButton.MouseEnter += (sender, e) => duplicateLeftButton.BackColor = hoverColor;
duplicateLeftButton.MouseLeave += (sender, e) => duplicateLeftButton.BackColor = buttonBackColor;
// Right arrow
Button duplicateRightButton = new Button();
duplicateRightButton.Text = "→"; // Right arrow symbol
duplicateRightButton.Font = new Font("Segoe UI", 20, FontStyle.Bold);
duplicateRightButton.Size = buttonSize;
duplicateRightButton.Location = new Point(110, 50);
duplicateRightButton.BackColor = buttonBackColor;
duplicateRightButton.ForeColor = Color.White;
duplicateRightButton.FlatStyle = FlatStyle.Flat;
duplicateRightButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100);
duplicateRightButton.MouseEnter += (sender, e) => duplicateRightButton.BackColor = hoverColor;
duplicateRightButton.MouseLeave += (sender, e) => duplicateRightButton.BackColor = buttonBackColor;
// Add controls to the panel
buttonPanel.Controls.Add(duplicateUpButton);
buttonPanel.Controls.Add(duplicateDownButton);
buttonPanel.Controls.Add(duplicateLeftButton);
buttonPanel.Controls.Add(duplicateRightButton);
// Add controls to the form
form.Controls.Add(buttonPanel);
// Event handlers for button clicks
duplicateUpButton.Click += (sender, e) =>
{
form.Close();
new Class1().Main(vegas, "Up");
};
duplicateDownButton.Click += (sender, e) =>
{
form.Close();
new Class1().Main(vegas, "Down");
};
duplicateLeftButton.Click += (sender, e) =>
{
form.Close();
new Class1().Main(vegas, "Left");
};
duplicateRightButton.Click += (sender, e) =>
{
form.Close();
new Class1().Main(vegas, "Right");
};
// Set focus to the form itself, so no button is focused by default
form.Shown += (sender, e) => form.ActiveControl = null;
// Show the form
form.ShowDialog();
}
}
}
Randomize Events Advanced | SCRIPT
Select only Videos or only Audios or Both, Grouped or Not. Now it is possible to Randomize in a lot of Scenarios!
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Collect all selected event groups, ensuring that video and audio remain together
List<List<TrackEvent>> eventGroups = new List<List<TrackEvent>>();
List<Timecode> originalStartPositions = new List<Timecode>();
foreach (Track track in vegas.Project.Tracks)
{
foreach (TrackEvent evnt in track.Events)
{
if (evnt.Selected)
{
// Check if the event is part of a group (for video/audio pairs)
if (evnt.IsGrouped)
{
// Find the group the event belongs to
bool alreadyGrouped = false;
foreach (List<TrackEvent> group in eventGroups)
{
if (group.Contains(evnt))
{
alreadyGrouped = true;
break;
}
}
if (!alreadyGrouped)
{
// Collect the entire group to maintain the video/audio relationship
List<TrackEvent> group = new List<TrackEvent>();
foreach (TrackEvent groupedEvent in evnt.Group)
{
group.Add(groupedEvent);
}
eventGroups.Add(group);
originalStartPositions.Add(group[0].Start);
}
}
else
{
// Treat individual events as their own group
eventGroups.Add(new List<TrackEvent> { evnt });
originalStartPositions.Add(evnt.Start);
}
}
}
}
// Check if there are selected groups to randomize
if (eventGroups.Count == 0)
{
MessageBox.Show("No selected events found to randomize.");
return;
}
// Fisher-Yates shuffle algorithm to randomize groups
Random rnd = new Random();
for (int i = eventGroups.Count - 1; i > 0; i--)
{
int j = rnd.Next(i + 1);
var tempGroup = eventGroups[i];
eventGroups[i] = eventGroups[j];
eventGroups[j] = tempGroup;
}
// Apply the shuffled groups to the timeline without overlap
Timecode currentTime = originalStartPositions[0];
for (int i = 0; i < eventGroups.Count; i++)
{
foreach (TrackEvent evnt in eventGroups[i])
{
evnt.Start = currentTime;
}
// Update the time for the next group to start right after the current group ends
currentTime += eventGroups[i][0].Length;
}
// Output for verification
Console.WriteLine("Shuffled event groups (with video/audio kept together and no overlap):");
foreach (var group in eventGroups)
{
foreach (var evnt in group)
{
Console.WriteLine("Event: " + evnt.Name + ", Position: " + evnt.Start);
}
}
}
}
@James-McLaughlin You will find a new link here as mentioned in a post in this thread by @iEmby around 14 August 2024
https://drive.google.com/drive/folders/16X76Lj2n7sutKolw7Y-aQuqliQimqGNB
Hi! 👋 I process sound and music in DAW Cockos Reaper, and I'm used to the "Open project folder" script - it's very simple and convenient, and I really missed it in Vegas Pro in the form of a button on the toolbar! 📂
But fortunately, Vegas has this wonderful scripting!) 🤩
I asked chatGPT for such a script 💬.
He said that Vegas API does not directly support such a function, nor that he can use knowledge of C# or VB.NET to solve this issue, which, unfortunately, I do not know (that's why I'm contacting Chat).
Here's what he got:
using System;
using System.IO;
using System.Diagnostics;
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Check if the project has been saved
if (string.IsNullOrEmpty(vegas.Project.FilePath))
{
vegas.ShowError("Project is not saved. Please save the project to open its folder.");
return;
}
// Get the folder path of the project
string projectFolder = Path.GetDirectoryName(vegas.Project.FilePath);
// Open the folder in File Explorer
Process.Start(new ProcessStartInfo
{
FileName = projectFolder,
UseShellExecute = true,
Verb = "open"
});
}
}
This is the same thing that the script did in Reaper and it is very convenient!)
Also here is the icon that I simply took from https://emoji.aranja.com/ for the request “folder”.
You can replace it with any other you like!)
I hope this will serve someone else as well as it did me!) ✔️
IMPROVED & UPDATED !! BATCH RENDER Script Is Here! Download It. Test It. Share It
What I Able to Improve in This Script:
- Modern Icon & Improved Interface
- For VEGAS Pro 15 And Next Versions.
- Will Render Project, Selection, Regions (Default Feature)
- Will Render Regions by Using Regine Label as File Names.
- If No Region Label Is Existing. It Will Render by Naming Regions As 'Region-1' 'Region-2' ------- Onwards.
- Will Ask You for Crosscheck Rendering Information like Template, Rendering Mode, Duration and Selection Range and Output File Name.
- Will Not Work on Unsaved Fresh Project. It will Ask to Save Project First with Save Button. After saving project, script will run automatically.
- If You Was Not Willing to Save Project, You Can Press NO. It Will Save Project in a Temporary Projects Folder at Desktop.
- Will Keep All Renders in a Folder Named 'Renders' At the Same Location Where Project Is Saved. (This Folder Will Be Automatically Created)
- Will Render Output File in Project and Selection Mode with Same Name as Project Name Is.
- Will Save a Backup File of The Project Before Start Rendering, in a Folder Named 'Backups' which will be automatically created if not exists.
- If file is already existed, then it will give you options 'Overwrite' and 'Keep Both'. if 'Keep Both' selected then it will give it a name i.e. Existing File Name + count number starting from 1 in an incremented counter manner.
So, Download It. Share Your Thoughts on This. Enjoy.
https://drive.google.com/drive/folders/1ft0rZpcBhGatTw5sc2t18z0ACQAXWsu_?usp=sharing
Note: As at mid August 2024 above link no longer working. New link below
https://drive.google.com/drive/folders/16X76Lj2n7sutKolw7Y-aQuqliQimqGNB
Note: Paste Both Files Into 'Script Menu' In Your VEGAS Pro's Program Directory.
I am new to Vegas scripting, but I am a programmer. I learn best by reviewing existing code. Are these scripts Open Source? If so, do you have them in a reop that we can access? Thanks.
@Stan-Green3926 Welcome to World of VEGAS Scripting...
Ok This is the above script code...
Enjoy Brother...
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using ScriptPortal.Vegas;
public class EntryPoint
{
// set this to true if you want to allow files to be overwritten
bool OverwriteExistingFiles = false;
String defaultBasePath = "Untitled_";
const int QUICKTIME_MAX_FILE_NAME_LENGTH = 55;
ScriptPortal.Vegas.Vegas myVegas = null;
enum RenderMode
{
Project = 0,
Selection,
Regions,
}
ArrayList SelectedTemplates = new ArrayList();
List<RenderArgs> renders = new List<RenderArgs>(); // Store RenderArgs for rendering
//****************************************************************************************************************
public void FromVegas(Vegas vegas)
{
vegas.UpdateUI();
myVegas = vegas;
// Check if the project is untitled and unsaved
if (myVegas.Project == null || string.IsNullOrEmpty(myVegas.Project.FilePath))
{
// Display a message box indicating that the project is unsaved
DialogResult dialogResult = MessageBox.Show(
"PLEASE SAVE YOUR PROJECT FIRST !!\n\nDo you want to save it now?",
"ATTENTION",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning
);
if (dialogResult == DialogResult.Yes)
{
// Open the "Save As" Project window
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Vegas Project Files (*.veg)|*.veg";
saveFileDialog.Title = "Save As Project";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
// Save the project with the selected file name
myVegas.SaveProject(saveFileDialog.FileName);
}
else
{
return; // Exit the script if "Save As" is canceled
}
}
// ... Your existing code ...
else
{
// User clicked "No"
// Create a "Temporary Projects" folder on the desktop if it doesn't exist
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string tempProjectsFolderPath = Path.Combine(desktopPath, "Temporary Projects");
if (!Directory.Exists(tempProjectsFolderPath))
{
Directory.CreateDirectory(tempProjectsFolderPath);
}
// Generate a unique file name with a counter
string baseFileName = "TemporaryProject";
int counter = 1;
string filePath;
do
{
filePath = Path.Combine(tempProjectsFolderPath, string.Format("{0}{1}.veg", baseFileName, counter++));
} while (File.Exists(filePath));
// Save the project with the generated file name
myVegas.SaveProject(filePath);
}
}
//****************************************************************************************************************
// Save the project as a backup before rendering
bool saveSuccess = SaveProjectAsBackup();
if (!saveSuccess)
{
MessageBox.Show(
"Failed to save project backup. Please check if you have write permissions.",
"ERROR",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
return; // Exit the script if backup save fails
}
//****************************************************************************************************************
// Construct the full path for the output file
string projectPath = myVegas.Project.FilePath;
string outputDirectory;
if (String.IsNullOrEmpty(projectPath))
{
// If project is not saved, use My Documents folder as before
string dir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
outputDirectory = Path.Combine(dir, "Renders");
}
else
{
// Get the directory where the project is saved
string dir = Path.GetDirectoryName(projectPath);
// Create the 'Renders' folder if it doesn't exist
outputDirectory = Path.Combine(dir, "Renders");
if (!Directory.Exists(outputDirectory))
{
Directory.CreateDirectory(outputDirectory);
}
// Set the default base file name to the project name
defaultBasePath = Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(projectPath));
}
DialogResult result = ShowBatchRenderDialog();
myVegas.UpdateUI();
if (DialogResult.OK == result)
{
// Inform the user of some special failure cases
String outputFilePath = FileNameBox.Text;
RenderMode renderMode = RenderMode.Project;
if (RenderRegionsButton.Checked)
{
renderMode = RenderMode.Regions;
}
else if (RenderSelectionButton.Checked)
{
renderMode = RenderMode.Selection;
}
// Collect selected templates
UpdateSelectedTemplates();
// Display a prompt box with information
StringBuilder promptMessage = new StringBuilder("");
//****************************************************************************************************************
switch (renderMode)
{
case RenderMode.Project:
promptMessage.AppendLine(">>>>>>>> RENDERING PROJECT <<<<<<<<\n`````````````````````````````````````````````````````````````````````````````````````````");
promptMessage.AppendLine("\nLength:\n" + myVegas.Project.Length.ToString() + "\n----------------\n\nName:\n" + Path.GetFileNameWithoutExtension(outputFilePath));
promptMessage.AppendLine("----------------\n\nLocation\n" + Path.GetFullPath(outputFilePath));
break;
case RenderMode.Selection:
promptMessage.AppendLine(">>>>>>>> RENDERING SELECTION <<<<<<<<\n`````````````````````````````````````````````````````````````````````````````````````````");
promptMessage.AppendLine("\nLength:\n" + myVegas.SelectionLength.ToString() + "\n----------------\n\nName:\n" + Path.GetFileNameWithoutExtension(outputFilePath));
promptMessage.AppendLine("----------------\n\nLocation\n" + Path.GetFullPath(outputFilePath));
// Path.GetFileNameWithoutExtension(projectFilePath)
// promptMessage.AppendLine("\n" + "From" + myVegas.SelectionStart.ToString() + " To " + (myVegas.SelectionStart + myVegas.SelectionLength).ToString());
break; // Make sure to break out of the switch case
case RenderMode.Regions:
promptMessage.AppendLine(">>>>>>>> RENDERING REGIONS <<<<<<<<\n`````````````````````````````````````````````````````````````````````````````````````````");
int regionIndex = 1;
foreach (ScriptPortal.Vegas.Region region in myVegas.Project.Regions)
{
if (string.IsNullOrEmpty(region.Label))
{
// Assign a default label
region.Label ="Region-" + regionIndex;
regionIndex++;
}
promptMessage.AppendLine("(" + region.Length.ToString()+ ")" + " " + region.Label);
}
break;
default:
break;
}
promptMessage.AppendLine("\n\n>>>>>>>>> SELECTED TEMPLATE <<<<<<<<<\n`````````````````````````````````````````````````````````````````````````````````````````");
foreach (RenderItem selectedItem in SelectedTemplates)
{
promptMessage.AppendLine(selectedItem.Template.Name);
}
// Display the prompt box
DialogResult infoResult = MessageBox.Show(
promptMessage.ToString(),
"ATTENTION !! CHECK BEFORE PROCEED !!",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
if (infoResult == DialogResult.OK)
{
// Start rendering
DoBatchRender(SelectedTemplates, outputFilePath, renderMode);
}
}
}
// Helper method to get the associated region for a RenderArgs
//****************************************************************************************************************
private bool SaveProjectAsBackup()
{
try
{
string projectFilePath = myVegas.Project.FilePath;
// Check if the project file path exists
if (File.Exists(projectFilePath))
{
string projectDirectoryName = Path.GetDirectoryName(projectFilePath);
string projectFileName = Path.GetFileNameWithoutExtension(projectFilePath);
// Create the backup folder if it doesn't exist
string backupFolderPath = Path.Combine(projectDirectoryName, "Backups");
Directory.CreateDirectory(backupFolderPath);
// Initialize a counter starting from 1
int counter = 1;
// Construct the backup file name with the project name, counter, and timestamp
string backupFileName = projectFileName + "_" + "Render" + "_" + "BAK" + "_" + counter + ".veg";
// Keep incrementing the counter until a unique filename is found
while (File.Exists(Path.Combine(backupFolderPath, backupFileName)))
{
counter++;
backupFileName = projectFileName + "_" + "Render" + "_" + counter + ".veg";
}
// Combine the backup folder path and the final backup file name
string backupFilePath = Path.Combine(backupFolderPath, backupFileName);
// Copy the project file to the backup location
File.Copy(projectFilePath, backupFilePath, OverwriteExistingFiles);
return true; // Backup save successful
}
}
catch (Exception ex)
{
// Handle any exceptions that may occur during backup save
MessageBox.Show(
"Failed to save project backup. Error: " + ex.Message,
"ERROR",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
return false; // Backup save failed
}
//****************************************************************************************************************
private ScriptPortal.Vegas.Region GetRegionForRenderArgs(RenderArgs args)
{
foreach (ScriptPortal.Vegas.Region region in myVegas.Project.Regions)
{
// Check if the region's position matches the RenderArgs start position
if (region.Position == args.Start)
{
return region;
}
}
return null; // Return null if no matching region is found
}
//****************************************************************************************************************
void DoBatchRender(ArrayList selectedTemplates, String basePath, RenderMode renderMode)
{
String outputDirectory = Path.GetDirectoryName(basePath);
String baseFileName = Path.GetFileName(basePath);
// make sure templates are selected
if ((null == selectedTemplates) || (0 == selectedTemplates.Count))
throw new ApplicationException("No render templates selected.");
// make sure the output directory exists
if (!Directory.Exists(outputDirectory))
throw new ApplicationException("The output directory does not exist.");
renders.Clear(); // Clear the list before adding RenderArgs
// Declare regionFilename outside of the if condition
string regionFilename = "";
// enumerate through each selected render template
foreach (RenderItem renderItem in selectedTemplates)
{
// construct the file name (most of it)
String filename = Path.Combine(outputDirectory,
FixFileName(baseFileName));
//check to see if this is a QuickTime file...if so, file length cannot exceed 59 characters
if (renderItem.Renderer.ClassID == Renderer.CLSID_CSfQT7RenderFileClass)
{
int size = baseFileName.Length + renderItem.Renderer.FileTypeName.Length + 1 + renderItem.Template.Name.Length;
if (size > QUICKTIME_MAX_FILE_NAME_LENGTH)
{
int dif = size - (QUICKTIME_MAX_FILE_NAME_LENGTH - 2); //extra buffer for a "--" to indicated name is truncated.
string tempstr1 = renderItem.Renderer.FileTypeName;
string tempstr2 = renderItem.Template.Name;
if (tempstr1.Length < (dif + 3))
{
dif -= (tempstr1.Length - 3);
tempstr1 = tempstr1.Substring(0, 3);
tempstr2 = tempstr2.Substring(dif);
}
else
{
tempstr1 = tempstr1.Substring(0, tempstr1.Length - dif);
}
filename = Path.Combine(outputDirectory,
FixFileName(baseFileName) +
FixFileName(tempstr1) +
"--" +
FixFileName(tempstr2));
}
}
// Moved regionFilename assignment here
regionFilename = filename;
// ... rest of the code ...
if (RenderMode.Regions == renderMode)
{
foreach (ScriptPortal.Vegas.Region region in myVegas.Project.Regions)
{
// Use region label as the base file name for rendering
string regionLabel = region.Label;
string regionOutputFilename = Path.Combine(outputDirectory, FixFileName(regionLabel));
// Append the original file extension from renderItem to the output filename
regionOutputFilename += renderItem.Extension;
// Create a RenderArgs and add it to the list
RenderArgs args = new RenderArgs();
args.OutputFile = regionOutputFilename; // Use region label with the original file extension
args.RenderTemplate = renderItem.Template;
args.Start = region.Position;
args.Length = region.Length;
renders.Add(args);
}
}
else
{
filename += renderItem.Extension;
RenderArgs args = new RenderArgs();
args.OutputFile = filename;
args.RenderTemplate = renderItem.Template;
args.UseSelection = (renderMode == RenderMode.Selection);
renders.Add(args);
}
}
// validate all files and propmt for overwrites
foreach (RenderArgs args in renders)
{
ValidateFilePath(args.OutputFile);
if (!OverwriteExistingFiles)
{
while (File.Exists(args.OutputFile))
{
string existingFileName = Path.GetFileName(args.OutputFile);
string msg = "File '" + existingFileName + "' already exists. Would You Like To Overwrite?\n\nYes >>>> Overwrite.\nNo >>>> Keep Both.";
DialogResult rs = MessageBox.Show(
msg,
"File Exists",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button3
);
if (rs == DialogResult.Cancel)
{
return; // Exit the script
}
else if (rs == DialogResult.Yes)
{
// User chose to overwrite, set the flag and break out of the loop
OverwriteExistingFiles = true;
break;
}
else
{
// User chose to keep both, so modify the output file path with a counter
string directory = Path.GetDirectoryName(args.OutputFile);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(args.OutputFile);
string fileExtension = Path.GetExtension(args.OutputFile);
int counter = 1;
// Keep incrementing the counter until a non-existing filename is found
while (File.Exists(args.OutputFile))
{
string newFileName = fileNameWithoutExtension + "_" + counter + fileExtension;
args.OutputFile = Path.Combine(directory, newFileName);
counter++;
}
}
}
// Continue with rendering or other operations
}
}
//****************************************************************************************************************
// perform all renders. The Render method returns a member of the RenderStatus enumeration. If it is
// anything other than OK, exit the loop.
RenderStatus overallRenderStatus = RenderStatus.Unknown; // Initialize overall status
foreach (RenderArgs args in renders) {
RenderStatus individualRenderStatus = DoRender(args);
if (individualRenderStatus != RenderStatus.Canceled && individualRenderStatus != RenderStatus.Failed) {
// Update overall status only if it's not canceled or failed
overallRenderStatus = RenderStatus.Complete;
} else {
overallRenderStatus = individualRenderStatus; // Update overall status to the specific status (canceled or failed)
break;
}
}
// Prompt options after rendering completion based on overall status
string completionMessage;
string caption = "Upps..!!";
MessageBoxButtons options;
if (overallRenderStatus == RenderStatus.Complete) {
completionMessage = "Rendering Completed Successfully !!\n\nOPEN FOLDER ??";
options = MessageBoxButtons.OKCancel;
} else {
completionMessage = "RENDERING STOPPED !!";
options = MessageBoxButtons.OK;
}
DialogResult result = MessageBox.Show(completionMessage, caption, options, MessageBoxIcon.Question);
if (result == DialogResult.OK && overallRenderStatus == RenderStatus.Complete) {
// Open Folder
Process.Start("explorer.exe", "/select," + renders[0].OutputFile);
}
// If Cancel is chosen or rendering is canceled/failed, the message box will simply close without further action.
}
//****************************************************************************************************************
RenderStatus DoRender(RenderArgs args)
{
RenderStatus status = myVegas.Render(args);
switch (status)
{
case RenderStatus.Complete:
case RenderStatus.Canceled:
break;
case RenderStatus.Failed:
default:
StringBuilder msg = new StringBuilder("Render failed:\n");
msg.Append("\n file name: ");
msg.Append(args.OutputFile);
msg.Append("\n Template: ");
msg.Append(args.RenderTemplate.Name);
throw new ApplicationException(msg.ToString());
}
return status;
}
String FixFileName(String name)
{
const Char replacementChar = '-';
foreach (char badChar in Path.GetInvalidFileNameChars()) {
name = name.Replace(badChar, replacementChar);
}
return name;
}
void ValidateFilePath(String filePath)
{
if (filePath.Length > 260)
throw new ApplicationException("File name too long: " + filePath);
foreach (char badChar in Path.GetInvalidPathChars()) {
if (0 <= filePath.IndexOf(badChar)) {
throw new ApplicationException("Invalid file name: " + filePath);
}
}
}
class RenderItem
{
public readonly Renderer Renderer = null;
public readonly RenderTemplate Template = null;
public readonly String Extension = null;
public RenderItem(Renderer r, RenderTemplate t, String e)
{
this.Renderer = r;
this.Template = t;
// need to strip off the extension's leading "*"
if (null != e) this.Extension = e.TrimStart('*');
}
}
//****************************************************************************************************************
Button BrowseButton;
TextBox FileNameBox;
TreeView TemplateTree;
RadioButton RenderProjectButton;
RadioButton RenderRegionsButton;
RadioButton RenderSelectionButton;
DialogResult ShowBatchRenderDialog()
{
const float HiDPI_RES_LIMIT = 1.37f; // based on the original HiDPI changes for DVP-667
float dpiScale = 1.0f;
Form dlog = new Form();
// Determine if DPI scale adjustments need to be made (ref. DVP-667)
Graphics g = ((Control)dlog).CreateGraphics();
if (g != null)
{
dpiScale = (float)g.DpiY / 96.0f;
g.Dispose();
if (dpiScale < HiDPI_RES_LIMIT) // only apply if DPI scale > 150%
dpiScale = 1.0f;
}
dlog.Text = "Batch Render (Modified By iEMBY)";
dlog.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
dlog.MaximizeBox = false;
dlog.StartPosition = FormStartPosition.CenterScreen;
dlog.Width = (int)(600 * dpiScale);
dlog.FormClosing += this.HandleFormClosing;
// Set the form background color and font color
dlog.BackColor = Color.FromArgb(60, 60, 60);
dlog.ForeColor = Color.White;
int titleBarHeight = dlog.Height - dlog.ClientSize.Height;
int buttonWidth = (int)(80 * dpiScale);
int fileNameWidth = (int)(410 * dpiScale);
FileNameBox = AddTextControl(dlog, "Name / Location", titleBarHeight + 8, fileNameWidth, 10, defaultBasePath);
// Set the background color and font color of FileNameBox
FileNameBox.BackColor = Color.White;
FileNameBox.ForeColor = Color.Black;
//****************************************************************************************************************
BrowseButton = new Button();
BrowseButton.Left = FileNameBox.Right + 4;
BrowseButton.Top = FileNameBox.Top - 2;
BrowseButton.Width = buttonWidth;
BrowseButton.Height = BrowseButton.Font.Height + 12;
BrowseButton.Text = "Browse...";
BrowseButton.BackColor = Color.Black; // Set background color to black
BrowseButton.ForeColor = Color.White; // Set font color to white
BrowseButton.Font = new Font(BrowseButton.Font.FontFamily, BrowseButton.Font.Size, FontStyle.Bold); // Set font style to bold
BrowseButton.Click += new EventHandler(this.HandleBrowseClick);
dlog.Controls.Add(BrowseButton);
//****************************************************************************************************************
TemplateTree = new TreeView();
TemplateTree.Left = 15;
TemplateTree.Width = dlog.Width - 45;
TemplateTree.Top = BrowseButton.Bottom + 10;
TemplateTree.Height = (int)(250 * dpiScale);
TemplateTree.CheckBoxes = true;
TemplateTree.AfterCheck += new TreeViewEventHandler(this.HandleTreeViewCheck);
dlog.Controls.Add(TemplateTree);
int buttonTop = TemplateTree.Bottom + 10;
int buttonsLeft = dlog.Width - (2*(buttonWidth+10));
RenderProjectButton = AddRadioControl(dlog,
"TO PROJECT",
30,
buttonTop,
true);
RenderSelectionButton = AddRadioControl(dlog,
"TO SELECTION",
RenderProjectButton.Right,
buttonTop,
(0 != myVegas.SelectionLength.Nanos));
RenderRegionsButton = AddRadioControl(dlog,
"TO REGIONS",
RenderSelectionButton.Right,
buttonTop,
(0 != myVegas.Project.Regions.Count));
RenderSelectionButton.Checked = true;
int buttonRightGap = (int)(dpiScale*5);
Button okButton = new Button();
okButton.Text = "Render";
okButton.Font = new Font(okButton.Font.FontFamily, okButton.Font.Size + 3, FontStyle.Bold);
okButton.Left = dlog.Width - (2 * (buttonWidth + 21)) - buttonRightGap;
okButton.Top = buttonTop - 3;
okButton.Width = buttonWidth;
okButton.Height = (okButton.Font.Height + 50) / 2;
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
okButton.BackColor = Color.White; // Set the background color to white
okButton.ForeColor = Color.Black; // Set the font color to black
dlog.AcceptButton = okButton;
dlog.Controls.Add(okButton);
Button cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Font = new Font(cancelButton.Font.FontFamily, cancelButton.Font.Size + 3, FontStyle.Bold);
cancelButton.Left = dlog.Width - (1 * (buttonWidth + 35)) - buttonRightGap;
cancelButton.Top = buttonTop - 3;
cancelButton.Width = buttonWidth;
cancelButton.Height = (cancelButton.Font.Height + 50) / 2;
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
cancelButton.BackColor = Color.White; // Set the background color to white
cancelButton.ForeColor = Color.Black; // Set the font color to black
dlog.CancelButton = cancelButton;
dlog.Controls.Add(cancelButton);
//****************************************************************************************************************
dlog.Height = titleBarHeight + okButton.Bottom + 8;
dlog.ShowInTaskbar = false;
FillTemplateTree();
return dlog.ShowDialog(myVegas.MainWindow);
}
//****************************************************************************************************************
TextBox AddTextControl(Form dlog, String labelName, int left, int width, int top, String defaultValue)
{
Label label = new Label();
label.AutoSize = true;
label.Text = labelName + ":";
label.Left = left;
label.Top = top + 4;
dlog.Controls.Add(label);
TextBox textbox = new TextBox();
textbox.Multiline = false;
textbox.Left = label.Right;
textbox.Top = top;
textbox.Width = width - (label.Width);
textbox.Text = defaultValue;
dlog.Controls.Add(textbox);
return textbox;
}
RadioButton AddRadioControl(Form dlog, String labelName, int left, int top, bool enabled)
{
Label label = new Label();
label.AutoSize = true;
label.Text = labelName;
label.Left = left;
label.Top = top + 4;
label.Enabled = enabled;
dlog.Controls.Add(label);
RadioButton radiobutton = new RadioButton();
radiobutton.Left = label.Right;
radiobutton.Width = 36;
radiobutton.Top = top;
radiobutton.Enabled = enabled;
dlog.Controls.Add(radiobutton);
return radiobutton;
}
static Guid[] TheDefaultTemplateRenderClasses =
{
Renderer.CLSID_SfWaveRenderClass,
Renderer.CLSID_SfW64ReaderClass,
Renderer.CLSID_CSfAIFRenderFileClass,
Renderer.CLSID_CSfFLACRenderFileClass,
Renderer.CLSID_CSfPCARenderFileClass,
};
bool AllowDefaultTemplates(Guid rendererID)
{
foreach (Guid guid in TheDefaultTemplateRenderClasses)
{
if (guid == rendererID)
return true;
}
return false;
}
void FillTemplateTree()
{
int projectAudioChannelCount = 0;
if (AudioBusMode.Stereo == myVegas.Project.Audio.MasterBusMode) {
projectAudioChannelCount = 2;
} else if (AudioBusMode.Surround == myVegas.Project.Audio.MasterBusMode) {
projectAudioChannelCount = 6;
}
bool projectHasVideo = ProjectHasVideo();
bool projectHasAudio = ProjectHasAudio();
int projectVideoStreams = !projectHasVideo ? 0 :
(Stereo3DOutputMode.Off != myVegas.Project.Video.Stereo3DMode ? 2 : 1);
foreach (Renderer renderer in myVegas.Renderers) {
try {
String rendererName = renderer.FileTypeName;
TreeNode rendererNode = new TreeNode(rendererName);
rendererNode.Tag = new RenderItem(renderer, null, null);
foreach (RenderTemplate template in renderer.Templates) {
try {
// filter out invalid templates
if (!template.IsValid()) {
continue;
}
// filter out video templates when project has
// no video.
if (!projectHasVideo && (0 < template.VideoStreamCount)) {
continue;
}
// filter out templates that are 3d when the project is just 2d
if (projectHasVideo && projectVideoStreams < template.VideoStreamCount) {
continue;
}
// filter the default template (template 0) and we don't allow defaults
// for this renderer
if (template.TemplateID == 0 && !AllowDefaultTemplates(renderer.ClassID)) {
continue;
}
// filter out audio-only templates when project has no audio
if (!projectHasAudio && (0 == template.VideoStreamCount) && (0 < template.AudioStreamCount)) {
continue;
}
// filter out templates that have more channels than the project
if (projectAudioChannelCount < template.AudioChannelCount) {
continue;
}
// filter out templates that don't have
// exactly one file extension
String[] extensions = template.FileExtensions;
if (1 != extensions.Length) {
continue;
}
String templateName = template.Name;
TreeNode templateNode = new TreeNode(templateName);
templateNode.Tag = new RenderItem(renderer, template, extensions[0]);
rendererNode.Nodes.Add(templateNode);
} catch (Exception e) {
// skip it
MessageBox.Show(e.ToString());
}
}
if (0 == rendererNode.Nodes.Count) {
continue;
} else if (1 == rendererNode.Nodes.Count) {
// skip it if the only template is the project
// settings template.
if (0 == ((RenderItem) rendererNode.Nodes[0].Tag).Template.Index) {
continue;
}
} else {
TemplateTree.Nodes.Add(rendererNode);
}
} catch {
// skip it
}
}
}
bool ProjectHasVideo() {
foreach (Track track in myVegas.Project.Tracks) {
if (track.IsVideo()) {
return true;
}
}
return false;
}
bool ProjectHasAudio() {
foreach (Track track in myVegas.Project.Tracks) {
if (track.IsAudio()) {
return true;
}
}
return false;
}
void UpdateSelectedTemplates()
{
SelectedTemplates.Clear();
foreach (TreeNode node in TemplateTree.Nodes) {
foreach (TreeNode templateNode in node.Nodes) {
if (templateNode.Checked) {
SelectedTemplates.Add(templateNode.Tag);
}
}
}
}
void HandleBrowseClick(Object sender, EventArgs args)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "All Files (*.*)|*.*";
saveFileDialog.CheckPathExists = true;
saveFileDialog.AddExtension = false;
if (null != FileNameBox) {
String filename = FileNameBox.Text;
String initialDir = Path.GetDirectoryName(filename);
if (Directory.Exists(initialDir)) {
saveFileDialog.InitialDirectory = initialDir;
}
saveFileDialog.DefaultExt = Path.GetExtension(filename);
saveFileDialog.FileName = Path.GetFileNameWithoutExtension(filename);
}
if (System.Windows.Forms.DialogResult.OK == saveFileDialog.ShowDialog()) {
if (null != FileNameBox) {
FileNameBox.Text = Path.GetFullPath(saveFileDialog.FileName);
}
}
}
void HandleTreeViewCheck(object sender, TreeViewEventArgs args)
{
if (args.Node.Checked) {
if (0 != args.Node.Nodes.Count) {
if ((args.Action == TreeViewAction.ByKeyboard) || (args.Action == TreeViewAction.ByMouse)) {
SetChildrenChecked(args.Node, true);
}
} else if (!args.Node.Parent.Checked) {
args.Node.Parent.Checked = true;
}
} else {
if (0 != args.Node.Nodes.Count) {
if ((args.Action == TreeViewAction.ByKeyboard) || (args.Action == TreeViewAction.ByMouse)) {
SetChildrenChecked(args.Node, false);
}
} else if (args.Node.Parent.Checked) {
if (!AnyChildrenChecked(args.Node.Parent)) {
args.Node.Parent.Checked = false;
}
}
}
}
void HandleFormClosing(Object sender, FormClosingEventArgs args)
{
Form dlg = sender as Form;
if (null == dlg) return;
if (DialogResult.OK != dlg.DialogResult) return;
String outputFilePath = FileNameBox.Text;
try {
String outputDirectory = Path.GetDirectoryName(outputFilePath);
if (!Directory.Exists(outputDirectory)) throw new ApplicationException();
} catch {
String title = "Invalid Directory";
StringBuilder msg = new StringBuilder();
msg.Append("The output directory does not exist.\n");
msg.Append("Please specify the directory and base file name using the Browse button.");
MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
args.Cancel = true;
return;
}
try {
String baseFileName = Path.GetFileName(outputFilePath);
if (String.IsNullOrEmpty(baseFileName)) throw new ApplicationException();
if (-1 != baseFileName.IndexOfAny(Path.GetInvalidFileNameChars())) throw new ApplicationException();
} catch {
String title = "Invalid Base File Name";
StringBuilder msg = new StringBuilder();
msg.Append("The base file name is not a valid file name.\n");
msg.Append("Make sure it contains one or more valid file name characters.");
MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
args.Cancel = true;
return;
}
UpdateSelectedTemplates();
if (0 == SelectedTemplates.Count)
{
String title = "No Templates Selected";
StringBuilder msg = new StringBuilder();
msg.Append("No render templates selected.\n");
msg.Append("Select one or more render templates from the available formats.");
MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
args.Cancel = true;
return;
}
}
void SetChildrenChecked(TreeNode node, bool checkIt)
{
foreach (TreeNode childNode in node.Nodes) {
if (childNode.Checked != checkIt)
childNode.Checked = checkIt;
}
}
bool AnyChildrenChecked(TreeNode node)
{
foreach (TreeNode childNode in node.Nodes) {
if (childNode.Checked) return true;
}
return false;
}
//****************************************************************************************************************
}
Manage VEGAS Preferences | Important Tool for Every VEGAS User
Auto Render Script
You just need to save your favourite render templates if they are not already exists.
Do it only once.
this script will render your project at loop region as per your project settings by matching render template with it..
using ScriptPortal.Vegas;
using System;
using System.IO;
using System.Windows.Forms;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
try
{
// Validate project
if (vegas.Project == null || string.IsNullOrEmpty(vegas.Project.FilePath))
{
MessageBox.Show("Please save the project first.");
return;
}
string projectPath = vegas.Project.FilePath;
string projectDir = Path.GetDirectoryName(projectPath);
string renderDir = Path.Combine(projectDir, "Renders");
// Create render directory if it doesn't exist
EnsureDirectoryExists(renderDir);
Timecode loopStart = vegas.Transport.LoopRegionStart;
Timecode loopLength = vegas.Transport.LoopRegionLength;
if (loopLength == Timecode.FromSeconds(0))
{
MessageBox.Show("No loop region found. Please set a loop region.");
return;
}
// Render loop region
RenderLoopRegion(vegas, loopStart, loopLength, renderDir, projectPath);
}
catch (Exception ex)
{
MessageBox.Show("Unexpected error: " + ex.Message);
}
}
private void EnsureDirectoryExists(string renderDir)
{
if (!Directory.Exists(renderDir))
{
Directory.CreateDirectory(renderDir);
}
}
private void RenderLoopRegion(Vegas vegas, Timecode loopStart, Timecode loopLength, string renderDir, string projectPath)
{
try
{
bool isAudioOnly = IsAudioOnlyRegion(vegas, loopStart, loopLength);
string ext = isAudioOnly ? ".mp3" : ".mp4";
string filename = Path.GetFileNameWithoutExtension(projectPath);
string outputFile = Path.Combine(renderDir, filename + ext);
// Ensure the output file name is unique
outputFile = GetUniqueFileName(outputFile);
RenderTemplate template = FindRenderTemplate(vegas, isAudioOnly);
if (template == null)
{
MessageBox.Show("No suitable render template found.");
return;
}
vegas.Render(outputFile, template, loopStart, loopLength);
// Success Message and Option to Open Render Folder
DialogResult result = MessageBox.Show("Rendering complete!\nDo you want to open the output folder?", "Rendering Complete", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
System.Diagnostics.Process.Start("explorer.exe", renderDir);
}
}
catch (Exception ex)
{
MessageBox.Show("Render failed: " + ex.Message);
}
}
private string GetUniqueFileName(string filePath)
{
int counter = 1;
string uniqueFilePath = filePath;
// Check if file exists, if it does, increment the counter until a unique name is found
while (File.Exists(uniqueFilePath))
{
uniqueFilePath = Path.Combine(Path.GetDirectoryName(filePath),
Path.GetFileNameWithoutExtension(filePath) + "_" + counter + Path.GetExtension(filePath));
counter++;
}
return uniqueFilePath;
}
private bool IsAudioOnlyRegion(Vegas vegas, Timecode start, Timecode length)
{
try
{
foreach (Track track in vegas.Project.Tracks)
{
if (track.MediaType == MediaType.Video)
{
foreach (TrackEvent ev in track.Events)
{
Timecode evStart = ev.Start;
Timecode evEnd = ev.Start + ev.Length;
if (evEnd > start && evStart < start + length)
{
return false; // video event intersects with region
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error checking video presence: " + ex.Message);
}
return true;
}
private RenderTemplate FindRenderTemplate(Vegas vegas, bool audioOnly)
{
try
{
foreach (Renderer renderer in vegas.Renderers)
{
try
{
if (audioOnly && renderer.Name.ToUpper().Contains("MP3"))
{
foreach (RenderTemplate template in renderer.Templates)
{
if (template.IsValid())
{
return template;
}
}
}
else if (!audioOnly && renderer.ClassID == new Guid("4c184f1e-4d99-4353-9de0-e49da388cb63")) // Magix AVC/AAC
{
ProjectVideoProperties vid = vegas.Project.Video;
RenderTemplate bestTemplate = null;
long bestBitrate = 0;
foreach (RenderTemplate template in renderer.Templates)
{
if (!template.IsValid())
continue;
if (template.VideoWidth != vid.Width ||
template.VideoHeight != vid.Height ||
template.VideoPixelAspectRatio != vid.PixelAspectRatio ||
template.VideoFieldOrder != vid.FieldOrder ||
template.VideoFrameRate != vid.FrameRate)
continue;
if (template.VideoBitrate >= 15000 && template.VideoBitrate > bestBitrate)
{
bestTemplate = template;
bestBitrate = template.VideoBitrate;
}
}
return bestTemplate;
}
}
catch (Exception innerEx)
{
MessageBox.Show("Renderer check failed: " + innerEx.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Template search failed: " + ex.Message);
}
return null;
}
}
for more functions in rendering concept in VEGAS Pro
Download This Powerful Rendering Tool Created By Me.
Quick Render by iEmby
Give your feedback for both if you try.
THANKYOU
Script: eliminar el audio de los eventos de video seleccionados
using ScriptPortal.Vegas; namespace Test_Script { public class Class1 { public void Main(Vegas vegas) { foreach (Track myTrack in vegas.Project.Tracks) { if (myTrack.IsVideo()) { foreach (TrackEvent evnt in myTrack.Events) { if (evnt.Selected) { foreach (TrackEvent ev in evnt.Group) { if (ev != evnt && ev.ActiveTake.Media == evnt.ActiveTake.Media && ev.MediaType == MediaType.Audio) { ev.Track.Events.Remove(ev); } } } } } } } } } public class EntryPoint { public void FromVegas(Vegas vegas) //public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args) { Test_Script.Class1 test = new Test_Script.Class1(); test.Main(vegas); } }O puede descargar desde aquí con el archivo de iconos PNG.
https://drive.google.com/drive/folders/1ORPZoqgbujBKsFoPRkjBjYtcKUspk2xB?usp=sharing
Gracias a @zzzzzz9125 por compartir esto.
No funciona el enlace mi hermano, quisiera poder tener el ícono PNG
MiniTools by iEmby- Version 1.0
DOWNLOAD IT || USE IT || SHARE IT
Old link is not working now.
This is new link
Cómo puedo usar eso hermano, puedes colocar algún tutorial para saber la función que hace. Además no puedo ejecutarlo, uso el VEGAS PRO 22 (BUILD 250)
Duplicate Events to Up, Down, Right and Left directions | SCRIPT
This Script Duplicate selected Events to up, down, right and left direction. It was made with the guidance of @jetdv.
using System; using System.Drawing; using System.Windows.Forms; using System.Collections.Generic; using ScriptPortal.Vegas; namespace DuplicateEventLeftRightUp { public class Class1 { public Vegas myVegas; public void Main(Vegas vegas, string direction) { myVegas = vegas; List<TrackEvent> selectedEvents = new List<TrackEvent>(); Dictionary<TrackEvent, Track> eventTrackMap = new Dictionary<TrackEvent, Track>(); // List to store the new duplicated events List<TrackEvent> newEvents = new List<TrackEvent>(); // Find all selected events and their tracks foreach (Track track in myVegas.Project.Tracks) { foreach (TrackEvent evnt in track.Events) { if (evnt.Selected) { selectedEvents.Add(evnt); eventTrackMap[evnt] = track; } } } // Check if any events are selected if (selectedEvents.Count > 0) { // Sort selected events by their start time to handle them in order selectedEvents.Sort((a, b) => a.Start.CompareTo(b.Start)); // Find the maximum end time of all selected events manually Timecode lastGlobalEventEnd = new Timecode(0); foreach (TrackEvent evnt in selectedEvents) { if (evnt.End > lastGlobalEventEnd) { lastGlobalEventEnd = evnt.End; } } Timecode beginning = null; foreach (TrackEvent selectedEvent in selectedEvents) { Track myTrack = eventTrackMap[selectedEvent]; TrackEvent currentEvent = selectedEvent; Timecode eventLength = selectedEvent.Length; if (beginning == null) { beginning = selectedEvent.Start; } // Reset the position for the current event's duplicates Timecode lastEventEnd = currentEvent.End > lastGlobalEventEnd ? currentEvent.End : lastGlobalEventEnd; TrackEvent newEvent = null; Timecode newEventStart = currentEvent.Start; // Initialize to avoid unassigned error if (direction == "Left") { newEventStart = beginning - eventLength; beginning = newEventStart; } else if (direction == "Right") { // Calculate the start time for the next duplicate to avoid overlap newEventStart = lastEventEnd; } else if (direction == "Up" && myTrack.Index > 0) { Track targetTrack = myVegas.Project.Tracks[myTrack.Index - 1]; if (myTrack.IsAudio() && targetTrack.IsAudio()) { AudioTrack aTrack = (AudioTrack)targetTrack; newEvent = (AudioEvent)currentEvent.Copy(aTrack, currentEvent.Start); } else if (myTrack.IsVideo() && targetTrack.IsVideo()) { VideoTrack vTrack = (VideoTrack)targetTrack; newEvent = (VideoEvent)currentEvent.Copy(vTrack, currentEvent.Start); } } else if (direction == "Down" && myTrack.Index < myVegas.Project.Tracks.Count - 1) { Track targetTrack = myVegas.Project.Tracks[myTrack.Index + 1]; if (myTrack.IsAudio() && targetTrack.IsAudio()) { AudioTrack aTrack = (AudioTrack)targetTrack; newEvent = (AudioEvent)currentEvent.Copy(aTrack, currentEvent.Start); } else if (myTrack.IsVideo() && targetTrack.IsVideo()) { VideoTrack vTrack = (VideoTrack)targetTrack; newEvent = (VideoEvent)currentEvent.Copy(vTrack, currentEvent.Start); } } if (direction == "Left" || direction == "Right") { if (myTrack.IsAudio()) { AudioTrack aTrack = (AudioTrack)myTrack; newEvent = (AudioEvent)currentEvent.Copy(aTrack, newEventStart); } else if (myTrack.IsVideo()) { VideoTrack vTrack = (VideoTrack)myTrack; newEvent = (VideoEvent)currentEvent.Copy(vTrack, newEventStart); } // Update the end position of the last duplicate event and the global tracker lastEventEnd = newEvent.End; lastGlobalEventEnd = lastEventEnd; } if (newEvent != null) { newEvents.Add(newEvent); } } } else { MessageBox.Show("Please select events to duplicate."); } } } public class EntryPoint { public void FromVegas(Vegas vegas) { // Create the form Form form = new Form(); form.Text = "Duplicate Events"; form.StartPosition = FormStartPosition.CenterScreen; form.BackColor = Color.FromArgb(40, 40, 40); form.ForeColor = Color.White; form.FormBorderStyle = FormBorderStyle.Sizable; form.MaximizeBox = false; form.MinimizeBox = false; form.Size = new Size(195, 190); form.Font = new Font("Segoe UI", 10, FontStyle.Regular); // Create panel to hold the buttons Panel buttonPanel = new Panel(); buttonPanel.Size = new Size(160, 200); buttonPanel.Location = new Point(10, 10); buttonPanel.BackColor = Color.FromArgb(40, 40, 40); // Common button properties Size buttonSize = new Size(40, 35); Color buttonBackColor = Color.FromArgb(60, 60, 60); Color hoverColor = Color.FromArgb(100, 149, 237); // Up arrow Button duplicateUpButton = new Button(); duplicateUpButton.Text = "↑"; // Up arrow symbol duplicateUpButton.Font = new Font("Segoe UI", 20, FontStyle.Bold); duplicateUpButton.Size = buttonSize; duplicateUpButton.Location = new Point(60, 10); duplicateUpButton.BackColor = buttonBackColor; duplicateUpButton.ForeColor = Color.White; duplicateUpButton.FlatStyle = FlatStyle.Flat; duplicateUpButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100); duplicateUpButton.MouseEnter += (sender, e) => duplicateUpButton.BackColor = hoverColor; duplicateUpButton.MouseLeave += (sender, e) => duplicateUpButton.BackColor = buttonBackColor; // Down arrow Button duplicateDownButton = new Button(); duplicateDownButton.Text = "↓"; // Down arrow symbol duplicateDownButton.Font = new Font("Segoe UI", 20, FontStyle.Bold); duplicateDownButton.Size = buttonSize; duplicateDownButton.Location = new Point(60, 90); duplicateDownButton.BackColor = buttonBackColor; duplicateDownButton.ForeColor = Color.White; duplicateDownButton.FlatStyle = FlatStyle.Flat; duplicateDownButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100); duplicateDownButton.MouseEnter += (sender, e) => duplicateDownButton.BackColor = hoverColor; duplicateDownButton.MouseLeave += (sender, e) => duplicateDownButton.BackColor = buttonBackColor; // Left arrow Button duplicateLeftButton = new Button(); duplicateLeftButton.Text = "←"; // Left arrow symbol duplicateLeftButton.Font = new Font("Segoe UI", 20, FontStyle.Bold); duplicateLeftButton.Size = buttonSize; duplicateLeftButton.Location = new Point(10, 50); duplicateLeftButton.BackColor = buttonBackColor; duplicateLeftButton.ForeColor = Color.White; duplicateLeftButton.FlatStyle = FlatStyle.Flat; duplicateLeftButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100); duplicateLeftButton.MouseEnter += (sender, e) => duplicateLeftButton.BackColor = hoverColor; duplicateLeftButton.MouseLeave += (sender, e) => duplicateLeftButton.BackColor = buttonBackColor; // Right arrow Button duplicateRightButton = new Button(); duplicateRightButton.Text = "→"; // Right arrow symbol duplicateRightButton.Font = new Font("Segoe UI", 20, FontStyle.Bold); duplicateRightButton.Size = buttonSize; duplicateRightButton.Location = new Point(110, 50); duplicateRightButton.BackColor = buttonBackColor; duplicateRightButton.ForeColor = Color.White; duplicateRightButton.FlatStyle = FlatStyle.Flat; duplicateRightButton.FlatAppearance.BorderColor = Color.FromArgb(100, 100, 100); duplicateRightButton.MouseEnter += (sender, e) => duplicateRightButton.BackColor = hoverColor; duplicateRightButton.MouseLeave += (sender, e) => duplicateRightButton.BackColor = buttonBackColor; // Add controls to the panel buttonPanel.Controls.Add(duplicateUpButton); buttonPanel.Controls.Add(duplicateDownButton); buttonPanel.Controls.Add(duplicateLeftButton); buttonPanel.Controls.Add(duplicateRightButton); // Add controls to the form form.Controls.Add(buttonPanel); // Event handlers for button clicks duplicateUpButton.Click += (sender, e) => { form.Close(); new Class1().Main(vegas, "Up"); }; duplicateDownButton.Click += (sender, e) => { form.Close(); new Class1().Main(vegas, "Down"); }; duplicateLeftButton.Click += (sender, e) => { form.Close(); new Class1().Main(vegas, "Left"); }; duplicateRightButton.Click += (sender, e) => { form.Close(); new Class1().Main(vegas, "Right"); }; // Set focus to the form itself, so no button is focused by default form.Shown += (sender, e) => form.ActiveControl = null; // Show the form form.ShowDialog(); } } }
Funciona muy bien mi hermano, pero hay alguna manera de que no limite solo 1 copia? Porque si selecciono el evento que pegaré en alguna dirección, se hace 1, ahora tendría 2 eventos, pero si selecciono esos 2 eventos para copiar más en cualquier dirección, solo se registra una copia, no los 2 eventos.
Lamento no poder modificar alguno de estos scripts para mejorar, es que recién estoy entendiendo esto y no tengo el conocimiento aún.
Otro punto es que sé que si copio un evento de audio o vídeo, luego selecciono para pegarlo, pero presiono Ctrl+B, puedo colocar el número de copias que deseo hacia la derecha, pero eso mismo se podría hacer teniendo en cuenta las direcciones?
Gracias una vez más por los scripts
@Manuel-CernaSnchez Hola, podrías hacer un vídeo para entenderlo mejor tu objetivo?
Resize Images In Media Pool With One Click without Harming Original Images.
Set Size Max : 1080 px height.
You Can Set Max Size As Per You Need.
using ScriptPortal.Vegas;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System;
using System.Collections.Generic;
using System.Windows.Forms;public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
int targetMaxHeight = 1080;
int resizedImageCount = 0; List<Tuple<Media, string>> mediaToReplace = new List<Tuple<Media, string>>(); try
{
foreach (Media media in vegas.Project.MediaPool)
{
try
{
if (media.HasVideo())
{
string filePath = media.FilePath;
string extension = Path.GetExtension(filePath).ToLower(); if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".bmp" || extension == ".tiff")
{
VideoStream videoStream = null;
try
{
foreach (MediaStream stream in media.Streams)
{
if (stream.MediaType == MediaType.Video)
{
videoStream = (VideoStream)stream;
break;
}
}
}
catch (Exception ex)
{
vegas.ShowError("Error getting video stream for " + filePath + ": " + ex.Message, "Script Error");
continue;
} if (videoStream != null)
{
int originalWidth = videoStream.Width;
int originalHeight = videoStream.Height; if (originalHeight > targetMaxHeight)
{
int newHeight = targetMaxHeight;
double ratio = (double)newHeight / originalHeight;
int newWidth = (int)(originalWidth * ratio); try
{
string directory = Path.GetDirectoryName(filePath);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
string resizedFileName = fileNameWithoutExtension + "_resize" + extension;
string resizedFilePath = Path.Combine(directory, resizedFileName); using (Image originalImage = Image.FromFile(filePath))
{
using (Bitmap newImage = new Bitmap(newWidth, newHeight))
{
using (Graphics g = Graphics.FromImage(newImage))
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(originalImage, 0, 0, newWidth, newHeight);
} newImage.Save(resizedFilePath, originalImage.RawFormat); mediaToReplace.Add(Tuple.Create(media, resizedFilePath));
resizedImageCount++;
}
}
}
catch (Exception ex)
{
vegas.ShowError("Error during image resize or file operation for " + filePath + ": " + ex.Message, "Image Resize Error");
}
}
}
}
}
}
catch (Exception ex)
{
vegas.ShowError("Error processing media item: " + media.FilePath + ": " + ex.Message, "Script Error");
}
} using (UndoBlock undo = new UndoBlock("Resize Images in Media Pool"))
{
foreach (Tuple<Media, string> item in mediaToReplace)
{
Media originalMedia = item.Item1;
string newFilePath = item.Item2; try
{
Media existingNewMedia = vegas.Project.MediaPool.Find(newFilePath);
Media newMediaInstance; if (existingNewMedia != null)
{
newMediaInstance = existingNewMedia;
}
else
{
newMediaInstance = Media.CreateInstance(vegas.Project, newFilePath);
} originalMedia.ReplaceWith(newMediaInstance);
}
catch (Exception ex)
{
vegas.ShowError("Error replacing media for original: " + originalMedia.FilePath + " with resized: " + newFilePath + ": " + ex.Message, "Media Replacement Error");
}
}
}
}
catch (Exception ex)
{
vegas.ShowError("An unexpected error occurred during script execution: " + ex.Message, "Script Execution Error");
}
finally
{
vegas.UpdateUI();
MessageBox.Show(resizedImageCount + " Images resized and replaced successfully.", "Script Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
Download From Above Link.
MEGA Link..
I will try to keep it here permanent.