Ruby File Auto-Reloader code
-
I got tired of reloading files I was editing, so made this up real quick. It uses a timer to check the last modification time on a file, and loads if updated. It handles errors gracefully by only trying to reload a file once per update. If packaged up with a nice user interface, it might make a nice dev tool.
Stop the timer in the Ruby Console:
UI.stop_timer $tNote - It's only good for one file at a time and needs improved if loading multiple files is needed. I just wanted something for "right now," and will try to make it better later.
def autoreload(name) pf = Sketchup.find_support_file('plugins') file = File.join(pf, name) $t = UI.start_timer(2, true) do mt = Kernel.test(?M, file) if mt.to_i > $mt.to_i puts "Loading; #{File.basename(file)}" begin load file rescue Exception => e puts e.message puts e.backtrace end $mt = mt end end end -
Thank-you for this great Plugin !!!

It's so boring to always close and re-open SU to update my plugins files !!
-
I'm glad you found it useful.
But there are times when it is good to close SketchUp; when you change the name of a method, for example. Closing SketchUp is the only way to get rid of the old method name. Sometimes you have a bug where a part of your code is still using the old method name until you remember you changed it. I've done this numerous times.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement