Toolbar problem in SU 8 on Windows
-
The timer did not help.
Thanks for the idea, Dan.
It is interesting that I get a warning when starting the timer:
/aa/toolbar.rb:32: warning: Float 0.1 out of range
SU 7 does not give the warning.
Has anyone tried my code (You do not actually need any .PNG files) and/or does anyone have a small .rb which I can load from a directory, rather than putting in plugins to see what it does?
Latest code:
toolbar = UI;;Toolbar.new "Test2" # This toolbar icon simply displays TestX on the screen cmd = UI;;Command.new("Test2") { UI.messagebox "Test2" } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" cmd.tooltip = "Test Toolbars" cmd.status_bar_text = "Testing the toolbars class" cmd.menu_text = "Test2" toolbar = toolbar.add_item cmd cmd = UI;;Command.new("Test3") { UI.messagebox "Test3" } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" cmd.tooltip = "Test Toolbars" cmd.status_bar_text = "Testing the toolbars class" cmd.menu_text = "Test3" toolbar = toolbar.add_item cmd toolbar.show # Show toolbar if it was open when we shutdown. state = toolbar.get_last_state printf("toolar state; %s\n", state) if (state == TB_VISIBLE) toolbar.restore # Per bug 2902434, adding a timer call to restore the toolbar. This # fixes a toolbar resizing regression on PC as the restore() call # does not seem to work as the script is first loading. printf("Starting timer\n") UI.start_timer(0.1, false) { toolbar.restore } printf("After Starting timer\n") end
Result in SU 8:
load '/aa/toolbar.rb'
/aa/toolbar.rb:33: warning: Float 0.1 out of range
toolar state: 1
Starting timer
After Starting timer
true -
-
@al hart said:
/aa/toolbar.rb:32: warning: Float 0.1 out of range
SU 7 does not give the warning.
The new core is more strict - the warning is probably because
0.1
suffers from rounding errors. -
Just when I was about to say, I was having no problems with Toolbars... I opened SU8 and got a toolbar shuffle for no apparent reason.
Anyway.. I turned off the Google toolbar.. and put the Sandbox toolbar where it was (last on the 1st row.)
Then I used the menu option "Save Toolbar Positions"
Then closed SU8
Then reloaded SU8 and it was where I put it.But, I'm very sure that I had not ever opened the Sandbox Ruby toolbar, and when I did, by checking the box in the Extensions panel, it just docked at the end of TB row 2, instead of floating.
So things are not right still in Sketchup Octoland...
... and Al, I do not get that float range error when running SU8 with Ruby v 1.8.7-p299
I'll try it in a min, with v 1.8.6-p287
~ -
@dan rathbun said:
So things are not right still in Sketchup Octoland...
Yes! I'm not mad!
But like you, I've been able to determine any pattern. I've pretty much settled on SU's Toolbar system being FUBAR.
-
@thomthom said:
The new core is more strict - the warning is probably because
0.1
suffers from rounding errors.i suspect it is because you can't set a timer to less that a full second.
I get the same error with 0.5, which shouldn't have any rounding errors:
UI.start_timer(0.5, false) {puts "A" }
(eval): warning: Float 0.5 out of range
20984
AThe message is even stranger when you pass if 2.0/10.0
UI.start_timer(2.0/10.0, false) {puts "A" }
(eval): warning: Float 2.0 out of range
20928
A -
I get no such errors in 7 or 8.
-
@dan rathbun said:
... and Al, I do not get that float range error when running SU8 with Ruby v 1.8.7-p299
~
The error is elusive, so it may be occurring when you run another script, but you can't see it.
How do you change the ruby version used internally by SketchUp?
-
@al hart said:
i suspect it is because you can't set a timer to less that a full second.
You can now in SU8!
-
@al hart said:
How do you change the ruby version used internally by SketchUp?
On the PC it's only a matter of renaming (for backup,) the old one from "msvcrt-ruby18.dll" to "msvcrt-ruby186-p287.dll"
Then go get another DLL from a higher patch level and/or branch and copy it into the SU folder. Most thsoe in the 1.8.x family are named "msvcrt-ruby18.dll", but the newer ones in 1.9.x have all 3 numbers in the file name. (ie: "msvcrt-ruby191.dll")
Sketchup is hardcoded to look for "msvcrt-ruby18.dll" -
Very strange... Al you may want to see if a plugin overrode UI.start_timer, by dumping a methos list: UI.methods.sort
look for a "old_start_timer etc.Or set $VERBOSE=trueand open the console before anyother rubies load.
When a method gets overriden, Ruby issues a warning to the console.
You can use a script snippet I posted: http://forums.sketchucation.com/viewtopic.php?f=180&t=30539#p269522 -
@dan rathbun said:
Very strange... Al you may want to see if a plugin overrode UI.start_timer, by dumping a methos list: UI.methods.sort
look for a "old_start_timer etc.I'm also seeing warnings like Al reports.
-
Well then maybe you both dump a plugins Dir listing and compare.
I have Google Tools: DCs, Sandbox, SolarNorth, and Photo(Web)Textures loaded.
3rd party Plugins: only Fredo's BezierSpline1.4, Smustard Organizer and my ver2ofOceanModeling.( It occurs to me that you guys might not have the correct Win32API.so file for v1.8.6-p287,
I remember having some problems with and old copy of Win32API.so, when I first started using v1.8.6 with SU7. )Here's the 2 so files distro'd with v1.8.6-p287:
-
-
Windows7
-
@al hart said:
The timer did not help. Thanks for the idea, Dan.
...Has anyone tried my code (You do not actually need any .PNG files) and/or does anyone have a small .rb which I can load from a directory, rather than putting in plugins to see what it does?
Latest code:
> toolbar = UI;;Toolbar.new "Test2" > # This toolbar icon simply displays TestX on the screen > cmd = UI;;Command.new("Test2") { > UI.messagebox "Test2" > } > cmd.small_icon = "ToolPencilSmall.png" > cmd.large_icon = "ToolPencilLarge.png" > cmd.tooltip = "Test Toolbars" > cmd.status_bar_text = "Testing the toolbars class" > cmd.menu_text = "Test2" > toolbar = toolbar.add_item cmd > > cmd = UI;;Command.new("Test3") { > UI.messagebox "Test3" > } > cmd.small_icon = "ToolPencilSmall.png" > cmd.large_icon = "ToolPencilLarge.png" > cmd.tooltip = "Test Toolbars" > cmd.status_bar_text = "Testing the toolbars class" > cmd.menu_text = "Test3" > toolbar = toolbar.add_item cmd > toolbar.show > > # Show toolbar if it was open when we shutdown. > state = toolbar.get_last_state > printf("toolar state; %s\n", state) > if (state == TB_VISIBLE) > toolbar.restore > # Per bug 2902434, adding a timer call to restore the toolbar. This > # fixes a toolbar resizing regression on PC as the restore() call > # does not seem to work as the script is first loading. > printf("Starting timer\n") > UI.start_timer(0.1, false) { > toolbar.restore > } > printf("After Starting timer\n") > end >
Just noticed a few boo-boos when rereading this old post.
(1) The statement
toolbar.show
(on line 22 of the snippet,) defeats the state/restore block that follows.(2) The state/restore conditional block would only work on the second toolbar "Test3" (otherwise you need a state/restore block after defining each toolbar, if you are going to keep reusing the same reference, in this case the identifier
toolbar
.)
My latest recommended snippet is in this post:
Re: How to use the toolbar.show method******* You could wrap the snippet in a method block called:
toolbar_restore(toolbar)
and then pass each toolbar reference to the method after creation, so as to make your code more "clean". (Also varsdelay
andstate
will be local to the method and get cleaned up automatically.)
~ -
We are still struggling with Toolbars in SU8.
Our biggest remaining problem, is that that when we load a plugin by hand, rather than having it loaded automatically as SketchUp loads - (we offer both options to users - always load the app, or manually load it from the Plugins menu) - the toolbar appears - but is not docked.
I looked at your code snippet in the other thread, but it is hard to figure out how to put everything together.
Can you, (or someone), provide a .RB which I can execute manually, (not placing it in the plugins folder - but loading the .RB from the ruby console - or later from the Plugins menu), which creates a new toolbar, and docks it properly?
Then I can grab from it what I need, etc. to get it to work with our app.
Advertisement