by Al Hart » Fri Sep 24, 2010 5:49 pm
I have created a ruby script which overrides the Ruby Console, and writes its messages to a file, and flushes each message as itr is written. If you ever have a problem where ruby files are not loading properly when you start SketchUp, this may help you debug them. Place this ruby script in the plugins folder, and it should create a file called c:\tmp\ruby_trace.txt which contains all of the messages which are sent to the Ruby Console (whether the Ruby Console is open or not). Sample OutputC:\tmp>type ruby_trace.txt
Fri Sep 24 00:51:28 -0600 2010 SketchUp Version: 8.0.3117 ----- Console messages are going to c:\tmp\ruby_trace.txt -----
If you want to trace ruby files as they are loaded, you could place this line at the top of each .rb file, which does not already print its file name. - Code: Select all
printf("***** Loading: %s\n",__FILE__)
[EDIT: Revised script for mkdir error] [EDIT: 5/1/2011 - added timestamp for messages] [Edit: 5/4/2001 - added machine independent code for file location] Latest Version 5/4/2011: !trace_console.rb (I want to apologize in advance for posting the same script to two SCF forums )
Please, register (free) to access all the attachments on the forums.
Last edited by Al Hart on Wed May 04, 2011 7:58 pm, edited 3 times in total.
-

Al Hart
- Render Plus Systems
-
- Posts: 1491
- Joined: Sun Nov 18, 2007 3:54 pm
- Location: Centennial, Co
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by sahi » Fri Sep 24, 2010 7:38 pm
 Thanks PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir
-
sahi
-
- Posts: 132
- Joined: Wed Nov 14, 2007 4:55 pm
- Location: Russia
- Operating system: Windows
- SketchUp version: pre-6
- License type: Free
- SketchUp use: architecture
- Level of SketchUp: Beginner
-
by TIG » Fri Sep 24, 2010 8:16 pm
sahi wrote::thumb: Thanks PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir
It's even better as Dir.mkdir(sdir) - then you don't those kind of typo make mistakes... It's also the future-proof coding method - the 'without-parenthesis' method might be deprecated soon...
TIG
-

TIG
- Global Moderator
-
- Posts: 13987
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Al Hart » Fri Sep 24, 2010 8:17 pm
sahi wrote::thumb: Thanks
PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir
AArrggh: Thanks sahi and thanks TIG
-

Al Hart
- Render Plus Systems
-
- Posts: 1491
- Joined: Sun Nov 18, 2007 3:54 pm
- Location: Centennial, Co
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by sahi » Fri Sep 24, 2010 9:41 pm
TIG wrote: () It's also the future-proof coding method - the 'without-parenthesis' method might be deprecated soon...
Thanks TIG.
-
sahi
-
- Posts: 132
- Joined: Wed Nov 14, 2007 4:55 pm
- Location: Russia
- Operating system: Windows
- SketchUp version: pre-6
- License type: Free
- SketchUp use: architecture
- Level of SketchUp: Beginner
-
by sahi » Sat Sep 25, 2010 11:04 pm
Sometimes it is necessary to compare as was and as became It is possible to add here such code - Code: Select all
ffile1 = "c:\\tmp\\1_ruby_trace.txt" if(File::exists?(@sfile)) if (File::exists?(ffile1)) File.delete(ffile1) end File.rename(@sfile, ffile1) end #if ffile
-
sahi
-
- Posts: 132
- Joined: Wed Nov 14, 2007 4:55 pm
- Location: Russia
- Operating system: Windows
- SketchUp version: pre-6
- License type: Free
- SketchUp use: architecture
- Level of SketchUp: Beginner
-
by Al Hart » Mon May 02, 2011 6:18 am
Your script is working great for me! Just that timestamp needs to be logged with each console message.
I made a version with an optional parameter which will show the date and time for each message. The new version is in the initial post for this thread. - Code: Select all
# comment one of these out to add time to traces @show_time = true #@show_time = false
Here is output with timestamp: Console messages from: !trace_console.rb Sun May 01 23:14:29 2011 SketchUp Version: 8.0.4811 Sun May 01 23:14:29 2011: ----- Sun May 01 23:14:29 2011: Sun May 01 23:14:29 2011: Console messages are going to c:\tmp\ruby_trace.txt Sun May 01 23:14:29 2011: Sun May 01 23:14:29 2011: -----
Last edited by Al Hart on Wed May 04, 2011 8:00 pm, edited 1 time in total.
-

Al Hart
- Render Plus Systems
-
- Posts: 1491
- Joined: Sun Nov 18, 2007 3:54 pm
- Location: Centennial, Co
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by fredo6 » Wed May 04, 2011 7:13 pm
Al, You should make your code portable on Windows and Mac - Code: Select all
tmpdir = (RUBY_PLATFORM =~ /darwin/i) ? "/tmp" : ENV["TEMP"] @sfile = File.join tmpdir, "Trace_Ruby.tmp"
This also avoids calling mkdir (since the tmp directories always exists) Fredo
-
fredo6
- Top SketchUcator
-
- Posts: 1666
- Joined: Mon Nov 12, 2007 9:07 pm
by Al Hart » Wed May 04, 2011 7:55 pm
I'll make the change. The only thing I hate is that it is often difficult to find the real temp folder on Windows, Typing in %TEMP% in Windows Explorer will find it, but I don't know if everyone knows that. Fredo6 wrote:Al, You should make your code portable on Windows and Mac - Code: Select all
tmpdir = (RUBY_PLATFORM =~ /darwin/i) ? "/tmp" : ENV["TEMP"] @sfile = File.join tmpdir, "Trace_Ruby.tmp"
This also avoids calling mkdir (since the tmp directories always exists) Fredo
-

Al Hart
- Render Plus Systems
-
- Posts: 1491
- Joined: Sun Nov 18, 2007 3:54 pm
- Location: Centennial, Co
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by driven » Wed May 04, 2011 8:45 pm
Hi Al,
I've been using this on a mac since you first posted it.
It took a day to find the .tmp file even though I always have hidden 'off' by default.
so I named your script auditMac.rb, made a plugins/folder put an empty text file in it like so.
@sfile = "/Library/Application\ Support/Google\ SketchUp\ 8/SketchUp/plugins/audit_mac_ruby/audit.txt "
it works great I drop auditMac.rb in the folder when I'm not having problems and put it out when needed.
your script just updates from the previous, so I just pull of copies if I need a log. I also park suspect rubies in the folder if I'm trouble shooting...
easy to find and use
john
-
driven
- Top SketchUcator
-
- Posts: 1409
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Wed May 04, 2011 9:39 pm
Finding a suitable 'temp' folder location is easy... tdir=ENV["TEMP"] tdir=ENV["TMPDIR"]if not tdir ### it's a Mac ? So 'tdir' is the path to the 'temp; directory for that user...
To make the full path to a temporary file use... tfile=File.join(tdir, tfilename)
TIG
-

TIG
- Global Moderator
-
- Posts: 13987
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by dburdick » Thu May 05, 2011 4:38 am
Very nice workin indeed Al. I'm still having issues re-directing error output to the log file. It seems as though Sketchup does not use stderr for error output. I've had some success just trapping messages in the Excpetion class StandardError but this is clumsy.
-
dburdick
- e-on software
-
- Posts: 81
- Joined: Wed Feb 03, 2010 5:49 am
- Name: Dave Burdick
by maricanis » Mon Jun 25, 2012 10:51 am
Hi,
I'm using latest version (from may 2011) and noticed strange problem. When I have plugin wxSU installed and !trace_console.rb, while Sketchup is running - no problems, and CPU usage is as expected. When I try to exit Sketchup,SU window is closed but Sketchup.exe process is not finished, and it uses maximal CPU load (when checked in TaskManager). ##########
If only one of these 2 plugins wxSU and !trace_console.rb is installed Sketchup process is ended without problems.
#### It seems that writing to text file is blocked for some reason, and trace file can't be closed.
I'm using SU 7.1 and 8, on Windows 7.
Marija
-
maricanis
-
- Posts: 12
- Joined: Fri Jun 26, 2009 10:20 am
- Name: maricanis
by Ad Machine » 5 minutes ago
Not a Premium Member yet? Check out the great time-limited deal we are offering.
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|