The only tip I got to debug ruby plugins in SketchUp is the use of puts
.
I tried to launch SketchUp this way: sketchup.exe > log.txt 2> errors.txt
, but it only shows logs / errors from SketchUp app, not from its plugins.
Does anyone knows how to:
Update: As of SketchUp 2014 you can use Ruby IDE's to step through Ruby code. Follow the instructions at this GitHub repository: https://github.com/SketchUp/sketchup-ruby-debugger
No more puts
debugging!
TBD has written and released a bridge to debug SketchUp Ruby plugins: http://labs.plugins.ro/
That's probably what you're looking for. I haven't used it myself yet - so can't elaborate too much on it.
I often use a call to the WIN32 api to OutputDebugString
which allows me to see the output (in DebugView) I send to it regardless if SU craches - and it doesn't slow down the execution as much as outputting lots of stuff to the SketchUp Ruby Console:
http://www.thomthom.net/software/sketchup/tt_lib2/doc/TT.html#debug-class_method
(I meant to give a direct link to the BitBucket source code, but the site is down a the moment. Repo: https://bitbucket.org/thomthom/tt-library-2/ ) EDIT: Site back online - direct link: https://bitbucket.org/thomthom/tt-library-2/src/tip/TT_Lib2/debug.rb?at=Version%202.8
One could also reroute puts
to OutputDebugString
if you wanted a quick catch all solution.
On a slight sidenote, there is also the Developers Tools utility released by the SketchUp team with an enhanced Ruby Console and unit test framework: https://github.com/SketchUp/sketchup-developer-tools