I have Delphi 7. But running the .NET framework is not built in (I don't think). Is there a simple example program or tutorial on how to access the Vegas Scripting via Delphi?
Although it should be possible technically to use Delphi 7 and compile to .NET, I'd advise to either:
- use JScript or VScript with some simple editor
- import Vegas TypeLibrary (COM) into Delphi project and create native Windows applications controlling Vegas from outside.
I personally chose the first approach - it's a lot of fun.
While I understand that TypeLib may change and become incompatible and such, I did try that approach. Just a proof of concept prototype application. I had an idea in mind to create external app that would allow you to import scanned images (concept illustations), associate media with them (future clips), add comments, and allow you to rearrange. That's storyboard. Than use that TypeLib interface to create project and automate everyhting to timeline.
Doing all this in script? No, thanks.
There is an approach to create a DLL for most of the application with COM interface and import it into script. But my approach above seemed more elegant.
Anyway, the idea of storyboard for Vegas still lives. I'll try DLL + script approach.
Did some more research on this. Delphi 7 includes a .net preview which allows it to work in the .net world but the preview is rather raw. In addition, any components or anything else created for Win32 Delphi will need a good amount of work to compile in the .net version. There is also no IDE at this time. Quick question regarding the design of the scripting. Other than the buzzwords, is there a reason for going to a .NET assembly rather than a straight COM interface?
As for the other question from aboukirev, your best best it using C# or VB.NET. If you don't have the money for Visual Studio, you can get a c# compiler on the internet that looks promising for free. Let me know if you need a link.
> Quick question regarding the design of the scripting. Other than the
> buzzwords, is there a reason for going to a .NET assembly rather than
> a straight COM interface?
We wanted a scripting interface for Vegas with interpreted and/or JIT
compilation of source code. The main reason for .NET is that it is
direction Microsoft is going. In my opinion, it is very nice to have
access to everything in the .NET framework and support for multiple
languages. COM interoperability and pinvoke also provides a nice
"out" when native code is required.
Thanks, Rich. I have all I need for .NET already, including excellent free IDE (SharpDevelop). And I created enough code to feel comfortable with .NET. It was not a question but rather objection to doing a lot of programming in JScript. It may work, I created huge applications in Perl in the past. Nothing wrong with interpreted code. It's more about personal preferences.
Right now it boils down to certain limitations in Vegas API. Some things require too much coding to workaround "missing" pieces in Vegas API.
A good example I'm working on is get a region from Media and "render" it (no effects) to a new file. Cannot create a render preset matching original media format on the fly. I could use DirectX 9 (thanks Microsoft for exposing API directly to .NET) and its "smart" (conservative) renderer mode to do the job (I still don't know if that will work). Theoretically it should just cut out the required piece without rerendering. But who knows...
I really like the power of .NET for scripting, but my main gripe is that C# can't access the vegas objects. I guess this is Microsoft's fault since this is a limitation of VSA, it only uses JScript.NET and VB.NET. Furthermore they seem to be pretty much ignoring JScript.NET when making Visual Studio which just makes it harder for us.
I was able to get the public beta to work with C#, nothing fancy, just polling the current project. This was before the API docs came out. Does the latest version not work well with C#?
You can add a reference to Vegas, but those objects aren't documented. You can't run a C# file directly from Vegas like you can with JScript.NET and VB.NET.
But you can have JScript call your C# assembly which can, in turn, access the same Vegas object model that is exposed to scripts... just pass in a reference to the script's global Vegas object and go from there.
This worked out very well. I thought I'd have to copy SonicFoundry.ScriptHost.dll to where the script was - not a good idea when Vegas is upgraded - but it found it anyway. Through the GAC i suppose.
I've tried this and have the following problem, maybe there is an easier solution to this. I add a reference to both interop.vegascom and sonicfoundry.scripthost in a C# sampel project, The below code works great:
Not rocket science but proves the access works correctly. I try to access anything in the scripthost dll, such as:
SonicFoundry.Vegas.Tracks TestTracks;
SonicFoundry.Vegas.Track NewTrack ;//= new SonicFoundry.Vegas.BusTrack();
SonicFoundry.Vegas.Project MyProject = new SonicFoundry.Vegas.Project() ;
TestTracks = MyProject.Tracks;
TestTracks.Clear();
NewTrack = TestTracks;
NewTrack.Name = "New Video Track";
NewTrack. .MediaType = SonicFoundry.Vegas.MediaType.Video;
TestTracks.Add(NewTrack);
And this compiles, seems to build the objects but any time I try to do any functions such as clear, add track or anything similar, I get an unknown COM error. I also tried adding a track to the current project using the VegasCom object doing something like:
VegasApp.Project_AddTrack(0, ref RefIndex, ref RefIndex2);
It didn't like this because I believe my track type is wrong, are those listed anywhere?
Just curious as to what I am doing wrong. Once, I get past the general connection level, I think I'll be on my way. Maybe a simple, create the objects and add a track to the current project, then add a FX with a keyframe in C#? It would be really helpful.
I believe using COM interop mode is not support so I would stop going down that path. I haven’t tried this yet but SonicPJM said:
> just pass in a reference to the script's global Vegas object and go from there
That says to me that you need a function in your C# code that will accept the Vegas object as a parameter. Then pass the Vegas object from your script to that function. Your function should now be able to manipulate the Vegas object as you would like. I think the key is to start from a script and pass control to the C# code.
Correct. Start from a script and pass the global Vegas object (or Vegas.Project, or whatever) into your C# object. Do not create a VegasCOM object... that is intended for internal use only.
Is there a short example of this. Once I have access tothe Vegas.Project object, I have a general idea of what I need to do. In my C# app, What type of object/call do I setup to allow a jscript vegas scrip pass in the correct object?
So I think I am doing this right but get the error BeanstalkVegasAddon.Class1.EntryFunction does not exist, are you missing an assembly. Here is the code
using System;
using SonicFoundry.Vegas;
using ClassLibrary2;
namespace BeanstalkVegasAddon
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public static void EntryFunction(SonicFoundry.Vegas.Project proj) { // go from here
cFrmMain MainForm ;
MainForm = new cFrmMain();
MainForm.Show();
}
public Class1()
{
//
// TODO: Add constructor logic here
//
}
}
}
Just trying to get a form to popup from a C# app through jscript. The project information uses BeanstalkVegasAddon as the Assembly Name and the Default Namespace. It compiles and within other C# apps, I can see and create objects correctly if I add a reference to the above. My jscript file looks like:
I've put the assembly dll in the directory with the script and also tried putting it into the main vegas directory. Any ideas on why this is not working for me?
using SonicFoundry.Vegas;namespace MyAssembly { public class MyClass { public static void EntryFunction(SonicFoundry.Vegas.Project proj) { // go from here } }}
I have created a Form to that i 're-send' my object of project ( to control it via a window) BUT when i click on a button in window to for example display liste of tracks ... a error occured saying that RCW has destroy my object !!! (garbage collector ?)
my question : how can do to bring my object ALIVE to work with it ? Please help me .