I need codes for ResetPanCrop and MatchOutputAspect.

iEmby wrote on 12/1/2023, 12:14 PM

i need chsarp codes for ResetPanCrop properties on selected events. and MatchOutputAspect for selected events.
can anyone help me.
pls keep in mind
write codes is csharp only and don't use Linq namespace.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Comments

jetdv wrote on 12/1/2023, 12:58 PM

@iEmby, did you look through my tutorials? There's a lot of information there but you may need to search a little bit to find the video you want...

http://www.jetdv.com/

https://www.youtube.com/@JetDVScripts/videos

Reset Pan/Crop:

Match Output Aspect (And resize which you can overlook):

 

iEmby wrote on 12/4/2023, 6:34 AM

Thankyou sir.. both i found and worked so well...
but i want to use Match Output Aspect in my own new toolkit script. in that it gives so many errors.. so i create i as individual script
 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 12/4/2023, 9:00 AM

The basic code presented will work wherever you want to place it. However, you may need to make sure the proper pieces are being passed to the routines. You can use it however you need.

iEmby wrote on 12/15/2023, 3:12 AM

@jetdv

thanks sir..

i am working on a new script which is merging tracks in one track from full project. But there are some exemptions like ignore track for merge if it has track fx, compositing level below 100%. And also ignore merging if events will overlap after merge. So i create this script and it works except last two exemption. can you help me in those last two exemptions. i am providing you my rest of code.

 

using System;
using System.Collections.Generic;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        MergeAndDeleteOriginalTracks(vegas);
    }

    private void MergeAndDeleteOriginalTracks(Vegas vegas)
    {
        // Create a new video track for merged events
        VideoTrack mergedTrack = new VideoTrack(0);
        vegas.Project.Tracks.Add(mergedTrack);

        // List to store original tracks for deletion
        List<Track> tracksToDelete = new List<Track>();

        // Iterate through all tracks in the project
        foreach (Track track in vegas.Project.Tracks)
        {
            // Skip the merged track itself
            if (track != mergedTrack)
            {
                // Check if the track has track-level FX
                if (!HasTrackFX(track))
                {
                    // Iterate through events in each track
                    foreach (TrackEvent trackEvent in track.Events)
                    {
                        // Copy the event to the new merged track
                        TrackEvent newEvent = trackEvent.Copy(mergedTrack, trackEvent.Start);

                        // Deselect the original event and select the copied event on the merged track
                        trackEvent.Selected = false;
                        newEvent.Selected = true;
                    }

                    // Add the original track to the list for deletion
                    tracksToDelete.Add(track);
                }
            }
        }

        // Remove the original tracks
        foreach (Track trackToDelete in tracksToDelete)
        {
            vegas.Project.Tracks.Remove(trackToDelete);
        }

        // Update the UI
        vegas.UpdateUI();
    }

    private bool HasTrackFX(Track track)
    {
        // Check if the track has track-level FX
        return track.Effects.Count > 0;
    }
}
 

Last changed by iEmby on 12/15/2023, 3:13 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 12/15/2023, 9:53 AM

For the overlap, you'll have to compare every event's start/end time to see if there's anything on the merged track in that time frame. It's a pain to have to check against every event every time but it does work. So create you a new function to "CheckForOverlap" and pass it the Merge track and the track you're checking. Then for every event on the track you're checking, check to see of there's anything on the merge track in that timeframe. Maybe something like (yes, it's not necessarily the most efficient that it could be but it should work):

        public bool EventsOverlapped(Track thisTrack, Track mergeTrack)
        {
            bool overlapped = false;

            foreach(TrackEvent evnt in thisTrack.Events)
            {
                foreach(TrackEvent mevent in mergeTrack.Events)
                {
                    if (mevent.Start > evnt.Start && mevent.Start < evnt.End)
                    {
                        overlapped = true;
                        break;
                    }
                    if (mevent.End > evnt.Start && mevent.End < evnt.End)
                    {
                        overlapped = true;
                        break;
                    }
                }
                if (overlapped)
                {
                    break;
                }
            }

            return overlapped;
        }

To check the opacity level, you have to look at the "video track":

                VideoTrack vidTrack = (VideoTrack)myTrack;
                if (vidTrack.CompositeLevel < 100)
                {
                    //opacity has been lowered
                }

So try this to add the composite level check (I added the "bold" parts):

        foreach (Track track in vegas.Project.Tracks)
        {
            // Skip the merged track itself
 and only look at video tracks
            if (track != mergedTrack && track.isVideo())
            {
                VideoTrack vidTrack = (VideoTrack)track;


                // Check if the track has track-level FX, composite level of 100, and no overlapped events
                if (!HasTrackFX(track) && vidTrack.CompositeLevel == 100 && !EventsOverlapped(track, mergedTrack))
                {
                    // Iterate through events in each track
                    foreach (TrackEvent trackEvent in track.Events)
                    {
                        // Copy the event to the new merged track
                        TrackEvent newEvent = trackEvent.Copy(mergedTrack, trackEvent.Start);

                        // Deselect the original event and select the copied event on the merged track
                        trackEvent.Selected = false;
                        newEvent.Selected = true;
                    }

                    // Add the original track to the list for deletion
                    tracksToDelete.Add(track);
                }
            }
        }

 

iEmby wrote on 12/16/2023, 5:32 AM

For the overlap, you'll have to compare every event's start/end time to see if there's anything on the merged track in that time frame. It's a pain to have to check against every event every time but it does work. So create you a new function to "CheckForOverlap" and pass it the Merge track and the track you're checking. Then for every event on the track you're checking, check to see of there's anything on the merge track in that timeframe. Maybe something like (yes, it's not necessarily the most efficient that it could be but it should work):

        public bool EventsOverlapped(Track thisTrack, Track mergeTrack)
        {
            bool overlapped = false;

            foreach(TrackEvent evnt in thisTrack.Events)
            {
                foreach(TrackEvent mevent in mergeTrack.Events)
                {
                    if (mevent.Start > evnt.Start && mevent.Start < evnt.End)
                    {
                        overlapped = true;
                        break;
                    }
                    if (mevent.End > evnt.Start && mevent.End < evnt.End)
                    {
                        overlapped = true;
                        break;
                    }
                }
                if (overlapped)
                {
                    break;
                }
            }

            return overlapped;
        }

To check the opacity level, you have to look at the "video track":

                VideoTrack vidTrack = (VideoTrack)myTrack;
                if (vidTrack.CompositeLevel < 100)
                {
                    //opacity has been lowered
                }

So try this to add the composite level check (I added the "bold" parts):

        foreach (Track track in vegas.Project.Tracks)
        {
            // Skip the merged track itself
 and only look at video tracks
            if (track != mergedTrack && track.isVideo())
            {
                VideoTrack vidTrack = (VideoTrack)track;


                // Check if the track has track-level FX, composite level of 100, and no overlapped events
                if (!HasTrackFX(track) && vidTrack.CompositeLevel == 100 && !EventsOverlapped(track, mergedTrack))
                {
                    // Iterate through events in each track
                    foreach (TrackEvent trackEvent in track.Events)
                    {
                        // Copy the event to the new merged track
                        TrackEvent newEvent = trackEvent.Copy(mergedTrack, trackEvent.Start);

                        // Deselect the original event and select the copied event on the merged track
                        trackEvent.Selected = false;
                        newEvent.Selected = true;
                    }

                    // Add the original track to the list for deletion
                    tracksToDelete.Add(track);
                }
            }
        }

 

Thanks so much 🙏

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 12/17/2023, 2:39 PM

@jetdv
sir is there anything we can create with codes which is like a 'Please Wait' Box which will keep showing until processing of current run script is not completed. after completion it should disappear. can you help me in this?
As i added 'vegas.UpdateUI();' at the end of every code. so i created this. but this disappeared before process completed.

 

    private void PleaseWait(Vegas vegas)
    {
        var pleaseWaitForm = new Form();
        pleaseWaitForm.Text = "";
        pleaseWaitForm.FormBorderStyle = FormBorderStyle.FixedDialog;
        pleaseWaitForm.Size = new System.Drawing.Size(200, 80);
        pleaseWaitForm.StartPosition = FormStartPosition.CenterScreen;
        pleaseWaitForm.MinimizeBox = false;
        pleaseWaitForm.MaximizeBox = false;

        var label = new Label();
        label.Text = "Please Wait";
        label.Dock = DockStyle.Fill;
        label.Font = new System.Drawing.Font("Mont", 12, System.Drawing.FontStyle.Regular);
        label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

        pleaseWaitForm.Controls.Add(label);

        var loadingDots = new Label();
        loadingDots.Text = "...";
        loadingDots.Dock = DockStyle.Bottom;
        loadingDots.Font = new System.Drawing.Font("Mont", 16, System.Drawing.FontStyle.Bold);
        loadingDots.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

        pleaseWaitForm.Controls.Add(loadingDots);

        var checkUpdateUITimer = new System.Windows.Forms.Timer();
        checkUpdateUITimer.Interval = 500; // 0.5 seconds, adjust as needed

        checkUpdateUITimer.Tick += (sender, e) =>
        {
            vegas.UpdateUI();
            pleaseWaitForm.Close();
            checkUpdateUITimer.Stop(); // Stop the timer after UI update
        };

        pleaseWaitForm.Shown += (sender, e) =>
        {
            checkUpdateUITimer.Start(); // Start the timer when the form is shown
        };

        pleaseWaitForm.ShowDialog();
    }

Last changed by iEmby on 12/17/2023, 2:40 PM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 12/18/2023, 7:52 AM

@iEmby, what I would typically do is add a progress bar to the dialog box. Show the dialog box and then update the progress bar as the processing progresses. Then when finished, I would typically just let them click on OK but you could try just closing the window. My progress bars have typically been in Custom Commands that stay open all the time so I don't need to worry about getting rid of the window or clicking on a button.

iEmby wrote on 12/19/2023, 1:49 AM

can u give me codes for that?

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 12/19/2023, 9:03 AM

@iEmby Here's from where I have a form where I added a progress bar named pbAll. I use the progress bar to show that activity is happening as the list is being processed. Once the procedure is done, I hide it again.
 

        private void btnDoAll_Click(object sender, EventArgs e)
        {
            pbAll.Value = 0; // Set the initial value to zero
            pbAll.Visible = true; // Make the progress bar visible

            // Looping through the items to process
            for (int i = 0; i < lstEvents.Items.Count; i++)
            {
                pbAll.Value = (i * 100) / lstEvents.Items.Count;  // Update the progress bar

                *** do whatever needs done to this item here ***

            }

            pbAll.Visible = false; // Finished so now hide the progress bar
        }

 

iEmby wrote on 12/20/2023, 10:09 PM

@jetdv thanks sir let me try once

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)