diff --git a/README.md b/README.md index 4bd0273..8242677 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,16 @@ If you're a SketchUp Ruby community member, you need to fork this repo (If you d 1. From your GitHub repo, send a Pull Request. +#### Debuging advice + +To debug, the following steps will allow to reload the app without closing sketchup on each modification: + +- uncomment the line `` Sketchup::require File.join(PLUGIN_PATH, 'reload')`` in loader.rb +- copy `` sketchup-stl.rb`` S file and `` sketchup-stl`` folder in `` SC:\Users\tks\AppData\Roaming\SketchUp\SketchUp 2023\SketchUp\Plugins`` folder + +Once Sketchup launched, you can modify scrripts and reload the extensions by going to "Extensions">"Developer"> "Reload Code Files: sketchup-stl" + + ## License diff --git a/src/sketchup-stl/exporter.rb b/src/sketchup-stl/exporter.rb index 78f73d8..c30470c 100644 --- a/src/sketchup-stl/exporter.rb +++ b/src/sketchup-stl/exporter.rb @@ -42,7 +42,7 @@ def self.select_export_file title_template = STL.translate('%s file location') default_filename = "#{model_name}.#{file_extension}" dialog_title = sprintf(title_template, default_filename) - directory = nil + directory = Sketchup.active_model.path filename = UI.savepanel(dialog_title, directory, default_filename) # Ensure the file has a file extensions if the user omitted it. if filename && File.extname(filename).empty? diff --git a/src/sketchup-stl/loader.rb b/src/sketchup-stl/loader.rb index af283a0..a8039ce 100644 --- a/src/sketchup-stl/loader.rb +++ b/src/sketchup-stl/loader.rb @@ -24,6 +24,7 @@ module STL Sketchup::require File.join(PLUGIN_PATH, 'utils') Sketchup::require File.join(PLUGIN_PATH, 'importer') Sketchup::require File.join(PLUGIN_PATH, 'exporter') + # Sketchup::require File.join(PLUGIN_PATH, 'reload') end # module STL end # module CommunityExtensions diff --git a/src/sketchup-stl/reload.rb b/src/sketchup-stl/reload.rb new file mode 100644 index 0000000..df5e8c1 --- /dev/null +++ b/src/sketchup-stl/reload.rb @@ -0,0 +1,23 @@ +module TKS + module SomePlugin + + if !defined?(@gui_loaded) + + # This assumes you have created a SketchupExtension object in a registrar + # file in the "Plugins" folder, referenced by a local constant EXTENSION. + UI.menu("Developer").add_item("Reload Code Files: sketchup_stl") { + prev_dir = Dir.pwd + Dir.chdir(__dir__) do + Dir.glob("*.rb").each { |rb_file| load(rb_file) } + rescue => error + puts error.inspect + puts error.backtrace + Dir.chdir(prev_dir) + end + } + + @gui_loaded = true + end + + end +end \ No newline at end of file