(MacOS) I’m a bit of a newb and am trying to get my extension and its menu item added automatically when I start Sketchup. For git reasons it’s down a dev directory path. The only way, I know of, to get the Extension installed and the menu item in the Extensions menu is using the ‘Extension Sources’ extension. Can I do what it does programmatically?
Other than that I can debug fine in RubyMine, everything works.
Here’s what I know:
a) I’m using an Eneroth-ish load script in the Plugins directory:
#require 'sketchup.rb'
#require 'extensions.rb'
pattern = "/Users/<me>/Library/Mobile Documents/com~apple~CloudDocs/Dev/Sketchup Ruby/*/src"
Dir.glob(pattern).each do |dir|
$LOAD_PATH << dir
Dir.glob("#{dir}/*.rb").each { |p| require p }
end
```
b) I did do a puts on $LOAD_PATH and it getting the correct path added.
c) When ‘Dir.glob(“#{dir}/*.rb”).each { |p| require p }’ executes I am hitting a breakpoint in my registration file. Myregistration file is not the problem because the extension installs using ‘Extension Sources’.
d) cube_to_drawer/main never gets invoked to add the menu item unless I used ‘Extension Sources’
I work on a windows machine. I have made a few plugins for myself (none published). I use this code in the plugins folder and i have my own dev folder it points to and loads. Hope this helps:
ruby
=begin
Copyright: 2025, Mark Perrah, All Rights Reserved
Author: Mark Perrah
Name: MP Edge State Tool
Version 1.0.2
SU Version: 2024/5
Date: 4/8/2025
Description: Show icon change in toolbar depending state of selected edges
History:
1.0.1 2025-04-08 first design
=end
require ‘sketchup.rb’
require ‘extensions.rb’
module MP_Extensions
module MP_Edge_State_Tool
my_extension_loader = SketchupExtension.new( 'MP Edge State Tool' , 'mp_extensions/mp_edge_state_tool.rb')
my_extension_loader.copyright = 'copyright 2025 by me'
my_extension_loader.creator = 'Mark Perrah'
my_extension_loader.version = '1.0.1'
my_extension_loader.description = 'MP Edge State tool.'
Sketchup.register_extension( my_extension_loader, true )
end # module MP_Edge_State_Tool
end # module MP_Extensions
```
The line “my_extension_loader = points to my subfolder. Thought possibly If the poster could use this as example to build the subfolder with his extension and point to it in this fashion.
@3DxJFD Yes, [1.] my loader file is in my Plugins directory. It does work, because [using RubyMine] I can put a breakpoint in my reg file, which is in down my ‘Dev’ path, and it gets hit when I start Sketchup. So that’s ok.
[2.] Macs (macOS) is based on unix, they don’t have drive letters, instead they have ‘mounted volumes’, but none the less the initial forward slash is the ‘root’ just like ‘C:’ on a windows machine.
[3.] This is good point! And, yup, my dev directory is on my iCloud drive. But, the ‘icloud’ files, are locally cached in this case, and as evidence, I’ve got full debugging in RubyMine, with zero delay, so I think that’s ok.
Ah well, I was just pointing to the obvious because that’s where I usually start getting off track. I did try both ways from the Basic Developemnt Environment page and they both worked for me (no GitHub). It sounds like you also know that you could run directly out of your Plugins folder with a registration file (‘registrar’ file, not the loader) but that doesn’t work for you, because Git reasons. One more wild guess: public vs. private GitHub repository? Could be a thing?
I haven’t tried loading from git, though I keep a backup copy of source code there. The attached extension, tweaked from the example in the dev github, has worked for me (it will need some edits for the folder paths where you keep your source). The ! on the registrar name causes SketchUp to load this before other extensions.