View previous topic :: View next topic |
Author |
Message |
saxman
Joined: 27 Jan 2008 Posts: 2
|
Posted: Wed Mar 19, 2008 7:50 am Post subject: Media Bin baby steps |
|
|
Hi Edward and crew. I am new to this forumn and new to scripting as well. I studied Fortran in college which is of little help now, but I have been reading two C# books and think that I know enough to start causing trouble. My first attempt at a basic script failed and I was hoping that someone might be able to explain my mistake. This script had the very easy task of just adding a new media bin, but it crashed and I don't understand why. Any help would be greatly appreciated.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Sony.Vegas;
namespace General_Script
{
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
string bin1 = "Bill";
MediaBin billBin = new MediaBin(bin1);
Vegas.Project.MediaPool.RootMediaBin.Add(billBin);
}
}
} |
|
Back to top |
|
 |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5476
|
Posted: Wed Mar 19, 2008 3:01 pm Post subject: |
|
|
On this line:
Vegas.Project.MediaPool.RootMediaBin.Add(billBin);
The "V" in Vegas should be lower-case:
vegas.Project.MediaPool.RootMediaBin.Add(billBin);
In this line:
public void FromVegas(Vegas vegas)
"vegas" is the variable name, "Vegas" is the variable type.
I usually do something like:
public class EntryPoint
{
Vegas myVegas = null;
public void FromVegas(Vegas vegas)
{
myVegas = vegas;
and then use "myVegas" as the variable name from that point forward. |
|
Back to top |
|
 |
saxman
Joined: 27 Jan 2008 Posts: 2
|
Posted: Thu Mar 20, 2008 8:40 pm Post subject: |
|
|
Thanks Edward. I understand the math and logic that I need to do my particular script, but I am really struggling with the syntax,especially in the Vegas API. For instance, in the script above and looking at the Vegas API, under MediaPool Class there is a property RootMediaBin which I used. Also under MediaPool Class, there is a method called Add that says that is not supported, but it worked in my script. So is the Add method that I used the one that is not supported under MediaPool, or does it refer to some other standard Add method?
I know this is asking a lot, but I have one other question. Most of the examples that I have seen for modifying events go through iterations to try and find what track is selected and what event on that track is selected. For my script, what if I know exactly the track that I want to add media to and it will always be track 3. Is there a simple way to write to add my media to track 3 without iterating through tracks? Thanks for your insight. |
|
Back to top |
|
 |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5476
|
Posted: Fri Mar 21, 2008 3:08 am Post subject: |
|
|
It's just a matter of proper interpretation. For example, "Add" is not available as a "MediaPool" class because you can't add another "Media Pool". However, you CAN add more BINS so it is available in the "root media bin" which is the bottom-most bin. |
|
Back to top |
|
 |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5476
|
Posted: Fri Mar 21, 2008 3:15 am Post subject: |
|
|
saxman wrote: | I know this is asking a lot, but I have one other question. Most of the examples that I have seen for modifying events go through iterations to try and find what track is selected and what event on that track is selected. For my script, what if I know exactly the track that I want to add media to and it will always be track 3. Is there a simple way to write to add my media to track 3 without iterating through tracks? Thanks for your insight. |
Certainly, you can definitely access tracks directly. For example, this code sets a variable to the third track:
Track myTrack = myVegas.Project.Tracks[2]; |
|
Back to top |
|
 |
|