Refresh plugins without restart Sketchup is possible??
-
I mean, every time I modify my plugins I must restart sketchup to watch the changes. You know som plugins or method for refresh my plugin without restart sketchup???
Thanks guys!!
-
if you go to the ruby console and type
load "pluginname.rb"
your plugin will be refreshed. -
Yes, thats normal. It will sort itself out when you restart sketchup.
there might be some clever way of avoiding it loading the extra menu items although i dont know how to do it, any clues anyone?
-
@remus said:
if you go to the ruby console and type
load "pluginname.rb"
your plugin will be refreshed.Hey man, thanks!!! It works!! But i have a little problem now, everytime I do this, in the menu of plugin appears a new plugin. If I do 3 times load "house.rb" then I have 3 House in the menu plugins, that's normal??
In my ruby I have the next line, maybe it's wrong.
UI.menu("PlugIns").add_item("house") {main}
-
Take a look at how box.rb in the plugins\examples folder loads itself into the menu. It starts on line 100.
Also important to note is that it calls a method file_loaded at the very end of the script. That method is in the sketchup.rb file, so must put in a
require 'sketchup.rb'
at the top of your script so it can correctly call that method. You can look at the sketchup.rb file to see what goes on when that method is called.But the idea is that you check to see if your file is already loaded. If it is loaded, then it does not add itself to the menu system again. But if it is not loaded, then it will add itself to the menu.
Chris
-
Also, instead of manually typing in the file name in
file_loaded("box.rb")
, you can usefile_loaded(__FILE__)
. FILE is a (please Jim or someone correct me if I get the object name wrong) is a constant that holds the name of the current ruby file.That is nice because it is easier to copy and paste between scripts, and you don't have to change anything if you rename your script after a few versions.
Chris
-
Thanks!! I got it! like box.rb
if( not file_loaded?("House.rb") ) UI.menu("PlugIns").add_item("Make house") {main} end file_loaded("House.rb")
and I tried with FILE and works too!
-
Also, you can use "unless" instead of "if not", and a bit of restructuring gives you
unless file_loaded?(__FILE__) file_loaded(__FILE__) #do your stuff here end
Though it's not a big deal, it eliminates any unnecessary calls to file_loaded()
-
Thanks man!!
And it's possible creat a plugin which reloads all the plugins in the directory plugins or the plugins you write in this plugin??
I mean a plugin which per example do this. "load "House.rb", like this we can reload all the plugins without write load"xxx.rb" in the ruby console.
-
Yes, you could create a toolbar that reloads your script you are developing. That way, just click the icon you made and it will run the load myruby.rb command.
Have you looked into Jims webconsole? I find it to be a very handy tool. I write most of my code in it. It lets you actually write code within sketchup and just pres execute and it will run. No need to make a menu system for it at first. I generally wait until its all running smoothly then copy it over to notepad++ to add my menus and copyright info, etc.
Chris
-
It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!
Thanks for the advice!!
-
@davidsuke said:
It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!
Thanks for the advice!!
If you want syntax highlighting you can use the editor here.
http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18130#p146440
[plugin] SuRDebug -
@pecan said:
@davidsuke said:
It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!
Thanks for the advice!!
If you want syntax highlighting you can use the editor here.
http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18130#p146440
[plugin] SuRDebugThat's good, and it have auto-indent too??
Advertisement