software works as script, but not a extension - Vegas 14

Bruggeling wrote on 2/27/2017, 12:45 PM

    LOCAL oProject AS Project
    LOCAL x AS DWORD
     
    oProject:=SELF:oVegas:Project
    
    VAR oSelectedTracks := FROM oTrack AS track IN oProject:Tracks WHERE oTrack:Selected SELECT oTrack
    x:=0
    FOREACH oTrack AS Track IN oSelectedTracks
        FOREACH oEvent AS TrackEvent IN oTrack:Events
            IF oEvent:Selected
                x++
            ELSE
                oEvent:Selected:=TRUE    // gives an error when in an extension !! but works as a simple script ...         
            ENDIF
         NEXT
NEXT

I have the impression that an extension can't change parameters... there must be something that I don't know :-)

programming language = Xsharp a new emerging language I like a lot because it is very readable

The docs to make extensions are very ... lacking, a lot of links leading to nothing (except adds for Vegas)

Main cameras Panasonic S5, still using some FZ1000

Windows 11
Processor AMD Ryzen 7 3700X 8-Core Processor 4.20 GHz
GPU NVidia Geforce RTX 2070 super
RAM 32,0 GB

Main disk M2 2 Terabyte, other disks SSD on SATA, some on USB.

Comments

Gary James wrote on 2/27/2017, 2:01 PM

When you modify a Vegas parameter in an Extension, the code that modifies the parameter must be enclosed within a Vegas UNDO block. Here's a C# example.
 

// this creates an Undo Block Object that is automatically freed as the using block // goes out of scope.

using ( new UndoBlock ( "Text that appears in the Undo dropdown list" ) )
{

// code that modifies a Vegas parameter inside the using block.

// this could be changing a track or event parameter, etc.

}

Bruggeling wrote on 2/27/2017, 2:40 PM

Thank you very very much, that works !

Main cameras Panasonic S5, still using some FZ1000

Windows 11
Processor AMD Ryzen 7 3700X 8-Core Processor 4.20 GHz
GPU NVidia Geforce RTX 2070 super
RAM 32,0 GB

Main disk M2 2 Terabyte, other disks SSD on SATA, some on USB.

Gary James wrote on 2/27/2017, 3:05 PM

Glad to hear this got you working. I'm not familiar with XSharp (or is it X#)? Is this a Microsoft product?

Bruggeling wrote on 2/27/2017, 3:20 PM

X# = Xsharp.

Not a Microsoft product, but based on Microsoft Roslyn. The team building this product is in the process of 'unifying' all dBase-dialects (foxbase, Visual Objects, Vulcan, Alaska...) but the product has gone way beyond the dBase scope. It integrates in Visual Studio and the code (I think) is very readable : this is what I did with the Undoblock (no curly brackets, no semi colons required in this syntax)

    LOCAL oProject AS Project
    
    oProject:=SELF:oVegas:Project
    
    VAR oSelectedTracks := FROM oTrack AS track IN oProject:Tracks WHERE oTrack:Selected SELECT oTrack
    
    VAR oUndo := UndoBlock{oProject,"Track Events Selection"}
    FOREACH oTrack AS Track IN oSelectedTracks
        FOREACH oEvent AS TrackEvent IN oTrack:Events
            oEvent:Selected:=TRUE
        NEXT
    NEXT
    oUndo:dispose()   

Main cameras Panasonic S5, still using some FZ1000

Windows 11
Processor AMD Ryzen 7 3700X 8-Core Processor 4.20 GHz
GPU NVidia Geforce RTX 2070 super
RAM 32,0 GB

Main disk M2 2 Terabyte, other disks SSD on SATA, some on USB.

NickHope wrote on 2/27/2017, 10:51 PM
The docs to make extensions are very ... lacking, a lot of links leading to nothing (except adds for Vegas)

Try some of the links in the Scripting FAQs if you didn't already.

fould12 wrote on 3/10/2017, 10:54 AM

When you modify a Vegas parameter in an Extension, the code that modifies the parameter must be enclosed within a Vegas UNDO block. Here's a C# example.
 

// this creates an Undo Block Object that is automatically freed as the using block // goes out of scope.

using ( new UndoBlock ( "Text that appears in the Undo dropdown list" ) )
{

// code that modifies a Vegas parameter inside the using block.

// this could be changing a track or event parameter, etc.

}


Wait, how did you figure this out? I couldn't find anything in the FAQs or API that said anything about this. How did you learn about this?

Gary James wrote on 3/10/2017, 12:32 PM

Like you, from asking questions in the Vegas forum. The one man I found to be most helpful in answering Vegas scripting questions is Edward Troxel. He's the author of the Excalibur Vegas Extension. He's been writing Vegas scripts and extensions longer than anyone I know. In appreciation for all the help he gave me, if I can pass on that kindness, I'm willing to help others if I can.

jetdv wrote on 3/11/2017, 10:34 AM

Like you, from asking questions in the Vegas forum. The one man I found to be most helpful in answering Vegas scripting questions is Edward Troxel. He's the author of the Excalibur Vegas Extension. He's been writing Vegas scripts and extensions longer than anyone I know. In appreciation for all the help he gave me, if I can pass on that kindness, I'm willing to help others if I can.

Thanks, Gary. It's hard to believe that Excalibur 1 was released 14 years ago in the spring of 2003 for Vegas Pro 4. My how it has changed over the past 1.5 decades.

I do have quite a bit of scripting information on my website at www.jedv.com as well.