Dies ist eine alte Version des Dokuments!


VEGASPython for Developers

Introduction

VEGASPython Interactive Window

VEGASPython includes an interactive window. VEGASPython interactive window is activated via the 'View' / 'Extensions' tab.

A VEGAS dockable window opens. The window can float over VEGAS or can be integrated into the VEGAS layout as any other VEGAS window.

The VEGASPython window shows two textboxes:

- Input PYTHON Comands - Output

and a menu with two items „File“ and „Execute VEGASPython Script“.

Python comands are entered in the textbox „Input“. Several lines can be entered one after each other. It is possible to copy a complete PYTHON Script from another editor via CTRL+C and CTRL+V. The PYTHON commands will be executed by clicking on the menu „Execute VEGASPython Script“.

All output from PYTHON print statements and all error messages will be shown in the „Output“ textbox.

VEGASPython is based on Python 3.7.3 and PythonNet.

The VEGAS API can be accessed directly by using the build-in variable „pyVEGAS“. All VEGAS API items are available.

Examples


Example for a simple script that can be used in the interactive window:

  import clr
  clr.AddReference('ScriptPortal.Vegas')
  import ScriptPortal.Vegas
  from ScriptPortal.Vegas import *
  # adapt this value to your needs
  maxLength = Timecode.FromString("00:00:04:00")
  # Go through the list of Tracks
  for track in pyVEGAS.Project.Tracks:
      for evnt in track.Events:
          if (evnt.Selected):
              dLength = evnt.Length
              if dLength > maxLength:
                  dLength = maxLength
              dStart = evnt.Start
              evnt.AdjustStartLength(dStart, dLength, True)

A script that is used as an extension needs to be included in a function FromVegas. See example below.

  import clr
  clr.AddReference('ScriptPortal.Vegas')
  import ScriptPortal.Vegas
  from ScriptPortal.Vegas import *
  def FromVegas(pyVEGAS):
      # adapt this value to your needs
      maxLength = Timecode.FromString("00:00:04:00")
      # Go through the list of Tracks
      for track in pyVEGAS.Project.Tracks:
          for evnt in track.Events:
              if (evnt.Selected):
                  dLength = evnt.Length
                  if dLength > maxLength:
                      dLength = maxLength
                  dStart = evnt.Start
                  evnt.AdjustStartLength(dStart, dLength, True)

Andere Sprachen
QR-Code
QR-Code en:vegas_python_dev (erstellt für aktuelle Seite)