[Plugin] Boolean helper update 08122011
-
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"?
-
@jim said:
How is this plugin not called "ScaleUp.rb"?
It's use is to quickly scale up and down a model. Why?
If one is working on small parts in SU for instance for 3d printing, some operations like the boolean operations and lathe result in errors with small vertices's/faces. SU has problems handling these small entities. If you temporarily scale up your model, you don't have these problems. After the operations are done , you can scale down again.So that's why the plugin is named booleanhelper. Simple but effective.
-
Jim's 'joke' refers to the fact that a lot of SketchUp tools have similar sounding names and you do 'ScaleUp' things using your tool - I suspect that it's 'lost in translation' ?
Another couple of things...
view.zoom_extents
must be
Sketchup.active_model.active_view.zoom_extents
as you haven't defined 'view' otherwise.
An alternative is
Sketchup.send_action("viewZoomExtents:")
a = Sketchup.read_default('liquidsscalefactor','value')
would be better to trap older wrong class-type values [your earlier version probably saved the value as the wrong 'type' - it should be saved as a 'String'] - like...
a = Sketchup.read_default('liquidsscalefactor','value'**,'100'**) if a.class==String a=a.to_f else ### might be an Array or something else! a=100.0 end#if
The basic Array class doesn't have '.to_f' as a method... although some scripts might extend that class methods and add it... and then there might not be an error like that, BUT best fixed in your code... -
@unknownuser said:
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
Hi Ken,
Thanx for the feedback, Boolean helper writes the scalefactor to the registry. I think an old value from previous version sits there. To fix it
Copy this code:
Sketchup.write_default('liquidsscalefactor','value',100)
And paste it in your ruby-console, press Enter and restart SU, and let me know if it worked...
-
Please write/read your values as a String - '100' etc.
It's safest to be consistent.
I know and integer like 100 would be OK and make a float 100.0 but so would '100'...
As explained an Array like you tried initially [100] is likely to break it ! -
@ Jim, no i did not get your joke .... Lost in translation I suppose
I've set everything to string now:
<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 />module Bhelper<br /><br /> sf </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'100'<br /></span><span class="syntaxdefault"> 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 /> class Tltip<br /> <br /> def initialize</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> <br /><br /> <br />a </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">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'100'</span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault">if a</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">class </span><span class="syntaxkeyword">==</span><span class="syntaxdefault">String<br />a</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">a</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_f<br />else </span><span class="syntaxcomment">### might be an Array or something else!<br /></span><span class="syntaxdefault">a</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">100.0<br />end</span><span class="syntaxcomment">#if<br /><br /><br /><br /></span><span class="syntaxdefault">b </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 1.0</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">a<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 #{b}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $cmdbooleanhelperscale<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 #{a.to_i}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $cmdbooleanhelperscale1<br />$cmdbooleanhelperscale</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu_text </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Scalefactor #{b}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $cmdbooleanhelperscale<br />$cmdbooleanhelperscale1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu_text </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Scalefactor #{b}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $cmdbooleanhelperscale1<br /> end<br /> <br /> end<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">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'100'</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">].</span><span class="syntaxdefault">to_s<br /> <br /> <br /> <br /> <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 />Bhelper</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Tltip</span><span class="syntaxkeyword">.new()<br /><br /></span><span class="syntaxdefault"> <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 /></span><span class="syntaxdefault"> <br /> <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 />Bhelper</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Tltip</span><span class="syntaxkeyword">.new()<br /></span><span class="syntaxdefault"> $booleanhelper_menu_loaded </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> true<br />end <br /><br />end </span><span class="syntaxcomment">#module<br /><br /></span><span class="syntaxdefault"> </span>
Is it correct like this??
-
if Sketchup.read_default('liquidsscalefactor','value', '100') == nil Sketchup.write_default('liquidsscalefactor','value',sf) end
Will never==nil
as you tell it to set it to '100' if it is nil in the 'read_default' [the third optional argument].
It's better to use something like my example... where you read its value, and it's set as '100' it it's NOT already set at all, OR it's set to be whatever it's value is already when read; then IF it's not s string it's set to '100' - to rescue us from you having accidentally setting it to something like an Array [100] etc in an earlier version...
Just read through your code and every time you read/write/get/set sf/@@sf etc check it's a string - except when you use it in a calculation - for the Scaling etc - where you use .to_f on it to turn it from a string into a float value - as the scale wants a 'number' - the registry entry and inputbox dialog use a 'string'... -
if Sketchup.read_default('liquidsscalefactor','value', '100') == nil
Little mistake, replaced all the read_default lines in the same way.. (in the editor)
-
hi,
I've been following this topic due to a keen interest in 3d printing, and have wanted to make a suggestion.
I can't find the code I played around with in the past which is the basis of my suggestion,
however Jim mentioned where it comes from in another post today, so I'll simply pass that on...http://code.google.com/apis/sketchup/docs/ourdoc/model.html#add_notethe idea is just write a screen note when working at scale and remove it when back to output scale.
I was looking into actually blocking exporting at scale, but didn't get it working.
I haven't had time yet, but I'll do some Mac tests and let you know if there are any issues.
john
-
@driven said:
hi,
I've been following this topic due to a keen interest in 3d printing, and have wanted to make a suggestion.
I can't find the code I played around with in the past which is the basis of my suggestion,
however Jim mentioned where it comes from in another post today, so I'll simply pass that on...http://code.google.com/apis/sketchup/docs/ourdoc/model.html#add_notethe idea is just write a screen note when working at scale and remove it when back to output scale.
I was looking into actually blocking exporting at scale, but didn't get it working.
I haven't had time yet, but I'll do some Mac tests and let you know if there are any issues.
john
Hi John,
I like your idea's! I know from experience that exporting a model in the wrong scale is a common mistake in 3D printing design... Not a lethal mistake, unless you order the model in the wrong size... Maybe there's something like a Read-only or immune method in Ruby, I will look for that...
Also the idea of model-notes is a good idea. I suggest an 'X' sign for every scale-up action. So when the model is in normal state no X sign is visible. If you've triple-scaled your model there will be three X's in the left top of the screen.
Also the X model-note provides a good feedback on the scale action, so after the scale action the script can do viewZoomExtents without loosing your sense of scale.
I'm also curious how this script behaves on the mac, so let me know..
Advertisement