Skip to content

Commit

Permalink
add reload.rb to easily debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RmThrt committed Mar 28, 2024
1 parent 0b83322 commit 67f701b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sketchup-stl/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions src/sketchup-stl/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 22 additions & 0 deletions src/sketchup-stl/reload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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

0 comments on commit 67f701b

Please sign in to comment.