sketchucation logo sketchucation
    • Login
    1. Home
    2. Al Hart
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 348
    • Posts 1,614
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: New Header for Render Plus Forum

      Thanks pixero and solo.

      I really appreciate the help. If I had a good eye for this, then the current image, which I created would have been a lot better. (One of our users took the time to tell me that I really needed to improve it)

      Current header:

      current_logo.jpg

      posted in Corner Bar
      Al HartA
      Al Hart
    • Using printf to help trace ruby errors

      After creating a script to trace ruby output to a file, I thought it might be a good idea to add a trace to every function call, with a line like this:

      printf("FILE; %s; Line; %s\n", __FILE__, __LINE__) if $rps_show_traces
      

      As in:

      def test2(ii)
      	printf("FILE; %s; Line; %s\n", __FILE__, __LINE__) if $rps_show_traces 
      	i1 = 1
      	i2 = i1+1
      	return i2
      end#def
      

      if $rps_show_traces is true, I will get a trace message for every function like this:

      (Does ruby already have anything like this to help trace function calls?)

      FILE: /aa/test (2).rb: Line: 24

      However if $rps_show_traces is not defined, or false, nothing will happen.

      I wondered how much this would slow things down.

      I also wondered it a if/end#if form would be significantly faster.

      if $rps_show_traces ; printf("FILE; %s; Line; %s\n", __FILE__, __LINE__); end#if
      

      So I created a test ruby to execute a function with the second form (if /end#if), the first form (if) and no trace statement at all.

      Sure enough the if/end#if was faster, but after 5,000,000 function calls the time difference, and the time to include a line like this in the source at all, is insignificant.

      if/end#if: elapsed 4.787 seconds
      if only: elapsed 4.678 seconds (.10 seconds faster for 5,000,000 calls)
      no trace: elapsed 4.279 seconds (.40 seconds faster for 5,000,000 calls)

      So, although it would mess up the source code a bit, it would take no significant overhead to include a trace line after each function definition.

      Here is the test routine if anyone wants to try it out.

      
      
      
      def test1(ii)
      	if $rps_show_traces ; printf("FILE; %s; Line; %s\n", __FILE__, __LINE__); end
      	i1 = 1
      	i2 = i1+1
      	return i2
      end#def
      
      def test2(ii)
      	printf("FILE; %s; Line; %s\n", __FILE__, __LINE__) if $rps_show_traces 
      	i1 = 1
      	i2 = i1+1
      	return i2
      end#def
      
      def test3(ii)
      	i1 = 1
      	i2 = i1+1
      	return i2
      end#def
      
      def do_all
      	printf("FILE; %s; Line; %s\n", __FILE__, __LINE__)
      	do_test1
      	do_test2
      	do_test3
      end#def	
      
      def do_test1
      	start = Time.now
      	ii = 0
      	0.upto(5000000) { |ii| test1(ii) }
      	etime = Time.now
      	printf("if/end#if; elapsed %s seconds\n", etime - start)
      	ii
      end#def
      
      def do_test2
      	start = Time.now
      	ii = 0
      	0.upto(5000000) { |ii| test2(ii) }
      	etime = Time.now
      	printf("if only; elapsed %s seconds\n", etime - start)
      	ii
      end#def
      
      def do_test3
      	start = Time.now
      	ii = 0
      	0.upto(5000000) { |ii| test3(ii) }
      	etime = Time.now
      	printf("no trace; elapsed %s seconds\n", etime - start)
      	ii
      end#def
      
      
      posted in Developers' Forum
      Al HartA
      Al Hart
    • New Header for Render Plus Forum

      I ran a crowdspring competition to design a new header for the Render Plus forum: http://irendernxt.com/

      Here are the entries: Header Entries

      Take a look and let me know 1-5 that you think would be good. Then I will try to select 5 finalists and we can choose again.

      If you designed some of the headers yourself, or if you like one because it contains one of your own images, then vote for at least one which is not based on your own work.

      Here is one sample: (There are quite a few more on the Header Entries page)

      image045.png

      Most people chose our existing logo, and added an image from the gallery.

      Some of the entries include ideas for a different color for the area to the right and left of the forum, and/or different colors for tab bars. Keep that in mind as we select the finalists.

      Use the one or two letter code above the entry to identify the one you like. (e.g. AA)

      Some entries contain more than one banner, if so refer to them as AA-1, AA -2, AA-3, etc.

      Either reply to this thread with your preferences, or email me directly at al.hart@renderplus.com

      posted in Corner Bar
      Al HartA
      Al Hart
    • RE: [Plugin] Trace Ruby messages

      @sahi said:

      :thumb: Thanks

      PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir

      AArrggh: 😑

      Thanks sahi and thanks TIG

      posted in Plugins
      Al HartA
      Al Hart
    • [Plugin] Trace Ruby messages

      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 Output

      C:\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.

      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 πŸ˜‰ )

      posted in Plugins
      Al HartA
      Al Hart
    • RE: Writing Ruby Console messages to a text file

      I had place an underscore at the front of the ruby file name, (_trace_ruby.rb), so it would run before other ruby files.

      But I was confused. It turns out the _ comes after a-z in sort order, so I changed it to !trace_ruby.rb so it would come first.

      I wanted to make sure that it caught printf's and puts's from other .rb files in plugins, so I created !r.rb with prints "!R" and !u.rb which prints "!U", and sure enough, !R did not trace to the file, but !U did.

      I have updated the script in the original post, and also added the $stderr stuff as suggested by Jim

      C:\tmp>type ruby_trace.txt
      Fri Sep 24 09:53:21 -0600 2010
      SketchUp Version: 8.0.3117

      Console messages are going to c:\tmp\ruby_trace.txt

      !U

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Writing Ruby Console messages to a text file

      @thomthom said:

      I might have the perfect candidate for testing. I experience crash without bugsplat with a script in some unknown condition.

      Let me know how it goes.

      You can add:

      printf("FILE; %s LINE; %s\n", File.basename(__FILE__), __LINE__)
      

      after almost every line in the ruby file to trace down the bug splat.

      (Or if someone knows another good way to trace ruby files, let me know)

      Al

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      All this work trying to redirect output led me to come up with a ruby script which will redirect output, and flush the output file.

      See: http://forums.sketchucation.com/viewtopic.php?f=180&t=31160

      posted in Developers' Forum
      Al HartA
      Al Hart
    • Writing Ruby Console messages to a text file

      Sketchup.exe has a feature where, if you redirect its standard output to a file, then any messages which would be sent to the ruby console are written to the file. However, Sketchup.exe does not flush this file, so if there is a big splat, or if you want to examine the file while Sketchup.exe is running, it will not contain all of the messages.

      I have created a ruby script which overrides the Ruby Console, and write its messages to a file, and flushes each message.

      Place this 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).

      Give it a try, see what happens, and offer any suggestions you may have:

      !trace_console.rb

      
      # Copyright 2010, Render Plus Systems.
      
      # Permission to use, copy, modify, and distribute this software for 
      # any purpose and without fee is hereby granted, provided that the above
      # copyright notice appear in all copies.
      
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
      #-----------------------------------------------------------------------------
      
      
      printf("***** Loading; %s\n", File.basename(__FILE__))
      
      # create a class to trap comsole output and send
      # it to a file int c;\tmp
      class CL_rps_console < Sketchup;;Console
      attr_accessor ;debug_file
      attr_accessor ;sfile
      
      	def initialize
      		# create a folder called c;\tmp
      		sdir = "c;\\tmp"
      		if (!FileTest.exists?sdir)
      			 Dir.mkdir(sdir)
      		end#if
      		@sfile = "c;\\tmp\\ruby_trace.txt"
      		@debug_file = File.new(@sfile, "w")
      
      		@debug_file.write(;;Time.now.to_s  + "\n")
      		@debug_file.write("SketchUp Version; " + Sketchup.version.to_s  + "\n")
      	end#def
      
      	def write(smess)
      		@debug_file.write(smess)
      		@debug_file.flush
      		super(smess) # call inherited class write function
      	end#def
      end#class
      
      # redefine standard output to our new class
      $old_stdout = $stdout # in case you want to turn off traces
      $stdout = CL_rps_console.new
      $stderr = $stdout # trap error displays as well
      puts "-----"
      puts "Console messages are going to " + $stdout.sfile
      puts "-----"
      
      
      

      Sample file contents:

      C:\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

      [EDIT: changed name to !trace_console.rb and added $stderr = $stdout]
      [EDIT: Revised script for mkdir error]

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      I see that Sketchup replaces $stdout with #Sketchup::Console:0x365e1b0

      It has a write method, but no flush method

      $stdout.methods - Object.methods
      ["write"]

      $stdout.flush
      Error: #<NoMethodError: undefined method `flush' for #Sketchup::Console:0x365e1b0>

      Maybe we can get SketchUp to add a flush method to Sketchup::Console ❓

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      @thomthom said:

      Turns out, I was using a BAT file...
      "C:\Program Files (x86)\Google\Google SketchUp 7\Sketchup.exe" > myRubyLog.txt

      I create an image to a shortcut to the folder, however the proper shortcut still didn't work with either of these targets:

      "C:\Program Files\Google\Google SketchUp 8\SketchUp.exe" > debug.txt

      "C:\Program Files\Google\Google SketchUp 8\SketchUp.exe > debug.txt"


      It turns out you can access the desktop with:

      \users%USERNAME%\Desktop

      as in:

      echo xxx > \users%USERNAME%\Desktop\debug.txt

      Here is a script which will work for 32 and 64 bit windows:

      (I thought I would pass along my trick for making .bat files which work for both 32 and 64 bit systems)

      
      @echo off
      
      rem - goto proper Program Files
      c;
      if "%ProgramFiles(x86)%" == "" goto win32
          set PFILES=%ProgramFiles(x86)%
          goto process
      ;win32
          set PFILES=%ProgramFiles%
      
      ;process
      echo executing "%PFILES%\Google\Google SketchUp 8\SketchUp.exe"
      "%PFILES%\Google\Google SketchUp 8\SketchUp.exe" > \users\%USERNAME%\Desktop\debug.txt
      
      echo load debug.txt in notepad.
      notepad \users\%USERNAME%\Desktop\debug.txt
      
      

      Unfortunately, when SketchUp produced its bug splat, it had not flushed its output.

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      @thomthom said:

      Turns out, I was using a BAT file...
      "C:\Program Files (x86)\Google\Google SketchUp 7\Sketchup.exe" > myRubyLog.txt

      My client figured out how to get to the DOS prompt. But I would still love to figure out a good way to do this.

      I could create a batch file which the user could unzip into the SketchUp folder.

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      oops - I edited my previous post while you were responding to it.

      How do you redirect output in a shortcut?
      I tried: "C:\Program Files\Google\Google SketchUp 8" > debug.txt

      and "C:\Program Files\Google\Google SketchUp 8 > debug.txt"

      In the target line, but neither worked.

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      Thanks for your help on this.

      What to you replace '> debug.txt' with to put it on the desktop?

      I guess I was hoping for a way for the client to navigate to the SketchUp folder, and then do something from Windows explorer.

      I just went to explorer, right clicked on SketchUp.exe and selected "Create Shortcut", then clicked on the shortcut and selected properties.

      But I can't figure out where to put the redirection?


      shortcut.jpg

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Running SketchUp with command line redirection

      @thomthom said:

      Send the client a shortcut they can run?
      I got one on my desktop to start SU in debug mode - and it outputs the txt file on the desktop.

      Can you send me (al.hart @ renderplus.com) the shortcut, or post it here.

      Thanks,

      Al

      posted in Developers' Forum
      Al HartA
      Al Hart
    • Running SketchUp with command line redirection

      I want to explain to a client how to run SketchUp, and direct to output to a file.

      e.g. C:\Program Files\Google\Google SketchUp 8>sketchup > debug.txt

      The user has never used a command prompt window before.

      1. Is there an easy way to run Sketchup.exe with output redirection from Windows explorer.

      2. Or is there some other easy to do this.

      Also, I am worried that if she has Windows 7, she will not be able to write to a debug.txt file in Program files.

      Any ideas?

      posted in Developers' Forum
      Al HartA
      Al Hart
    • SketchUp dump files

      A client sent me a .DMP file and a file called SketchUpUndo0.log .

      1. Does anyone know anything useful which can be learned from the .DMP file?

      2. Do you only get the .log file after a crash?

      posted in Extensions & Applications Discussions extensions
      Al HartA
      Al Hart
    • RE: Alpha in Sketcup::Color

      I see the documentation says:

      @unknownuser said:

      NOTE: Assigning an alpha does not actually work.

      color = Sketchup::Color.new "AliceBlue"
      alpha = color.alpha = 255

      posted in Developers' Forum
      Al HartA
      Al Hart
    • Alpha in Sketcup::Color

      One of the things that messed up our ruby script in SketchUp 8.0 was the addition alpha to the class Sketchup::Color.

      Try this line in the ruby console:

      printf("%#x\n", Sketchup::Color.new('white'))

      in SU 7 it displays: 0xffffff

      in SU 8 it displays: 0xffffffff

      We fixed our applications, but does anyone know anything good that the new alpha channel is used for?

      posted in Developers' Forum
      Al HartA
      Al Hart
    • RE: Painting a material in a 3D view

      I'll have to look a little closer at the video. (I just looked at it, but I might have to watch harder.)

      I was quite impressed by the Street View stuff at the Base Camp, but as I remember it, he had to apply the street view texture separately to each face on the building he had created. And he had to stretch and dirstort the image to match the face - so it wasn't an automatic process (or am I missing something

      @unknownuser said:

      @unknownuser said:

      Does PhotoMatch, or 3D street view, or whatever, already wrap an image onto surfaces

      Is that I said second post πŸ˜„

      See video from 0. 45 minutes and following πŸ˜‰

      Also, when you use PhotoMatch for a texture, does it then get shaded? If so I will need to save an unshaded image from SketchUp. (I believe I can do this by turning the sun on for shading, setting Light intensity to 0 and Dark intensity to 100)

      posted in Developers' Forum
      Al HartA
      Al Hart
    • 1 / 1