Detect if an extenbsion is loaded?
-
Not exactly what I asked for, but I found this to be useful:
$LOADED_FEATURES.join("\n")
Lists all loaded files, even those loaded with
Sketchup::require
. -
Could use
defined?()
to check for modules, variable, etc. -
@thomthom said:
Not exactly what I asked for, but I found this to be useful:
$LOADED_FEATURES.join("\n")
Lists all loaded files, even those loaded with
Sketchup::require
.Though, doesn't list loaded .rbs files.
-
$" This pre-defined variable, an array contains the module names loaded by require.
@+
-
That's the same as
$LOADED_FEATURES
isn't it? -
in reality, I do not know
but
puts $LOADED_FEATURESreturn nil
puts $" return thatBy cons no return for files rbs
http://www.zenspider.com/Languages/Ruby/QuickRef.html#19
ChrisP
-
@thomthom said:
That's the same as
$LOADED_FEATURES
isn't it?YES.
Verify with .object_id
The problem with rbs loading is a bug. The rbs loader (Sketchup.require and/or Sketchup.load,) should upon sucessful load of an rbs file, push the path argument into the $" array, just as the Ruby native Kernel.require does.
I think the way they wrote it, you must not specify the file extension.
If you wish to require widget.rbs then you use:
Sketchup.require 'foldername/widget'
and then you might see 'foldername/widget' as one of the elements in the $" array. -
@thomthom said:
Is there a way to detect if an Extension is loaded or not?
Yes, but you need to modify the SketchupExtension class.
I did exactly that and a whole lot more (mods the class,) for my own personal use.No point in me releasing it, as you guys generally don't like these sort of mods, and also Google will not use "unsolicited code contributions" (which is why I now understand why Jim gave up on the SKX project.)
-
@dan rathbun said:
I think the way they wrote it, you must not specify the file extension.
If you wish to require widget.rbs then you use:
Sketchup.require 'foldername/widget'
and then you might see 'foldername/widget' as one of the elements in the $" array.That's what I do - no file extension for .rbs files, but I've not found them listed anywhere.
@dan rathbun said:
No point in me releasing it, as you guys generally don't like these sort of mods,
I avoid it in released code as it's the same as not wrapping the code in modules - too much chance for conflicts. That's my reason for skipping out of the SKX project.
Though for debugging and experimenting I occasionally do it. Recently extended the Menu, Toolbar and Command class to intercept the creation of the UI elements - might be a way to make an UI manager.
-
@dan rathbun said:
No point in me releasing it, as you guys generally don't like these sort of mods, and also Google will not use "unsolicited code contributions" (which is why I now understand why Jim gave up on the SKX project.)
I probably shouldn't have - it can still be a valuable project. I think if I/we had pushed through, people would have started to use it and we might have a quality piece of work by now.
Advertisement