Question

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:

  • Execute step by step inside SketchUp
  • Get an execution stack when a plugin crashes SketchUp
  • Any other idea that woul be helpfull to debug ruby plugins in this context
Was it helpful?

Solution 2

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

OTHER TIPS

SketchUp released an open source debugger for the SketchUp Ruby API on April 15th, 2014:

https://github.com/SketchUp/sketchup-ruby-debugger

It looks like the SketchUp folks released a new unit testing framework in October 2014. I've not tried using it yet, but will give it a shot and report back with what I find:

https://github.com/SketchUp/testup-2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top