Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
en:vegas_python_faq [2018/10/27 17:19]
hlinke
en:vegas_python_faq [2020/03/14 16:07] (aktuell)
hlinke [Section 1: General]
Zeile 99: Zeile 99:
 === Is there a way to determine the path of currently running script? === === Is there a way to determine the path of currently running script? ===
  
-<del>Yes, the global variable ScriptPortal.Vegas.Script.File contains the full path of the currently executing script. So if your script needs access to a helper file that resides in the same directory, your code might look like this: +Yes, the filename including the complete path is available in the variable sys.argvIn Python sys.argv is a string list containing the script filename and all commandline argumentsThe script filename is the first string in the list.
-Language: C#+
  
-String scriptDirectory = Path.GetDirectoryName(ScriptPortal.Vegas.Script.File); +So if your script needs access to a helper file that resides in the same directory, your code might look like this: 
-String helperFile = Path.Combine(scriptDirectory, "HelperFile.ext");</del+ 
-This feature will be provide in the next uopdate of VEGASPython.+<code Python> 
 +clr.AddReference("System.IO") // we need System.IO for Path.GetDirectoryName and Path.Combine 
 +import System.IO 
 +from System.IO import * 
 +import sys 
 +scriptDirectory = Path.GetDirectoryName(sys.argv[0]
 +helperFile = Path.Combine(scriptDirectory, "HelperFile.ext") 
 +</code
 + 
 +=== How do I start a script from the commandline? === 
 + 
 +Pythonscripts can be started from the commandline together with VEGAS and commandline parameters can be passed to the script. 
 + 
 +Example: 
 +<code> 
 +C:\Program Files\VEGAS\VEGAS Pro 16.0\vegas160.exe /SCRIPTARGS pythonscriptfilename /SCRIPTARGS arg1 /SCRIPTARGS arg2 
 +</code> 
 + 
 +  * pythonscriptfilename: path and filename of the pythonscriptfile to be executed 
 +  * arg1: any text string as argument1 
 +  * arg2: any text string as argument2 
 + 
 +The number of arguments is not limited. 
 + 
 +The first /SCRIPTARGS must be the script filename. 
 + 
 +Example: 
 +<code> 
 +C:\Program Files\VEGAS\VEGAS Pro 16.0\vegas160.exe /SCRIPTARGS "D:\pythonfile\test.py" /SCRIPTARGS arg1 /SCRIPTARGS arg2 
 +</code> 
 + 
 +If the filename or a parameter include blanks, then the parameter must be enclosed in ´""´.  
 +The pythonscript can access the commandline arguments as it is standard in Python via the variable sys.argv. 
 +This variable contains a list of strings with each argument as a separate string item in the list. 
 +The first item is the scriptfilename. 
 + 
 +The python script: 
 + 
 +<code python> 
 +for arg in sys.argv: 
 +    print (arg) 
 +</code> 
 + 
 +gives as output: 
 + 
 +["D:\pythonfile\test.py","arg1","arg2"]
  
 === How do I add a script to the Scripting menu? === === How do I add a script to the Scripting menu? ===
Zeile 110: Zeile 154:
 You can add a script to the Extension menu (under Vegas' Tools menu) by placing the script in one of the following directories: You can add a script to the Extension menu (under Vegas' Tools menu) by placing the script in one of the following directories:
  
-C:\Users\<username>\Documents\Vegas Application Extensions\VEGASPYTHON\  +  * C:\Users\<username>\Documents\Vegas Application Extensions\VEGASPython_PN\  
-C:\Users\<username>\AppData\Local\VEGAS Pro\14.0\Application Extensions\VEGASPYTHON\   +  C:\Users\<username>\AppData\Local\VEGAS Pro\14.0\Application Extensions\VEGASPython_PN\   
-C:\Users\<username>\AppData\Roaming\VEGAS Pro\14.0\Application Extensions\VEGASPYTHON\  +  C:\Users\<username>\AppData\Roaming\VEGAS Pro\14.0\Application Extensions\VEGASPython_PN\  
-C:\ProgramData\Vegas Pro\14.0\Application Extensions\VEGASPYTHON\    +  C:\ProgramData\Vegas Pro\14.0\Application Extensions\VEGASPython_PN\    
-C:\Users\<username>\AppData\Local\Vegas Pro\Application Extensions\VEGASPYTHON\  +  C:\Users\<username>\AppData\Local\Vegas Pro\Application Extensions\VEGASPython_PN\  
-C:\Users\<username>\AppData\Local\Vegas Pro\Application Extensions\VEGASPYTHON\  +  C:\Users\<username>\AppData\Local\Vegas Pro\Application Extensions\VEGASPython_PN\  
-C:\ProgramData\Vegas Pro\Application Extensions\VEGASPYTHON+  C:\ProgramData\Vegas Pro\Application Extensions\VEGASPython_PN
  
-You must use the subdirectoy VEGSAPYTHON in the same directory where you installed the VEGASPYTHON.dll.+You must use the subdirectoy VEGASPYTHON in the same directory where you installed the VEGASPYTHON.dll.
  
 === How do I add a script to the toolbar? === === How do I add a script to the toolbar? ===
Zeile 132: Zeile 176:
 You can make a custom icon appear for a script you've added to the Scripting menu or toolbar by placing a PNG image in the same folder that contains the script. The PNG file must have the same name as the script with the '.png' extension appended. For example, if the script is named "My Script.cs", the toolbar image should be named "My Script.py.png". The image must be 16 X 16 pixels and must have 32-bit color depth with an alpha channel for transparency. You can make a custom icon appear for a script you've added to the Scripting menu or toolbar by placing a PNG image in the same folder that contains the script. The PNG file must have the same name as the script with the '.png' extension appended. For example, if the script is named "My Script.cs", the toolbar image should be named "My Script.py.png". The image must be 16 X 16 pixels and must have 32-bit color depth with an alpha channel for transparency.
  
-=== How do create and debug a script using a Visual Studio? ===+=== How do create and debug a script using a Visual Studio? ===
  
-You can debug VEGASPython scripts usuing Microsoft Visual Studio 2017 as Editor and Debugger. You dnot have to compile the script or do any fancy stuff.+You can debug VEGASPython scripts usuing Microsoft Visual Studio 2017 as Editor and Debugger. You do not have to compile the script or do any fancy stuff.
 Please see the page [[en:debugging_of_scripts_with_visual_studio_2017|debugging_of_scripts_with_visual_studio_2017]] Please see the page [[en:debugging_of_scripts_with_visual_studio_2017|debugging_of_scripts_with_visual_studio_2017]]
  
Zeile 156: Zeile 200:
 ==== Section 2: Tracks and Events ==== ==== Section 2: Tracks and Events ====
  
-=== How do access the VEGAS attributes? === +=== How do access the VEGAS attributes? === 
-VEGASPython provides a variable pyVEGAS that is from the type VEGAS and provides the interface to all VEGAS internal data structures. You can find details of the data structures in the VEGAS Scripting API.+VEGASPython provides a variable pyVEGAS which is of the type VEGAS and provides the interface to all VEGAS internal data structures. You can find details of the data structures in the VEGAS Scripting API.
  
 Example: Example:
Zeile 283: Zeile 327:
 </code> </code>
  
-=== How to I make a script modify the text string in a text event? ===+=== How do I make a script modify the text string in a text event? ===
  
 You can't. Currently, one major shortcoming of the scripting API in VEGAS is that specific parameters of video effects are not accessible to scripts. The text string of text generators are one such parameter. Scripts can only set presets values for a given key frame. You can't. Currently, one major shortcoming of the scripting API in VEGAS is that specific parameters of video effects are not accessible to scripts. The text string of text generators are one such parameter. Scripts can only set presets values for a given key frame.

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