A Script that opens a specific Vegas Project

torpex wrote on 10/26/2022, 9:49 AM

I have several Vegas projects that I use as templates and may need any of them at any time, they don't survive for long in the recent projects menu, so I thought it would be handy to have specific buttons in the tool bar to jump right to them, which you can do by adding scripts as buttons in the customize toolbar menu, but I've never managed to make a script that worked, no matter how many other scripts I tried reverse engineering.
JEDTV kindly gave me this bit of code under one of his YT videos:

 myVegas.NewProject(false, false);
                myVegas.OpenProject(E:\vegas projects\HDMS Templates\);

But I have no idea what other code is needed.

To be honest I assumed this would have been a fairly common script being used for the same purpose I am, to make buttons to open commonly used template projects, but it seems no one has ever mentioned their script for this online.
Does anyone know what the full script might look like around this?
Thanks in advance.

Comments

jetdv wrote on 10/26/2022, 10:02 AM

@torpex What you have listed won't work as-is. First of all, the path has to be a string so you'd need quotes around it. Secondly, "OpenProject" expects an exact file name in addition to the path. Are you trying to just open a dialog at a specific path that then lets you select the file? Or are you trying to open a specific file?

For example, you could use something like:

myVegas.NewProject(false, false);
myVegas.OpenProject("E:\\vegas projects\\HDMS Templates\\Template1.veg");

And that script would open that specific project. Then you could create several of those pointing at different files and add them to your toolbar for easy access. But you'd need one script per template.

Alternately, you could open a window that shows you a specific folder and then opens the selected file. Then you would only need one script to run, you would select the file you wanted and then VEGAS would open the selected file. If that's what you prefer, I'd be happy to create a quick tutorial on that.

torpex wrote on 10/26/2022, 10:57 AM

Cheers for the quick reply, yeah just one button per template would be okay, so I've got:

myVegas.NewProject(false, false);
myVegas.OpenProject("E:\\vegas projects\\HDMS Templates\\HDMS01.veg");

What needs to come before and after that, and should it be a js or cs file?

I'm making this in Notepad++ and am utterly out my depth and reminding myself why I quit this search several times before, I can feel my brain melting, despite it probably being the easiest thing to do, no idea if i need "using system," using system.IO," whether I need public class or vegas class, tried all manner of permutations, myvegas, no idea what they all do or why they're needed....

I did try and look for your website to see if I could reverse engineer your script for opening multiple projects and rendering them but I'm guessing the site is no longer online. (EDIT - now it's appearing, strange!)

I don't feel this is worth the stress of stabbing in the dark and getting nowhere, but I'm sure if I quit, I'll just try looking again at some point in the future, after becoming repeatedly frustrated in the knowledge that there's a simpler workflow I could be using, but have now already wasted entire days looking for, reverse engineering, or asking about, when all it would save me is a litle extra navigation in the file menu, albeit every....single...time...

jetdv wrote on 10/26/2022, 11:35 AM

The very first VEGAS tutorial is where we created the base "Class1.cs" that I've used in virtually all subsequent tutorials. Take a look at this tutorial (pause around 12:13 to see the full base script which simply shows the VEGAS version):

Naturally, you would name yours something besides "Class1" so that it makes sense for what you're trying to do. But it will be a .cs file as we are using CSharp in these tutorials. So you could name it something like "Open HDMS01.cs"

So any code you see in the majority of the tutorials  would need all of this surrounding code as well as the part discussed in the tutorial.

//Other "using" lines may be needed. The tutorial shows several more
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;
            myVegas.OpenProject("E:\\vegas projects\\HDMS Templates\\HDMS01.veg");
        }
    }
}

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

You can also change "Test_Script" and "Class1" so the script makes more sense for what you're trying to do:
 

using ScriptPortal.Vegas; 

namespace OpenTemplate 

{ 

    public class OpenVegasTemplate

    {

        public Vegas myVegas;

        public void Main(Vegas vegas)

        { 

            myVegas = vegas; 

            myVegas.OpenProject("E:\\vegas projects\\HDMS Templates\\HDMS01.veg"); 

        } 

    } 

} 

public class EntryPoint 

{ 

    public void FromVegas(Vegas vegas) 

    { 

        OpenTemplate.OpenVegasTemplate OVT= new OpenTemplate.OpenVegasTemplate(); 

        OVT.Main(vegas); 

    } 

}

Look next Monday on my YouTube channel/website for a full tutorial on how the script can open a dialog showing the content of the template folder (i.e. E:\\vegas projects\\HDMS Templates\\) and allow you to select the desired template in that folder so you only need one script to choose any template.

torpex wrote on 10/26/2022, 12:58 PM

YEEEEESSSS!!!
It worked!!!
Thank you so so much!
That dialog with options sounds handy too, I'll check that out, much appreciated!
I've been wondering how to make that script for years, now I can finally use them, cheers for your help!

jetdv wrote on 10/26/2022, 1:57 PM

@torpex, you've inspired the next two tutorials. On Oct 31 will be the tutorial that shows how to choose a template from a specific folder and on Nov 7 will be a tutorial answering the question - you've shown me code in the tutorial; what else is needed?