Run a script from inside a script?

roger_74 wrote on 3/3/2003, 4:52 AM
Is there any way to run a script from a script?

I've tried this:


import SonicFoundry.Vegas;

var scriptHost : SonicFoundry.Vegas.ScriptHost = new SonicFoundry.Vegas.ScriptHost();
scriptHost.RunScriptFile("c:\\vegas\\scripts\\simple.js");
scriptHost.Close();


It works once. The second time I run it I get this error 13 times in a row and then the script runs as usual.

"An error occurred while processing the undo buffer. You should save your work immediately using a new project filename and restart Vegas.

The reason for the error could not be determined."

Comments

SonyPJM wrote on 3/3/2003, 9:03 AM

The ScriptHost was not intended to be used that way. It is meant only
to be created by Vegas and, accordingly, is not included in the
docs.

You probably could, however, create your own instance of an
IVsaEngine. Then you could Compile() and Run() another script... but
all that can get fairly involved. What's your overall goal? Maybe
you could just create an assembly and call it from within your script.
roger_74 wrote on 3/3/2003, 10:34 AM
I want to allow the user to optionally have a Settings script pop up when they run a script.

Some users want to change settings each time, and some users want to just run the script.
roger_74 wrote on 3/6/2003, 3:22 AM
I tried the IVsaEngine thing... It worked but the files I ran did not get access to the Vegas namespace, so it's no better than using precompiled assemblies.
SonyPJM wrote on 3/6/2003, 8:53 AM
You need to add a reference item (IVsaReferenceItem) to the SonicFoundry.ScriptHost.dll which is located in the same directory as Vegas40.exe... make sure you set the item's AssemblyName property to the full path to SonicFoundry.ScriptHost.dll since it is not in the GAC.

You may also need to add a reference item to the Interop.VegasCOM.dll since that is referenced by classes in the ScriptHost dll.