I'm not sure I understand what you mean... Maybe i'm not competely with you on the terminology.
First I thought "What does Takes have to do with this" and then I realized I don't think I know what a take is:) But from what I think now.. if I splitt an Event I will get a Take?? and then I guess I'm not sure what you mean anyway.
What do you mean by removing the takes.. before the event?
Yes. I'm not sure if it works without deleting the takes. You can try it and see and let us know :-). Also remember there is ALWAYS one take (the original clip) there just may be more than one.
This is sort of long but I need to explain it in order to make you understand my problem.
I actually have problems doing this... don't know why really. I don't understand what's going wrong cause I'm not really done with the splitting thing (have'nt come to the deleteing yet)
Public Sub Main()
CutOutFrames(GetInputValue())
End Sub
Public Function GetInputValue() As Long
'prompt User For Input
Dim InputValue As String
InputValue = InputBox("Type the number of frames you want to remove in the strobeffect (higher number will create slower effect)")
Try
GetInputValue = CLng(InputValue)
Catch objE As Exception
MessageBox.Show("Input was not a valid number", "Oops!")
GetInputValue = 0
End Try
End Function
Public Sub CutOutFrames(ByVal NumberOfFrames As Long)
Dim EndFrame As Long
Dim FrameCounter As Long
Dim anEnum As IEnumerator
Dim SelectedTracks As Integer
Dim SplitTimeCode As New SonicFoundry.Vegas.Timecode()
anEnum = VegasApp.Project.Tracks.GetEnumerator
While anEnum.MoveNext 'Loop through the tracks
If CType(anEnum.Current(), SonicFoundry.Vegas.Track).IsVideo Then
Dim EventEnum As IEnumerator
EventEnum = CType(anEnum.Current(), SonicFoundry.Vegas.Track).Events.GetEnumerator
While EventEnum.Movenext 'Loop through Events
Dim TrackEvent As SonicFoundry.Vegas.TrackEvent
TrackEvent = CType(EventEnum.Current, SonicFoundry.Vegas.TrackEvent)
If TrackEvent.Selected Then
EndFrame = (GetStartFrame(TrackEvent) + GetLength(TrackEvent))
For FrameCounter = GetStartFrame(TrackEvent) To EndFrame Step NumberOfFrames
SplitTimeCode.FrameCount = FrameCounter
MsgBox("start: " & CStr(GetStartFrame(TrackEvent)) & vbcrlf & "EndFrame: " & CStr(EndFrame) & vbcrlf & "FrameCount: " & CStr(SplitTimeCode.FrameCount))
TrackEvent.Split(SplitTimeCode)
Next
'Exit While
End If
End While
End If
End While
End Sub
Private Function GetLength(ByVal TrackEvent As SonicFoundry.Vegas.TrackEvent) As Long
Return TrackEvent.Length.FrameCount
End Function
Private Function GetStartFrame(ByVal TrackEvent As SonicFoundry.Vegas.TrackEvent) As Long
Return TrackEvent.Start.FrameCount
End Function
End Module
------------------------------------------------------------------------
The problem is somewhere in the WHILE and FOR loop I guess. The problem is this.
I have remarked the row with the "EXIT WHILE" cause it did'nt help me. But if you want to try you can see the difference with remarking that row and not remark it.
The Result:
I get the input from the user and want to splitt every [input number] frame but for some reason it only splits once, as if the FOR loop does'nt work, OR if I remark the EXIT WHILE.. I will get a really weired result where I splitt once and then it loops to the next event (since I splitt it) and splitt that once and etc... and I can't see why I don't splitt the selected Event several times instead... I guess I need to refere to the event I want to splitt some other way maybe?
You have to be REAL careful when looping on a track in which you are changing the number of events. For example, if you do a while loop deleting events, you will delete the first, third, fifth, seventh... events while leaving events two, four, six, eight.... This is because when you delete an event, the events move down one and then the while loop moves forward one. You are probably running into a similar problem.
Here is how I would probably attack this problem:
1) start at the END and go backwards splitting the main clip at each location.
2) start at the END and go backwards deleting every other clip (using a FOR loop)
I guess I understand that if I have ONE selected Event and then Choose to Splitt it at The StartFrame + 10 Frames. I get Two Selected Events. Then When the While loop moves forward to the next, there's a the new event and I want to splitt that at Startframe + 10 frames... BUT does'nt work.. it splitts at StartFrame + 20 instead and then next StartFrame + 40 and then next StartFrame + 80 etc etc...
--------------------------------------------------------------------------------
While EventEnum.MoveNext 'Loop through Events
Dim TrackEvent As SonicFoundry.Vegas.TrackEvent
TrackEvent = CType(EventEnum.Current, SonicFoundry.Vegas.TrackEvent)
If TrackEvent.Selected Then
EndFrame = (GetStartFrame(TrackEvent) + GetLength(TrackEvent))
SplitTimeCode.FrameCount = GetStartFrame(TrackEvent) + NumberOfFrames
MsgBox("start: " & CStr(GetStartFrame(TrackEvent)) & vbCrLf & "EndFrame: " & CStr(EndFrame) & vbCrLf & "FrameCount: " & CStr(SplitTimeCode.FrameCount))
TrackEvent.Split(SplitTimeCode)
End If
End While
----------------------------------------------
The MSGBOX I show shwo the right info though... And the SplitTimeCode.FrameCount actually tells me the Right frame where it should splitt but the Splitt does not happen there...
Another really weird thing is this too.. the Endframe that I want to print in the MSGBOX says the same the whole time.. is that because ALL the events are selected the whoel time that are involved in the operation?
I did try the backwards looping thing and that did'nt work either... I just don't seem to get this looping and changing the Eventnumer thing...
I really appriciate that you take time to try to help me... must be frustrating:)
okay! Now I have been able to splitt the events at the right locations and now I'm up for the delete thing... I can't find any delete mothods.. I have tried my scritp by using TrackEvent-Mute = True instead and it works as it should but I want to delete the events instea dof Muting them... but how do you delete an event? Can't find any Delete OR Remove Method...
Thank you! The script is now as I wanted it, but it does
nt look the way I wanted but that's my fault, I did'nt really think well on this.. instead of Strobe effect I got flicker... but I guess if that's what you want.. then .. there's a script for it:)
Sorry to raise this thread from its grave, but I'm getting an error when trying to run Lars' script (located at the link below). When I try to run it, Vegas 4 gives me the following error message:
Error on line 54:
'Split' is not a member of 'SonicFoundry.Vegas.TrackEvent'.
Can anyone help me on this? Is it a flaw in the script, or am I doing something wrong on my end? And yes, I've got .NET framework 1.1.
You could also make an array of events you want to delete during the splitloop, and then delete the events in the array with an enumerator that counts from i=array.length-1 to i=0