# Copyright 2005, @Last Software, Inc. # This software is provided as an example of using the Ruby interface # to SketchUp. # Permission to use, copy, modify, and distribute this software for # any purpose and without fee is hereby granted, provided that the above # copyright notice appear in all copies. # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #----------------------------------------------------------------------------- require 'sketchup.rb' #----------------------------------------------------------------------------- # Needs clearer documentation. This method parses a string, which is in the form # of a length and then returns a Length object with the value (in current units). def toLStringTest teststring = "3.2m" begin len = teststring.to_l rescue UI.messagebox $!.message end if (len) UI.messagebox len else UI.messagebox "Failure" end end if( not file_loaded?("stringtests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") StringTest_menu = plugins_menu.add_submenu("String Tests") StringTest_menu.add_item("String.to_l") { toLStringTest } end #----------------------------------------------------------------------------- file_loaded("stringtests.rb")