Help for scripting in Visual Studio

srg.steam wrote on 3/23/2007, 3:02 PM
I am a one-time VB programmer, now retired (70). I am upgrading myself to VB.Net. This process is not as bad as I expected. I want to know how I can prepare scripts for Vegas using the intellisense features of the Virtual Studio environment. I can't face trying to do it with no help in a text editor.
I have loaded a reference into a new project and opened a .bas file. I am trying to introduce a constructor to generate an instance of the Sony.Vegas object. This seems to take and to expose a shedload of collections and so on for the Vegas application.
What goes wrong then is that any time I try to refer to the instantiation I get nothing.
Maybe I lost my wits and can't remember how to do it. (probably true). Any help gratefully received with perhaps a small instructive example.

Comments

JohnnyRoy wrote on 3/24/2007, 7:11 AM
You must get the Vegas object passed into your code. You cannot create it in a constructor.

There is a direct entry point which I use in C# but I'm not sure if it works in VB. If it does try doing this: Make a public class named EntryPoint with a public method "public void FromVegas(Vegas vegas)". As I said, this works in C# and avoids having to use JScript and the config file explained below but I'm not sure if it works for VB.

If the EntryPoint.FromVegas(Vegas) call doesn't work, you need to write a little JScript loader that passes the Vegas object to your code. Here is an example:
import System.Windows.Forms;
import Sony.Vegas;
import MyDllNamespace;

try
{
MainEntry.Start(Vegas);
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
In your VB project you create a public static entry point called MainEntry.Start() that accepts the Vegas object. That routine should do whatever it needs to in order to initialize and call your application (e.g., load the main dialog window). Sorry, I can't give you an example but I don't know VB. I do all of my development in C#.

Then you need to make a config file to tell Vegas where to find your VB dll. It should be put in the same location as the JScript file look something like the following:
<?xml version="1.0" encoding="UTF-8" ?>
<ScriptSettings>
<AssemblyReference IsLocal="true">MyVBDll.dll</AssemblyReference>
</ScriptSettings>
The name of this config file is the same as the JScript file with .config after it. So if the JScript file is MyScript.js then the config file is MyScript.js.config.

Debugging:

I'm sure you are going to want to debug your script from with Visual Studio. I don't know if you have this set up yet, but just in case you don't here are the instructions. In the Debug options of Visual Studio under Configuration Properties, make the following changes:

Start Action:
Debug Mode: Program
Start Application: C:\Program Files\Sony\Vegas 6.0\vegas60.exe

Start Options:
Command Line Arguments: -SCRIPT:".\Script Menu\MyScript.js"
Working Directory: C:\Program Files\Sony\Vegas 6.0

Obviously those are the parameters for Vegas 6. Just change everything to point to Vegas 7 if you are using Visual Studio 2005 and Vegas 7. In all of these examples change the MyScript to your actual script name.

Hope this helps,

~jr