Load Toolbars
-
I start to set my own Toolbar to load the single Toolbars with a one Button solution.
I use for the start:
def thea_show
User::ToolbarSet["Thea Exporter"].show()
end #def
@cmd = UI::Command.new("Thearender") { thea_show }
@cmd.small_icon = "../images/th.png"
@cmd.large_icon = "../images/th.png"
@cmd.tooltip = "Thea Render"( The cmd are for Jim's Toolbar Plugin )
This works for four of six Buttons. ( Shaderlight and the Thea Exporter do not open )
Is there a reason why some toolbars wont open and some do?Thanks Burkhard

-
thea_show?
If you type that in the Ruby Console does it work ?? -
With Thea Exporter not but with Maxwell ..Yes
...and don't ask why...I just tried a few things


-
This works too (Thea For SketchUp), just Shaderlight and Thea Exporter failed.
def theaskp_show
User::ToolbarSet["Thea For SketchUp"].show()
end #def
@cmd = UI::Command.new("Thearender") { theaskp_show }
@cmd.small_icon = "../images/ths.png"
@cmd.large_icon = "../images/ths.png"
@cmd.tooltip = "Thea Render for Sketchup" -
Found a workaround. It needs to be refresh, so I build in a refresh Button with:
User::ToolbarSet.refresh() (Thanks to Dan http://sketchucation.com/forums/viewtopic.php?f=180&t=51432 )
So, if a Toolbar is not loaded, it works after refresh the hash
-
(A) Any script that is going to access
User::ToolbarSetshould have a require call at the top like:
require('user/toolbarset.rb')
whose argument is whatever the dir and filename you used.This way you be sure that the
Usermodule andToolbarSethash have been created.(B) Ruby
UI:Toolbarobjects are created in the order that scripts are run.
1) Alphabetical according to their filename
2) as they are specified inrequire()calls(Which can change the alpha order.)
(C) My suggestion is to name YOUR custom toolbar script so that it loads LAST, by using "X_my_toolbars.rb" or something, as it's filename. Then the
requirecall, as shown in (A) at the top of this file, would create theUser::ToolbarSethash AFTER all other toolbars have been created.
-
@burkhard said:
Found a workaround. It needs to be refresh, ...
So, if a Toolbar is not loaded, it works after refresh the hash.The Toolbar WAS loaded, but
UI::Toolbarreferences are NOT automatically added into the customUser::ToolbarSethash.SO.. I created the
UI::Toolbar.refresh()method to find any new toolbars (created after the hash was populated,) and add them.I WILL NOT modify the API's
UI::Toolbarclass constructor method, in a public script, because I feel it is a violation of the API Terms of Use.BUT perhaps we can modify the
User::ToolbarSethash's[]method's errorProc, so that it refreshes the hash automatically.
See: http://sketchucation.com/forums/viewtopic.php?f=180&t=51432&p=466742#p466742
Advertisement