Dies ist eine alte Version des Dokuments!


Python Scripting for VEGAS Pro

Debugging using WING Python IDE

Debugging with Visual Studio is still possible but not recommended anymore.

I recommend the Wing Python IDE https://wingware.com/.

There is a free version (WING IDE Personal) for non-comercial use and a professional version available.

For debugging Pythondeo with WING IDE please follow following steps:

  1. copy the file wingdbstub.py from the wing IDE program directory to the VEGASPython_PN directory, where your VEGASPython code is located.
  2. add the following line at the begin of theh python code: „import wingdbstub“
  3. Turn on listening for externally initiated debug connections in Wing, which is most easily done by clicking on the bug icon in the lower left of the main window and selecting „Accept Debug Connections“ in the popup menu that appears.

Load the Python Script into Wing IDE and set breakpoints.

Start the script from VEGAS menu. (It is not possible to debug interactive scripts from the interactive window)

When you do changes to the script VEGAS needs to be restarted as a scripts are automatically precompiled when the are used the first time and as long VEGAS is runningit will execute the already loaded code!

Debugging of Scripts with Visual Studio 2017

This section was only valid for the older VEGASVPython Versions below 0.90 based on IRONPython. As there is an easier possibility to debug Python scripts with Wing Python IDE I did not check if debugging with VISUAL Studio is still possible and how to install it. It should be…

The interactive VEGASPython Window is only foreseen for very short scripts needing a few lines. For longer scripts it is proposed to use a Python Script Editor that supports the writing of Python code. But this is not all. It is very unusual that the script you have written is working correctly from the start. There are always small things that are wrong - especially simple typos or logical flow errors.

As PYTHON is an interpreted language, most erros can only be found when the script is executed.

This seems to be a disadvantage. But: Due to the interpretation of the script at runtime the turn arround times frem chnaging the script to seeing the results or error is much faster than in other languages.

Especially the startup time of VEGAS and opening a test project can take a lot of time.

With VEGASPython, Vegas stays open with the test project all the time. You only have to restart the script for testing after you updated it.

It may be surprising but the best support for VEGASPython editing and debugging is provided by Microsoft Visual Studio 2017 (this is the current version). You can use the free community version of Visual Studio 2017. And with Python you can use Visual Studio as a simple editor and debugger. You do not have to deal with all the other complex development project setups.

Visual Studio Installation

Here is what you have to do to setup your editing system for VEGASPython:

  1. Download Microsoft Visual Studio 2017 community edition: https://visualstudio.microsoft.com/de/downloads/
  2. Install Visual Studio
  3. When the Installer asks: which development invironment should be installed? - select „Python“ (if you want to use other environemnts too, feel free to add them)
  4. Take for all other questions the standard answer

Editing Python Files with Visual Studio

Open Visual Studio

A Window like the following one will open:

If you are not familiar with Visual Studio, this start page may overload you. With Python you do not have to bother with creating a project and define all the parameters. We will use Visual Stduio only as an Editor.

So the only step we are doing: We go to the „File“ Menu and open an existing Scripfile or create a new Scripfile. New scripts I usually place in the „Test“ subdirectory of VEGASPYTHON. So the new script shows up in Vegas in the scrit submenu „Test“.

In this example we select the file test.py that is located in the sub-directory „test“ of the VEGASPython directory.

After opening the file, you can edit the file now in the Visual Studio Editor.

Debugging Python Files with Visual Studio

Visual Studio can do much more for us that only editing the script. You can set breakpoints at every line of the script by clicking at the front of the line.

To start the debugging, start VEGAS and load your test project.

When VEGAS is started, we now have to tell Visual Studio, which program it has to monitor. We do this by opening the „Debug“-Menu and select the menu entry „Attach to process“. The following window opens:

Search in this wondow for „Vegas160.exe“ or similar depending on the Vegas version you are running. Select it and click on the „Attach“-Button.

From now on Visual Studio monitors what Vegas is doing.

When we look into Visual Studio it shows now the break points with an empty circle. This shows that the script was not started yet.

Now we can start the „test“ Script. We open it the same way we open all Python scripts.

When the script started and we have set a break pint in the script, Visual Studio stops the script, when the script reaches the breakpoint.

With the key „F10“ we can now setp through the script.

And we can even inspect variables. But unfortunately this inspection is only possible for local variable in functions.


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