SketchUp installs extensions (zipped up into .RBZ archives) using: Sketchup::install_from_archive … or the end user installs the the RBZ either: using the manual “Install Extension…” button at the bottom left of the Extension Manager window, … or through the Extension Warehouse.
Read and understand how to set up a proper SketchupExtension object, with a registrar file, an extension subfolder, and code files within that subfolder.
SketchUp Ruby extensions all run in the same environment, and exiting it would not just exit a single script from loading. Instead off using exit, you could rearrange the code with a syntax block after the if/unless statement.
# Doesn't work in SketchUp
exit if some_condition
# Stuff goes here...
# Works in SketchUp
unless some_condition
# Stuff goes here...
end
It is not needed to push the registrar file’s path into the $loaded_files array with file_loaded().
It will just bloat the array and it’s file_loaded?() block is not needed for registrars as the load cycle only happens once.
I guess you can tell I am not a fan of using file_loaded() or file_loaded?().
It uses a global array which can have clashing strings in it. Also string comparison in Ruby is slow.
It is much faster and safer to have your extension submodule use it’s own internal boolean module variable to track it’s own load state.