📝⚙️(Script) Add Picture-in-Picture to the event.

m3lquixd wrote on 3/8/2023, 8:27 AM

Is there a way to create a script that when triggered the selected event is added a video fx? Example: When running the script, the picture in picture plugin is added to the selected event.

Last changed by m3lquixd

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

Comments

jetdv wrote on 3/8/2023, 8:49 AM

Just go through my tutorials...

Picture In Picture - UID: {Svfx:com.vegascreativesoftware:pictureinpicture}

In short, yes there is a way. The script can add the Picture in Picture effect and can also either pick a preset or adjust the parameters.

The first tutorial gives you information on all of the plugins. The important information for Picture and Picture is listed above. The next tutorial shows how to add an effect to an event. The next one shows how to adjust parameters. The last one shows how to add that effect to an event, track, media, or the entire project.

m3lquixd wrote on 3/8/2023, 9:14 AM

@jetdv Could you create it and highlight where to choose the plugin and where to change the parameters? To see if I can understand how this script works. Because I don't speak English and I don't understand programming.
If it's not a bother, you would do one that adds the picture in picture plugin to the selected event. with scale parameters x and y 1,000
 

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/8/2023, 9:54 AM

Go back to the script where we were setting the alpha channel. This is the main part:

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {

                        }
                    }
                }
            }

That goes through all of the tracks, confirms it's a video track as we are wanting to add a video effect so we don't need to look at audio tracks, then goes through all of the events on the video track, and looks to see if the event is selected. That's the event(s) to which you want the effect added.

Now, per the second tutorial using the information I listed above which came from the first tutorial, the effect needs to be added to the selected event:

                            VideoEvent vEvent = (VideoEvent)evnt;
                            string plugInUID = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            vEvent.Effects.Add(effect);

First, we're adding a video effect so we have to work with a video event. So we change the "track event" to a "video event". Then we indicate which effect we want. Look at the effects available in VEGAS, get that specific plugin, get a new effect from that plugin, and add that effect to the event.

Next comes the harder part which is found in the third tutorial. We have to get the OFXEffect but we don't know the "name" of the parameters we want to change so we we'll add this:

                            OFXEffect ofx = effect.OFXEffect;
                            foreach (OFXParameter ofxParm in ofx.Parameters)
                            {
                                MessageBox.Show(ofxParm.Name + "  -  " + ofxParm.Label + "  -  " + ofxParm.ParameterType.ToString());
                            }

This will get us the OFX effect and then list all of the parameters available to us. We're looking for "X" and "Y" to adjust. Now we'll run this and look at all of the messages pop up making note of the ones we want and the types of parameter they are. In this case, it appears we want "Scale" which is labeled "Scale in X" as the "Y" should automatically follow. That is a "Double" variable. The "Y" value is called "DistortionScaleY" and is also a Double variable. We can set this too but it really doesn't matter.

That means we will then change that last section to now read:

                            OFXEffect ofx = effect.OFXEffect;
                            OFXDoubleParameter X = (OFXDoubleParameter)ofx["Scale"];
                            X.Value = 1.000;
                            OFXDoubleParameter Y = (OFXDoubleParameter)ofx["DistortionScaleY"];
                            Y.Value = 1.000;

We'll get our "X" parameter named "Scale" and set it to a value of 1.000. And this will also set the "Y" parameter even though it's automatically the same as the "X" value unless you change other parameters.

Now surrounding it with all the default base code that surrounds all of the scripts we've been creating. You end up with:
 

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            VideoEvent vEvent = (VideoEvent)evnt;
                            string plugInUID = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            vEvent.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;
                            OFXDoubleParameter X = (OFXDoubleParameter)ofx["Scale"];
                            X.Value = 1.000;
                            OFXDoubleParameter Y = (OFXDoubleParameter)ofx["DistortionScaleY"];
                            Y.Value = 1.000;
                        }
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

All the information is there in those tutorials. It's just a matter of adjusting for your specific effect and parameters.

m3lquixd wrote on 3/8/2023, 12:21 PM

@jetdv Thank you very much for the explanation, I will try to replicate with another plugin.
A doubt. Is it possible to automatically open the settings window of the added plug-in? Automatically open the video event FX after the plugin has been added.​​​​​​​

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/8/2023, 12:25 PM

@jetdv Because my idea is to add PiP and immediately be able to move the media in the video preview. without even having to click on the Video Event FX icon.

Last changed by m3lquixd on 3/8/2023, 12:27 PM, changed a total of 1 times.

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/8/2023, 12:33 PM

Is it possible to automatically open the settings window of the added plug-in? Automatically open the video event FX after the plugin has been added.​​​​​​​

Yes, add

evnt.OpenVideoEffectUI();

on the line after Y.Value = 1.000;

m3lquixd wrote on 3/8/2023, 1:04 PM

Final script.

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            VideoEvent vEvent = (VideoEvent)evnt;
                            string plugInUID = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            vEvent.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;
                            OFXDoubleParameter X = (OFXDoubleParameter)ofx["Scale"];
                            X.Value = 1.000;
                            OFXDoubleParameter Y = (OFXDoubleParameter)ofx["DistortionScaleY"];
                            Y.Value = 1.000;
                            evnt.OpenVideoEffectUI();
                        }
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

Utility for him below:

Thank you again @jetdv!

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

Steve_Rhoden wrote on 3/8/2023, 10:27 PM

Thank you so much for this script @jetdv, very very convenient and helpful to have this script sitting on the toolbar, because i use the PIP feature quite so often.

And thank you @m3lquixd for bringing this helpful bit to the forefront and also in refining this script. 👍👍

m3lquixd wrote on 3/9/2023, 6:11 AM

@jetdv is the best. Just thank him. I only think of ideas.

Last changed by m3lquixd on 3/9/2023, 6:19 AM, changed a total of 1 times.

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/9/2023, 6:32 AM

@jetdv Is it possible to make the script, before adding the PiP, check if the event already has a PiP? If the event already has a PiP, instead of adding another one, the script will only open the PiP adjustment window. PiP's Video Effect UI. If the event does not have a PiP, the script will add it and open the window.

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/9/2023, 9:05 AM

Yes. Note here that we add a new "pipFound" variable after getting the Video Event and defining the UniqueID we're looking for. Then we add a new section to search for that UniqueID:

 foreach(Effect eff in vEvent.Effects) 
{ 
    if (eff.PlugIn.UniqueID == plugInUID) 
    { 
        pipFound = true; 
        break; 
    } 
} 

Next, we only add the effect *IF* pipFound is false - or "not pipFound", the ! means "Not". In either case, the effect window will be opened as that command is left outside of the "if" statement.

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            VideoEvent vEvent = (VideoEvent)evnt;
                            string plugInUID = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
                            bool pipFound = false;

                            foreach(Effect eff in vEvent.Effects)
                            {
                                if (eff.PlugIn.UniqueID == plugInUID)
                                {
                                    pipFound = true;
                                    break;
                                }
                            }

                            if (!pipFound)
                            {
                                PlugInNode fx = myVegas.VideoFX;
                                PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                                Effect effect = new Effect(plugin);
                                vEvent.Effects.Add(effect);

                                OFXEffect ofx = effect.OFXEffect;
                                OFXDoubleParameter X = (OFXDoubleParameter)ofx["Scale"];
                                X.Value = 1.000;
                                OFXDoubleParameter Y = (OFXDoubleParameter)ofx["DistortionScaleY"];
                                Y.Value = 1.000;
                            }

                            evnt.OpenVideoEffectUI();
                        }
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

relaxvideo wrote on 3/9/2023, 9:12 AM

Cool!

jetdv: it is still impossible to press a button on fx panel with script? For example i do 3D stereo editing with 2 cams and always align the left and right views with the "auto correct" button. But with lot of clips this is a hard, repeatable work. (yes, i know Vegasaur can do that, but i search a free solution for this easy task.)

thanks

#1 Ryzen 5-1600, 16GB DDR4, Nvidia 1660 Super, M2-SSD, Acer freesync monitor

#2 i7-2600, 32GB, Nvidia 1660Ti, SSD for system, M2-SSD for work, 2x4TB hdd, LG 3D monitor +3DTV +3D projectors

Win10 x64, Vegas22 latest

jetdv wrote on 3/9/2023, 9:18 AM

@relaxvideo, please see here:

 

m3lquixd wrote on 3/9/2023, 9:34 AM

@jetdvI emphasized "PiP's Video Effect UI" because if you have one more plugin in the event, it would open specifically the PiP window, not just the Video Effect UI window.​​​​​​​

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/9/2023, 9:59 AM

@jetdv Is it possible to specifically open the PiP window, even having another plugin in the event? I don't think it's possible lol 😅 but you're going to tell me.

Last changed by m3lquixd on 3/9/2023, 10:23 AM, changed a total of 1 times.

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/9/2023, 11:09 AM

@m3lquixd, you're lucky it can open the window. It can't pick which item in that window to open to. So, yes, I'm going to tell you it's not possible.

m3lquixd wrote on 3/9/2023, 11:37 AM

@jetdv Yeah, as I thought. But that's okay, that's good enough.

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

relaxvideo wrote on 3/24/2023, 11:43 AM

@relaxvideo, please see here:

 

Jetdv: thanks, finally i have little time for testing.
It should work in Vegas 11 too?

I already have and use the Stereoscopic 3D adjust adding script, which is works by hotkey.
Now i like to do the auto alignment automatically, without pressing the button every time.

So i insert these lines in my .JS file, but it doesn't work for some reason:

foreach (Parameter parm in evnt.Effects.Parameters)
{
   if (parm.ParameterType.ToString() == "PushButton")
     {   
         parm.ParameterChanged();
     }
}         

What could be wrong? Maybe only work in latest Vegas versions? :(

#1 Ryzen 5-1600, 16GB DDR4, Nvidia 1660 Super, M2-SSD, Acer freesync monitor

#2 i7-2600, 32GB, Nvidia 1660Ti, SSD for system, M2-SSD for work, 2x4TB hdd, LG 3D monitor +3DTV +3D projectors

Win10 x64, Vegas22 latest

jetdv wrote on 3/24/2023, 11:53 AM

OFX was added in Vegas 10 so, it might work in Vegas 11. However, I don't know exactly when all of the API calls were added.

I do know that the ".ParameterChanged();" call was available at that time. I cannot say whether or not it worked for the "push button" parameter.

relaxvideo wrote on 3/24/2023, 11:56 AM

ok, thanks, will test in 19 too, but i love 11 better :) :)

#1 Ryzen 5-1600, 16GB DDR4, Nvidia 1660 Super, M2-SSD, Acer freesync monitor

#2 i7-2600, 32GB, Nvidia 1660Ti, SSD for system, M2-SSD for work, 2x4TB hdd, LG 3D monitor +3DTV +3D projectors

Win10 x64, Vegas22 latest

jetdv wrote on 3/24/2023, 2:49 PM

@relaxvideo I just realized, you have incorrect code there!

foreach (Effect effect in evnt.Effects)
{
    OFXEffect ofx = effect.OFXEffect;
    foreach (OFXParameter parm in ofx.OFXParameters)
    {
       if (parm.ParameterType.ToString() == "PushButton")
       {   
           parm.ParameterChanged();
       }
    }
}

You have to be looking at the OFXEffect and the OFXParameters.

relaxvideo wrote on 3/24/2023, 3:32 PM

Thanks, but V11 still give me an error message:

C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(28) : Expected ',' or ')'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(28) : Expected ';'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(30) : The list of attributes does not apply to the current context
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(31) : Expected ',' or ')'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(31) : Expected ';'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(28) : Variable 'foreach' has not been declared
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\3d-auto.js(33) : Variable 'parm' has not been declared

 

My code:

import Sony.Vegas; 
import System.Windows.Forms;
import Microsoft.Win32;

var plugInName = "Stereoscopic 3D Adjust";
var presetName = "";

try
{
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;

var fx = Vegas.VideoFX;

var plugIn = fx.GetChildByName(plugInName);
if (null == plugIn) {
throw "could not find a plug-in named: '" + plugInName + "'";
}

var effect = new Effect(plugIn);
evnt.Effects.Add(effect);

if (null != presetName) {
effect.Preset = presetName;
}

foreach (Effect effect in evnt.Effects)
  {
    OFXEffect ofx = effect.OFXEffect;
    foreach (OFXParameter parm in ofx.OFXParameters)
    {
       if (parm.ParameterType.ToString() == "PushButton")
       {   
           parm.ParameterChanged();
       }
    }
  }

}
}
}

catch (errorMsg)

{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

 

#1 Ryzen 5-1600, 16GB DDR4, Nvidia 1660 Super, M2-SSD, Acer freesync monitor

#2 i7-2600, 32GB, Nvidia 1660Ti, SSD for system, M2-SSD for work, 2x4TB hdd, LG 3D monitor +3DTV +3D projectors

Win10 x64, Vegas22 latest

jetdv wrote on 3/24/2023, 3:46 PM

@relaxvideo Well... you don't need to go through the list of effects because you just added the effect you want to look at. Turns out that var effect = new Effect(plugIn); and foreach (Effect effect were both creating the "effect" variable. Therefore, you were getting an error because the same variable was being defined twice in the same scope. But you don't need it anyway - just use the initial "effect" variable and get rid of the foreach loop looking at the effects list.

import Sony.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;

var plugInName = "Stereoscopic 3D Adjust";
var presetName = "";

try
{
    for (var track in Vegas.Project.Tracks) {
        for (var evnt in track.Events) {
            if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;

            var fx = Vegas.VideoFX;

            var plugIn = fx.GetChildByName(plugInName);
            if (null == plugIn) {
                throw "could not find a plug-in named: '" + plugInName + "'";
            }

            var effect = new Effect(plugIn);
            evnt.Effects.Add(effect);

            if (null != presetName) {
                effect.Preset = presetName;
            }

            OFXEffect ofx = effect.OFXEffect;
            foreach (OFXParameter parm in ofx.OFXParameters)
            {
                if (parm.ParameterType.ToString() == "PushButton")
                {   
                    parm.ParameterChanged();
                }
            }
        }
    }
}


catch (errorMsg)

{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

 

relaxvideo wrote on 3/24/2023, 4:01 PM

thanks again, but if i use that code:

C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\nane.js(28) : The list of attributes does not apply to the current context
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\nane.js(29) : Expected ',' or ')'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\nane.js(29) : Expected ';'
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\nane.js(29) : Variable 'foreach' has not been declared
C:\Program Files\Sony\Vegas Pro 11.0\Script Menu\Add_fx\nane.js(31) : Variable 'parm' has not been declared

 

#1 Ryzen 5-1600, 16GB DDR4, Nvidia 1660 Super, M2-SSD, Acer freesync monitor

#2 i7-2600, 32GB, Nvidia 1660Ti, SSD for system, M2-SSD for work, 2x4TB hdd, LG 3D monitor +3DTV +3D projectors

Win10 x64, Vegas22 latest