Would it be possible for a "Launch Mocha UI" Script?

Steve_Rhoden wrote on 3/6/2024, 6:43 AM

Just wanting to know if a script could be created to launch Mocha Pro on the selected event? This would be very convenient to select an event and with a single click of the script, Mocha Pro is initialize and the "Launch Mocha UI" opens up the program.

Comments

jetdv wrote on 3/6/2024, 10:26 AM

Once an effect is added to an event, a script can open the VEGAS FX UI. If there's more than one effect, I can't guarantee which effect will be selected by default. And if Mocha has a separate UI that opens, it *might* be possible for a script to "push that button" but I can't guarantee that it would open the UI - especially if the VEGAS FX window wasn't open.

jetdv wrote on 3/6/2024, 12:51 PM

Well, what do you know, it actually works. This will look for a selected video event that has the Mocha VEGAS plugins on it. It will then open the VEGAS FX dialog and then push the "Launch Mocha UI" button.

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent vEvent in myTrack.Events)
                    {
                        if (vEvent.Selected)
                        {
                            foreach (Effect myEffect in vEvent.Effects)
                            {
                                if (myEffect.PlugIn.UniqueID == "{Svfx:com.borisfx.ofx.mochaVegas}")
                                {
                                    vEvent.OpenVideoEffectUI();
                                    myVegas.UpdateUI();
                                    if (myEffect.IsOFX)
                                    {
                                        OFXEffect OFX = myEffect.OFXEffect;
                                        foreach(OFXParameter parm in OFX.Parameters)
                                        {
                                            if (parm.ParameterType == OFXParameterType.PushButton && parm.Name == "launchMochaProID")
                                            {
                                                parm.ParameterChanged();
                                                myVegas.UpdateUI();
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

 

Steve_Rhoden wrote on 3/6/2024, 1:06 PM

Thank you so much, Gonna give it a whirl....

m3lquixd wrote on 3/6/2024, 6:03 PM

@jetdv Could you make it so that if the event didn't have mocha vegas it could be 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 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/6/2024, 8:50 PM

Yes, that is certainly possible. Just look at any of the tutorials on my site that show how to add an effect. Then instead of searching for effects, find the selected event, add the effect, and then just use the effect you just added. There are several examples in my tutorials.

Here's an example (but not with Mocha):

 

m3lquixd wrote on 3/6/2024, 9:55 PM

I tried to change exactly this script, but I couldn't

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 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/6/2024, 11:05 PM

Would be something more like:

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent vEvent in myTrack.Events)
                    {
                        if (vEvent.Selected)
                        {
                            string plugInUID = "{Svfx:com.borisfx.ofx.mochaVegas}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            vEvent.Effects.Add(effect);
                            vEvent.OpenVideoEffectUI();
                            myVegas.UpdateUI();

                            if (effect.IsOFX)
                            {
                                OFXEffect OFX = effect.OFXEffect;
                                foreach(OFXParameter parm in OFX.Parameters)
                                {
                                    if (parm.ParameterType == OFXParameterType.PushButton && parm.Name == "launchMochaProID")
                                    {
                                        parm.ParameterChanged();
                                        myVegas.UpdateUI();
                                    }
                                }
                            }
                        }
                    }
                }
            }

 

m3lquixd wrote on 3/7/2024, 6:25 AM

@jetdv But this is adding a new mocha even though there is already one in the event, ideally if there was already a mocha in the event, it would just open the interface

Last changed by m3lquixd on 3/7/2024, 7:16 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 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/7/2024, 8:07 AM

Well... yes it is. That same tutorial shows how to check for it already being there and then adding only if it needs to be added.
 

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 (VideoEvent vEvent in myTrack.Events)
                    {
                        if (vEvent.Selected)
                        {
                            string plugInUID = "{Svfx:com.borisfx.ofx.mochaVegas}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = null;
                            bool MochaFound = false;

                            foreach(Effect myEffect in vEvent.Effects)
                            {
                                if (myEffect.PlugIn.UniqueID == "{Svfx:com.borisfx.ofx.mochaVegas}")
                                {
                                    effect = myEffect;
                                    MochaFound = true;
                                }
                            }

                            if (!MochaFound)
                            {
                                effect = new Effect(plugin);
                                vEvent.Effects.Add(effect);
                            }
                            vEvent.OpenVideoEffectUI();
                            myVegas.UpdateUI();

                            if (effect.IsOFX)
                            {
                                OFXEffect OFX = effect.OFXEffect;
                                foreach(OFXParameter parm in OFX.Parameters)
                                {
                                    if (parm.ParameterType == OFXParameterType.PushButton && parm.Name == "launchMochaProID")
                                    {
                                        parm.ParameterChanged();
                                        myVegas.UpdateUI();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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

 

m3lquixd wrote on 3/7/2024, 8:34 AM

Perfect, thank you!

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 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))