The PyWin Debugger is an interactive GUI that allows you to debug scripts running in Softimage using the power of Python debugging. The module that defines it is debugger, which is built on the pdb module (the standard Python debugger).
The PyWin Debugger provides the following debugging tools to help you debug your scripts:
If you are using the recommended pywin32 extension for Python, the PyWin Debugger is already installed and waiting to be invoked. Because it is a Python module, you need to import it before you can use it:
# This loads the debugger module... import pywin.debugger as dbg # This launches the GUI: dbg.brk()
An alternative call to the debugger is:
dbg.set_trace()
Because the PyWin Debugger interacts directly with Softimage you can control Softimage by typing commands in the Interactive Window. For example, if you type Application.LogMessage( "Debug this!" ) in the Debugger's Interactive Window and press Enter, "Debug this!" is logged to the history pane in Softimage.
You can modify the interactive window in the PyWin debugger to have a Softimage object expose all its methods in the auto-complete prompt.
Edit this file: %PythonPath%\Lib\site-packages\pythonwin\pywin\scintilla\view.py and add the following lines in the _AutoComplete function (use the context lines to find out where to put the code):
# The object may be a COM object with typelib support - lets see if we can get its props. # (contributed by Stefan Migowsky) try: # Get the automation attributes items_dict.update(ob.__class__._prop_map_get_) # See if there is an write only property # could be optimized items_dict.update(ob.__class__._prop_map_put_) # append to the already evaluated list except AttributeError: pass # BEGIN ADDED LINES # The object might be a pure COM dynamic dispatch with typelib support - lets see if we can get its props. if hasattr(ob, "_oleobj_"): try: for iTI in xrange(0,ob._oleobj_.GetTypeInfoCount()): typeInfo = ob._oleobj_.GetTypeInfo(iTI) typeAttr = typeInfo.GetTypeAttr() for iFun in xrange(0,typeAttr.cFuncs): funDesc = typeInfo.GetFuncDesc(iFun) funName = typeInfo.GetNames(funDesc.memid)[0] if not items_dict.has_key(funName): items_dict[funName] = 1 except: pass # END ADDED LINES except: win32ui.SetStatusText("Error attempting to get object attributes - %s" % ('sys.exc_info()[0]',))
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License