[Plugin] Boolean helper update 08122011
-
Hi TIG,
@unknownuser said:
I don't see any 'write_default' code ?
My complete code is now attached in the rb-file below....
Am I right? It has to be:
sfa = Sketchup.read_default('liquidsscalefactor','value', 0) sff = sfa[0].to_f
Instead of that I was looking for a more elegant solution like:
sfa = Sketchup.read_default('liquidsscalefactor','value', 0).to_f
but that's not possible?
TIG, Thnx for your help once again, I lost count already
-
Your
sfa = Sketchup.read_default('liquidsscalefactor', 'value', 0).to_f
will work without intermediate steps... although I'd set the fall-back option to '0'. -
@tig said:
Your
sfa = Sketchup.read_default('liquidsscalefactor', 'value', 0).to_f
will work without intermediate steps... although I'd set the fall-back option to '0'.I got it working like this:
sf = (Sketchup.read_default 'liquidsscalefactor', 'value', '0')[0].to_f
final code in first post. Thnx!
-
Should NOT need the [] - the returned value should be a string ''
-
Downloaded the latest version. Here what is happening.
-
If you don't put a value to the scale, the model disappears.
-
The model does not stay at it's present locations like the previous version did.
Ken
-
-
The scale should default to 1000 if it's not set, or to another value if it has been set before...
-
Hi Ken, you were right! Thanx for the feedback
Solved both problems,
It's only possible to enter a number > 0
You now can choose between scale about origin or scale about object's center.
The default is to scale about the object's center. If you want to change that, open the ruby-file and uncomment
(remove the #) the first line of code. Please reboot ruby to make it work.Latest version in topic-start
-
Hi TIG,
Would you be so kind to inspect my code briefly to see if there are things that could be done in a better way or are
actually wrong but function by accident?? (code in first topic)And a question
The script accepts only input if its a number > 0 It accepts for instance numbers like 1.90.
But it also accepts numbers like 1,90. Nothing happens then when you
try to use it.
How can I filter this kind of input?I other words, how do I program this:
@@x = 1,90 If x contains ',' do something
?
Thank you
-
Try these tweaks
module Bhelper sf = **'1000.0'**
To make it a 'string'.
Then
@@sf = Sketchup.read_default('liquidsscalefactor','value'**,'1000.0'**)**.to_f**
to trap for it not having set [should never happen!] and.to_f
to turn the read string into a 'float'.
You don't need
@@sf = results.to_s.to_f
as it's now already a float, and should be got thus from the input@@sf=results[0]
@@sf = results
is wrong/duplicated AND also
Sketchup.write_default('liquidsscalefactor','value',@@sf**.to_s**)
should be inside the 'begin' section, otherwise it 'fires' even after an error.In your two similar classes
def initialize() sf = (Sketchup.read_default 'liquidsscalefactor', 'value', '0')[0].to_f
should both become
def initialize() sf = (Sketchup.read_default 'liquidsscalefactor', 'value', '1000.0')**.to_f**
-
Well I tried again. This time I get the error code "NilClass"
Ken
-
Ken
Please bear with him...
This is his first Ruby and whilst it is a good idea it needs some 'fine tuning' -
@tig said:
Ken
Please bear with him...
This is his first Ruby and whilst it is a good idea it needs some 'fine tuning'Hello TIG
I was, I waited and no one else seemed to have this problem. I am not in a hurry just trying to get to him info. He is a lot further along in Ruby than I am.
Ken
-
HI Ken and TIG,
Thanx for your feedback, I really enjoy learning to code with your help!
I decided to change the approach of Booleanhelper a bit. In the latest version (1.04) its only possible to scale with factor 10, 100, or 1000. You can choose a value from a dropdown-menu.
I've done this because the plugin is only needed to temporary scale up and down a model.
If you work on a scaled up model for instance with scale 100 you can adapt your measurements easily.
In other words, it makes no sense to scale up and down with a factor of eg 9,81.@TIG Here is the code of version 1.04. I managed to integrate the scalefactor in the tooltip of the toolbar icons, but the method I used for the tooltips is not working for the menu-items, unfortunately.
Further I put this piece of code in the Getinfo class. As a result the tooltips only update after setting the scalefactor. My idea was to put the code for the tooltip outside the classes, but to no avail;<span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /><br /></span><span class="syntaxcomment">#=============================================================================<br /></span><span class="syntaxdefault"> <br /> <br /> </span><span class="syntaxcomment">#$booleanhelper_scaleoption = 1 # Uncomment the first line of code to scale your object about the origin. ( Restart needed!)<br /></span><span class="syntaxdefault"> <br /> </span><span class="syntaxcomment"># Leave it as it is to scale your object about it's center.<br /></span><span class="syntaxdefault"> <br /><br /><br /><br /><br /><br /><br />module Bhelper<br /><br /> sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 100<br /> if Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_default</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> nil<br /> <br /> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">write_default</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">sf</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> end <br /> <br /><br /> <br />class Getinfo<br /> <br /> def initialize</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> <br /> <br /> <br /><br /> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_default</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> prompts </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxstring">"Set scalefactor "</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> <br /> defaults </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[@@</span><span class="syntaxdefault">sf</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> values </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxstring">"10|100|1000"</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># For other scale factors please use the native Sketchup-scale tool . This script is intended only for quick scale up and down actions .<br /><br /></span><span class="syntaxdefault"> <br /> results </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">inputbox prompts</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> defaults</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> values</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Scalefactor."<br /></span><span class="syntaxdefault"> <br /> return if not results<br /><br /> <br /> <br /> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> results</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> <br /> <br /> $cmdbooleanhelperscale</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">tooltip </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Scalefactor#{@@sf}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /> $cmdbooleanhelperscale1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">tooltip </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Scalefactor#{@@sf}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">write_default</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">,@@</span><span class="syntaxdefault">sf</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> <br /> <br /> <br /> end<br /><br />end<br /><br /><br /> <br /><br /><br />class Kleiner<br /> <br /> def initialize</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> <br /> sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_default </span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'100'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">to_f<br /> <br /> model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities<br /> selection </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br /> <br /> boundbox </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br /> center</span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> boundbox</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">center<br /><br /> <br /> if $booleanhelper_scaleoption </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> 1<br /> <br /> center </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> <br /> <br /> end <br /> <br /> trans </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">scaling</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 1.0</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">sf</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform_entities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> selection</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> </span><span class="syntaxcomment">#new_view = view.zoom_extents<br /></span><span class="syntaxdefault"> <br /> end<br />end<br /><br /><br /><br /><br /><br />class Groter<br /> <br /> def initialize</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> <br /> sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">read_default </span><span class="syntaxstring">'liquidsscalefactor'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'100'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">to_f<br /> <br /> model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> entities</span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities<br /> selection </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br /> <br /> <br /> <br /> boundbox </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br /> center</span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> boundbox</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">center<br /> <br /> <br /> if $booleanhelper_scaleoption </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> 1<br /> <br /> center </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> <br /> <br /> <br /> end<br /><br /> trans </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">scaling</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">center</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> sf</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform_entities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> selection</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> </span><span class="syntaxcomment">#new_view = view.zoom_extents<br /></span><span class="syntaxdefault"> <br /> end<br />end<br /><br /><br /> <br /> <br /> <br /> <br /><br /></span><span class="syntaxcomment">#=============================================================================<br /></span><span class="syntaxkeyword">if(</span><span class="syntaxdefault"> not $booleanhelper_menu_loaded </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> <br /> add_separator_to_menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> new_menu </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">add_submenu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Boolean helper"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> new_toolbar </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Toolbar</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">"Boolean helper"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> plugins </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find_support_file</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> imgdir </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">plugins</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Booleanhelper"</span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> $cmdbooleanhelperscale </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Command</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">"Scale down"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">Bhelper</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Kleiner</span><span class="syntaxkeyword">.new()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> $cmdbooleanhelperscale</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">small_icon </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">imgdir</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"smaller.png"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> $cmdbooleanhelperscale</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">large_icon </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">imgdir</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"smallerL.png"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> <br /><br /> new_menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$cmdbooleanhelperscale</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> new_toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$cmdbooleanhelperscale</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> $cmdbooleanhelperscale1</span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Command</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">"Scale up"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">Bhelper</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Groter</span><span class="syntaxkeyword">.new()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> $cmdbooleanhelperscale1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">small_icon </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">imgdir</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"bigger.png"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> $cmdbooleanhelperscale1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">large_icon </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">imgdir</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"biggerL.png"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /><br /><br /> new_menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$cmdbooleanhelperscale1</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> new_toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$cmdbooleanhelperscale1</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> cmd </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Command</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">"set scale factor"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">Bhelper</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Getinfo</span><span class="syntaxkeyword">.new()}<br /></span><span class="syntaxdefault"> <br /> new_menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">cmd</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> new_toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show<br /><br /> $booleanhelper_menu_loaded </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> true<br />end <br /><br />end </span><span class="syntaxcomment">#module </span><span class="syntaxdefault"></span>
-
Your
$cmdbooleanhelperscale.tooltip = ("Scalefactor#{@@sf}")
does work IF you change the scale-factor... so set it to work at initialization...
To get the tooltips working from initialization you must set the tooltip in each of the buttons' initialization code; after the @@sf has be established.
Incidentally this is a clever way of having a changing tooltip... where bit you glean it from? Or was it of your own devising??A few more observations - some very minor:-
For
$cmdbooleanhelperscale1
a 1.0/ version -$cmdbooleanhelperscale1.tooltip = "Scalefactor #{1.0/@@sf}"
as it'd make it clearer which is increasing and which is decreasing.Set
$cmdbooleanhelperscale.tooltip = ("Scalefactor#{@@sf}")
with a space between the text and 'number' like "Scalefactor #{@@sf}".Wouldn't it be good to re-zoom after you scale stuff? To do this add
Sketchup.send_action("viewZoomExtents:")
to your methods, immediately after the scaling has been done.'Capitalize' or 'Title-Case' the menu item text where you set the scale factor.
-
Hi TIG, thanx again for your suggestions.
What do you exactly mean by initialization?
@unknownuser said:... so set it to work at initialization...
To me its seems logical to put
@@sf = (Sketchup.read_default 'liquidsscalefactor', 'value', '100').to_s $cmdbooleanhelperscale.tooltip = ("Scalefactor #{@@sf}") $cmdbooleanhelperscale1.tooltip = ("Scalefactor #{@@sf}") $cmdbooleanhelperscale.menu_text = ("Scalefactor #{@@sf}") $cmdbooleanhelperscale1.menu_text = ("Scalefactor #{@@sf}")
in the beginning of the script. Tried that, but it doesn't work. Sketchup gives this error:
undefined method `tooltip=' for nil:NilClassWhen I place the tooltip and menu_text lines in the Getinfo class, the tooltip works but the menu-text falls back on the name in
$cmdbooleanhelperscale = UI::Command.new("Scale down") {Bhelper::Kleiner.new() }
in this case 'Scale down'.Furter,
$cmdbooleanhelperscale1.tooltip = "Scalefactor #{1.0/@@sf}
does not work.......??After some trial and error I eventually found out about how to put a variable in a tooltip.
I already had your suggestion about the tooltip, later I found out how to combine text and variables in
a messagebox. Just combined two pieces of existing information...About the re-zoom, I tried that. But in the case of rezoom there's no feedback on the scale-action.
You just see the same shape as before. A message-box wouldn't work that good, because you have to
click it away, it interrupts the flow of use.First post: plugin + toolbar images
-
When I say 'initialization' it is simply within the method that runs with a
.new()
command - i.e.def initialize()
...Using
$cmdbooleanhelperscale.tooltip = ("Scalefactor #{@@sf}") **if $cmdbooleanhelperscale**
should avoid the error - it's not set at some point... repeat for$cmdbooleanhelperscale1
etc etc...After you have done the scaling transformation simply add the 'zoom-extents' line I gave you [i.e. into the end of the two initialize methods for scale-up/scale-down]... There's no need for UI 'inputs' here ?
-
@tig said:
$cmdbooleanhelperscale.tooltip = ("Scalefactor #{@@sf}") if $cmdbooleanhelperscale
works ok!
does
if $variable
mean introducing some variable?I tried to introduce
#booleanhelperscale
with$booleanhelperscale = nil
but no succes!I really still have no clue were to put the code.. Because when you open Sketchup the code has to run otherwise no tooltip is available... So it has to be on two places, once in the getinfo class (to update the scalefactor and once somewere else to load at the time Sketchup application starts up. :?:
I'm sure there is some elegant solution for this problem..About the zoom extents, i think you misunderstood.. I was discussing the possibility of an UI.messagebox to give feedback on the scale action. Zoom extents alone provides no feedback on the scale-operation. (The same shape remains on the screen) So i don't want to put it in the script without proper feedback. Messesagebox "Scaled up! Done" is no option because you have to click on it to continue your work.
-
Hello TIG,
I got everything working now. I made a new class and put everything for the tooltips in there. I call the class in Getinfo, and in the menu-loader section.
I got this feeling the script is finished nowThanks again for your great help. What is keeping you busy lately ??
Regards,
Liquid
-
Oops!
Following error code on my machine.
Error Loading File booleanhelper1.05.rb
undefined method `to_f' for [10]:ArrayNotice, I have been following this thread not so much as I need the plugin, just trying to keep up with the programing.
Ken
-
How is this plugin not called "ScaleUp.rb"?
Advertisement