Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Extension vs. Script

  • Extension vs. Script

    Posted by Karl Goldshmidt on June 3, 2008 at 12:23 am

    Mornin all…

    I’m trying to do some evaluation of Sony’s scripting capabilities. Have some initial stuff that worked as a script, but for some reason, things are not working if I run them as an extension. A simple example is:


    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Windows.Forms;
    using Sony.Vegas;

    namespace Media_Test
    {
    public class EntryPoint
    {
    public void FromVegas(Vegas vegas)
    {
    MessageBox.Show("Script Start...");

    //String tNewFile = "G:/project_TEST/00_Layout/avis/Sc062_S0004.00.avi";
    String tNewFile = "G:\\project_TEST\\00_Layout\\avis\\Sc062_S0004.00.avi";
    Media m = new Media(tNewFile);

    MessageBox.Show("Script End...");
    }
    }
    }

    works fine as a script, but if I modify it as an extension:


    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.Drawing;
    using System.IO;
    using System.Reflection;
    using System.Windows.Forms;
    using Sony.Vegas;

    namespace Media_Test2
    {
    public class Media_Test2 : ICustomCommandModule
    {
    protected Vegas myVegas = null;

    public void InitializeModule(Vegas vegas)
    {
    myVegas = vegas;
    myVegas.AppDeactivate += new EventHandler(myAppDeactivate);
    }

    void myAppDeactivate(Object sender, EventArgs args)
    {

    }

    public ICollection GetCustomCommands()
    {
    CustomCommand myToolCommand = new CustomCommand(CommandCategory.Tools, "Media_Test2");
    myToolCommand.DisplayName = "Media Test Two";
    myToolCommand.Invoked += this.HandleInvoked;
    return new CustomCommand[] { myToolCommand };
    }

    void HandleInvoked(Object sender, EventArgs args)
    {
    MessageBox.Show("Script Start...");
    string tNewFile = "G:/project_TEST/00_Layout/avis/Sc062_S0004.00.avi";
    MessageBox.Show(tNewFile, "tNewFile");
    try
    {
    Media m = new Media(tNewFile);
    }
    catch (Exception e)
    {
    myVegas.ShowError(e);
    }
    MessageBox.Show("Script End...");
    }
    }
    }

    I get COM errors like:

    System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
    at Sony.Vegas.IMediaCOM.AddToPool(String path, Boolean addToProperBin, UInt32& mediaID, MetaPathType& metaPathType)
    at Sony.Vegas.Media..ctor(String path)
    at Media_Test2.Media_Test2.HandleInvoked(Object sender, EventArgs args)

    I’m at a loss at this point at what I am forgetting (though I bet its something simple…)

    Configuration is Sony Vegas 8.0b (build 217) running on Microsoft Windows XP Professional x64 SP2 on Dual Core AMD Opteron 2.41GHz and 4G ram.

    TIA,
    krash

    P.S. side note – I notice if I pass in a media path (to the script) that uses “/” for the path, I get the whole path as the media name, where if I use “\\”, I just get the media file name…

    Karl Goldshmidt replied 17 years, 11 months ago 3 Members · 3 Replies
  • 3 Replies
  • Edward Troxel

    June 3, 2008 at 12:53 pm

    You need to use \\ instead of \ or / when assigning the string.

    As for any other possible changes, I don’t have time to look right now.

    Edward Troxel
    JETDV Scripts

  • John Rofrano

    June 3, 2008 at 2:12 pm

    Hi Karl,

    Here is what has changed between scripts and commands. Vegas wraps your entire script in an undo block. It can do this because all processing stops while the script is run. Because custom commands are always available as an extension while the project is being work on, you must declare an undo block yourself in your code whenever you change the project.

    Try adding this to your code:

    void HandleCommandInvoked(Object sender, EventArgs args)
    {
      MessageBox.Show("Script Start...");
      string tNewFile = @"G:\project_TEST\00_Layout\avis\Sc062_S0004.00.avi";
      MessageBox.Show(tNewFile, "tNewFile");
      using (UndoBlock undo = new UndoBlock("Test Command"))
      {
        try
        {
          Media m = new Media(tNewFile);
        }
        catch (Exception e)
        {
          myVegas.ShowError(e);
          undo.Cancel = true;
        }
      }
      MessageBox.Show("Script End...");
    }

    This will stop the error that you are getting.

    ~jr

    https://www.johnrofrano.com/

  • Karl Goldshmidt

    June 3, 2008 at 7:46 pm

    Thanks John,
    I’m sure that is mentioned somewhere in the SDK notes, but I must have missed it. I knew it was going to be something simple.

    Thanks again,
    krash

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy