Separating a plugin from others
-
@unknownuser said:
I see, so doing:
t3 = Test.new
Will get unexpected results!Thank you!
Depends in what cope you are in.
module Mod1 class Test def id puts "Mod1 Test" end end t1 = Test.new # Should refer to Mod1;;Test end module Mod2 class Test def id puts "Mod2 Test" end end t2 = Test.new # Should refer to Mod2;;Test t4 = Mod1;;Test.new end t3 = Test.new # I don't know if this will even work
-
@unknownuser said:
Sketchup.load 'Plugin.rbs'
returns0
(!=true or false).
There is no explanation in the API for such a case.Is there someone from Google who can tell me what 0 means in this case?
It happens on Vista64 SU 7.1. -
What is Plugin.rbs ?
-
@chris fullmer said:
What is Plugin.rbs ?
I have used SDK Scrambler on Plugin.rb file >> Plugin.rbs.
It is 'a' plugin name. Not relevant in this case. -
Once you scramble a file, there are problems with it loading. I think you have to hard code the path into the file.
I'm not sure if you use the FILE constant in your script, but I tihnk that might not work in a scrambled script. I'm sure others here know more about this. But I do know that scrambled scripts are a little trickier to load somehow....Perhaps that is why it seems to not be loading?
Chris
-
@unknownuser said:
@unknownuser said:
Sketchup.load 'Plugin.rbs'
returns0
(!=true or false).
There is no explanation in the API for such a case.Is there someone from Google who can tell me what 0 means in this case?
It happens on Vista64 SU 7.1.Does the plugin load? Might be the manual that's incorrect, and it returns 1 on success and on failure?
-
Sketchup.load
acts likeSketchup.require
which acts likerequire
- which means it checks the$"
special global variable before loading.0 could mean it has already been loaded. Check the
$"
variable in the Ruby Console window to see if the file is already on the list. -
@chris fullmer said:
I'm not sure if you use the FILE constant in your script, but I tihnk that might not work in a scrambled script. I'm sure others here know more about this. But I do know that scrambled scripts are a little trickier to load somehow....Perhaps that is why it seems to not be loading?
I just realized same thing. I do use FILE. I will hard code it. I am not sure if it will be
unless file_loaded?('Plugin.rb')
orunless file_loaded?('Plugin.rbs')
. Will check it.@thomthom said:
Does the plugin load? Might be the manual that's incorrect, and it returns 1 on success and on failure?
The plugin loads automatically on my machine (Vista32Home). When I
Sketchup.load 'Plugin.rbs'
it returns 0 .. which may mean that the plugin has been already loaded.
The thing is that an user on Vista64 gets olso 0, but there is no plugin whatsoever in his Plugins menu.I have another tester with Vista64 and it works fine for him, so there must be some interaction with a different plugin I believe.
-
@unknownuser said:
I am not sure if it will be unless file_loaded?('Plugin.rb') or unless file_loaded?('Plugin.rbs'). Will check it.
Not important - can be any string. It just adds the string to a global variable. It is something invented for Sketchup for the sole purpose of guarding the menus from adding multiple entries.
Yeah - I think I'll call them "menu guards".
-
I can confirm. Sketchup.load returns 0 (fixnum class) if it loaded and false (falseclass) if it did not load.
Odd, that should go in as a bug fix, and an API fix?
Chris
-
@jim said:
Not important - can be any string...
Yeah - I think I'll call them "menu guards".So FILE is not the issue. I think I have a problem with a different plugin, that stops mine to load into Plugins.
Thanks for explanation. -
You say its a Vista user with problems? Nearly all the Vista problems I get are related to the "Compatibility Files" folder. Sometimes when a user downloads a file directly to the plugins folder, it will put it into a safe compatilibity folder, and it does not appear in the plugins folder.
Have the user check their compatibility folder, delete any old versions of your plugin, reinstall, and try again. That might help.
Chris
-
I have discovered something important for those who use rbs.
If you check if your plugin has already been loaded with:
file_loaded?(File.basename(__FILE__))
from inside of a rbs file - the FILE value == '(eval)' !
If there are two rbs plugins which use the same method, the first will block the second.
That is why my rbs has been loaded, but didn't create a menu in Plugins. -
@unknownuser said:
If you check if your plugin has already been loaded with:
file_loaded?(File.basename(__FILE__))
from inside of a rbs file - the FILE value == '(eval)' !Sounds like File.basename(FILE) is getting set to part of an eval error string.
I wonder if eval error strings are put to the $! message global? -
FILE when ruby is scrambled is useless as it gets evaled, so you cannot use it. had the same problem when developing/using Sketchup Bridge.
workaround: add the path to the global search path for loading scripts $:
Advertisement