Load_on_start doesn't work in Sketchup.register_extension for SU 2016

Hi,
I’m experiencing a problem registering my extension, which appears only in SU2016
I’m creating a file in %ProgramFiles%\Sketchup\Sketchup 2016\tools\ named myPlugin.rb which contains only

require("sketchup.rb")
require_all("C:/Program Files/MyProduct/Plugins/")

in C:/Program Files/MyProduct/Plugins/, there’s the rb file that registers my extension, containing

...
myExt = SketchupExtension.new "My product", "subFolder/aplugin"
...
Sketchup.register_extension myExt, true

and in subfolder, the file aplugin.rbs implementing the plugin.

When I do that on older versions of SU (2013-2015), it works perfectly.
Now, on SU 2016, the extension is visible in window->preferences->extensions but is not checked by default.
Why does this behavior has changed since this version ?!

Thanks.

Yes, it is broken. The SketchUp team knows it’s broken. This bug will hopefully be fixed in a maintenance release.

2 Likes

Ok. Thank you for the quick answer :grinning:

BTW: it should be in the Plugins folder not the tools which is reserved for auto loading SU plugins…

it is highly likely that SU will block loading from it’s application folders in the very near future…

john

2 Likes

Yes, that’s what I did before, but since the Plugins folder is in AppData,
and there’s no way to reliablily find this folder within all versions (I
read that by there, can’t remember where), except with a case of (and
finding the version of Sketchup.exe to “know” this folder). But it’s the
same, it’s not reliable for future versions. That’s why I choosed this
folder which works for every version, as long as I know the path to SU.exe.

plugpath = Sketchup::find_support_file("Plugins")

… has always been reliable, and should always be.

If you want to install YOUR files and plugins in a company specific location, that is independent from the SketchUp version, than it should be in your company sub-folder of the user’s %AppData% folder. (Just like SketchUp does, and Microsoft does.)

company = File.join( ENV["AppData"].gsub("\\",'/'), "Guilleme" )
Dir::mkdir(company) unless File::exist?(company) && File::directory?(company)

ADD: Then your company’s plugins path would need to be appended to the Ruby $LOAD_PATH array:

$LOAD_PATH << company

Afterward, Ruby’s load() and require() methods will be able to find files via relative paths below your company path. (Sketchup::register_extension also.)


OR you can put it in the user independent ProgramData store:

company = File.join( ENV["ProgramData"].gsub("\\",'/'), "Guilleme" )
Dir::mkdir(company) unless File::exist?(company) && File::directory?(company)

This was called %AllUsersProfile% prior to Windows v 6+ (Vista and higher.)
BUT, … the files will be for all users using that workstation.

1 Like

Yes … if you’re within Sketchup, which is not my case.
My goal is to install my application’s plugins to an installed sketchup (for instance, the one associated with skp files), from outside SU (from my App’s setup).
I don’t think the location of my plugins matters for the problem. ProgramFiles, AppData or ProgramData will act quite the same I think (except ProgramFiles could be (x86) or not, depending on SU is 32 or 64).
Even with your interesting advices, I can’t figure out how I can append my plugin’s folder to $LOAD_PATH. For that, I need to put a file somewhere that SU will load on start. But how can I find this “somewhere” independently of SU version and outside of SU’s ruby interpreter ?

can’t you just load your rbz into SU with command line?

Sketchup.exe -RubyStartup <path in your_installer>/load_rbz.rb

john

1 Like

You cannot. SketchUp will only load version specific files by default. It would need to be modified with an extension (and sometimes is by educational ITs etc.,) to load from a version independent plugin folder. (This is often a shared plugin folder on a network server.)

So (for default stratup extension loading,) you are stuck with the version specific %AppData% plugins path after v2014. And the version specific %ProgramFiles% path for v2013 and earlier.

Incorrect. There are major permissions differences. If the user does not have administrative privileges, access to %ProgramFiles% plugin folders can be restricted. Also with %ProgramData% plugins folders, writing to those folders at runtime (for settings files, etc.) can be blocked.

This is why the plugins folders were moved into the user’s %AppData% path beginning with v2014. (It is where Microsoft intends user specific application data to be stored.)

You will have to rely upon pathstrings stored in the Environment variables, (%AppData%, %ProgramData%, etc.,) or access the registry for installation path strings (if your installer engine allows this.)
See: Environment variable - Wikipedia

You really didn’t explain this external installer issue in the original post, and we don’t know what installer engine you are using.

Installer locations can be read from the registry at:

For 64bit app on 64bit WIN, or 32bit app on 32bit WIN. (SketchUp v2015 or higher.)
HKEY_LOCAL_MACHINE\SOFTWARE\SketchUp

For 32bit app on 64bit WIN
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SketchUp

For versions prior to v2013, the “InstallLocation” attributes are under the “Google” key, not a generic “SketchUp” key. For example, version 8 on my 64bit WIN would be:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Google SketchUp 8\InstallLocation

That is problematic for older versions, and still may not be fixed in the current version. Each SketchUp installation is fighting over the SKP file association, and the double-click shell open command path.

It would be better to enumerate the set of SketchUp installations and ask which ones to install the plugin for. (Of, course only listing those version that your plugin is compatible with.)

Has it been fixed in SU17? i am experiencing the same problem: extension is not checked through the code in ruby when it has been un checked using the extension manager window; maybe it is on purpose?