yeah, but UI.messagebox
is again disturbing a quick save-and-test my plugins!
I'm still fooling around with the Win32API, to know when the Ruby Console window is open. In the meantime I'm just waiting 2 seconds before my plugins are loaded with this:
To make it ready for RDZ I added:
...\plugins\mr_plugins.rb
require 'sketchup.rb' # Don't know why, but everyone is adding these line?
require 'extensions.rb' # Don't know why, but everyone is adding these line?
mr_plugins = SketchupExtension.new "mr_plugins", "mr_plugins/mr_!main.rb"
mr_plugins.copyright= "Copyright 2014"
mr_plugins.creator= "onidarbe () gmail"
mr_plugins.version = "2013 jan 06"
mr_plugins.description = "Adds all ../plugins/mr_plugins/*.rb"
Sketchup.register_extension mr_plugins, true
This plugin will then load all my plugins in a sub-folder after 2 seconds, to be sure that the Ruby Console is open and ready to receive puts
:
...\Plugins*mr_plugins*\mr_!main.rb
module MR
if !file_loaded?(File.basename(__FILE__))
UI.start_timer(2, true){ require_all(Sketchup.find_support_file("Plugins") + "/mr_plugins/") }
file_loaded(File.basename(__FILE__))
end #if
end #module
Finally this code will add a menu-item which could be checked to enable/disable opening the Ruby Console:
...\Plugins*mr_plugins*\mr_openRubyConsoleOnStart.rb
module MR
@pluginPath = Sketchup.find_support_file("Plugins")
def self.openRubyConsoleOnStart # onidarbe 2013-01-07
# Delete or create a plugin file that opens the Ruby Console on start of Sketchup.
# Because the filename starts with a "!" it will alphabetically start first.
# The Ruby Console takes some time to load in-between loading other plugins!"
if FileTest.exist?(@pluginPath + "/!openRubyConsoleOnStart.rb")
File.delete(@pluginPath + "/!openRubyConsoleOnStart.rb")
UI.menu("Windows").set_validation_proc(@menuItem){MF_UNCHECKED}
else
file = File.new(@pluginPath + "/!openRubyConsoleOnStart.rb", "w")
file.puts("# Placed here with #{File.basename(__FILE__)} to open the Ruby Console at start.")
file.puts("# Filename starts with a '!' to start first as plugins starts alphabetically.")
file.puts("# The Ruby Console takes some time to load in-between loading other plugins!")
file.puts("Sketchup.send_action 'showRubyPanel;'") #to open Ruby Console
file.close
UI.menu("Windows").set_validation_proc(@menuItem){MF_CHECKED}
end
end
if !file_loaded?(File.basename(__FILE__))
@menuItem = UI.menu("Windows").add_item("Open Ruby Console on start [MR]") {MR;;openRubyConsoleOnStart}
if FileTest.exist?(@pluginPath + "/!openRubyConsoleOnStart.rb")
p @menuItem
UI.menu("Windows").set_validation_proc(@menuItem){MF_CHECKED}
end if
file_loaded(File.basename(__FILE__))
end
end #module
Now if I could know that the Ruby Console is open, then I don't need to add an other menu-item! I could just restore the last situation, opening the Console when it was open on closing SU. ![:unamused: π](https://community.sketchucation.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f612.png?v=fe137e50c39)