Need Some Help

SimpleMoney wrote on 12/17/2003, 7:47 AM
I'm trying to run some very simple code, but keep getting the error: "Error has been thrown by the target of an invocation"

I know I haven't set my variable 'evnt' to the project, but don't know how. Also, does anyone know the calculation for converting a double to a timecode?

Thanks!

Here's the code I'm using (it's VBScript) - I'll spare you the imports section:

Public Module MainModule

Public Sub Main()
Dim evnt As TrackEvent
Dim myStart As Double
Dim myEnd As Double

myStart = 1500
myEnd = 3000

evnt.AdjustStartLength(New Timecode(myStart), New Timecode(myEnd), False)

End Sub

End Module

Comments

jetdv wrote on 12/17/2003, 8:28 AM
You haven't even set the event to an actual event on the timeline. Right now, "evnt" does not exist as a true event. Did you try somethine like this?


Dim anEnum As IEnumerator
anEnum = VegasApp.Project.Tracks.GetEnumerator
While anEnum.MoveNext 'Loop through the tracks
Dim EventEnum As IEnumerator
EventEnum = CType(anEnum.Current(), SonicFoundry.Vegas.Track).Events.GetEnumerator
While EventEnum.MoveNext 'Loop through Events
Dim evnt As SonicFoundry.Vegas.TrackEvent
evnt = CType(EventEnum.Current, SonicFoundry.Vegas.TrackEvent)
evnt.AdjustStartLength(New Timecode(myStart), New Timecode(myEnd), False)
End While
End While
SimpleMoney wrote on 12/17/2003, 8:47 AM
Thanks, it worked. AdjustStartLength is NOT what I need to use. The API is not helping me figure out what I need, so if I tell you what I'm trying to do, could you lead me in the right direction.

I want to create a new file that starts at X time and ends at Y time.

The AdjustStartLength (which I thought would do that) - does not. My file length did not change one bit when I ran the script (which I would like to thank you again for).

I wouldn't need this help if I knew the DLL that .NET needed to pull up Intellisense, because I would know what methods and events were being used by Vegas.

Thanks again.
jetdv wrote on 12/17/2003, 9:18 AM
Have you looked Here?

Specifically, you should look at:
2.4: How do I add a specific file on the currently selected track in the current position?

This will get the clip ONTO the timeline and by changing "stream.Length" in the "New VideoEvent" line you can specify the length.

I also have some scripting information in my newsletter.