# 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' #----------------------------------------------------------------------------- # Default leadertype is Hidden. Apparently all text has a leader. So, why have this API? # This test just looks up all of the numerical values for leaders and arrows # and returns their string representation in SketchUp. This is not part of the # API, but was created to determine the range of return values for some methods. def eachKeyClassRenderingOptionsTest Sketchup::RenderingOptionsInfo.each_key { |key | UI.messagebox key } end def keysClassRenderingOptionsTest key = Sketchup::RenderingOptionsInfo.keys[0] UI.messagebox key end def getValueRenderingOptionsTest model = Sketchup.active_model renderingoptions = model.rendering_options begin value = renderingoptions["DisplayInstanceAxes"] rescue UI.messagebox $!.message end UI.messagebox value end def setValueRenderingOptionsTest model = Sketchup.active_model renderingoptions = model.rendering_options value = renderingoptions["DisplayInstanceAxes"] UI.messagebox value value = renderingoptions["DisplayInstanceAxes"] = true UI.messagebox value end def eachRenderingOptionsTest model = Sketchup.active_model renderingoptions = model.rendering_options renderingoptions.each { |key, value| UI.messagebox key } renderingoptions.each { |key, value| UI.messagebox value } end def eachKeyRenderingOptionsTest model = Sketchup.active_model renderingoptions = model.rendering_options renderingoptions.each_key { |key | UI.messagebox key } end def keysRenderingOptionsTest model = Sketchup.active_model renderingoptions = model.rendering_options keys = renderingoptions.keys key = keys[0] UI.messagebox key end if( not file_loaded?("renderingoptionstests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") RenderingOptions_menu = plugins_menu.add_submenu("RenderingOptions Tests") RenderingOptions_menu.add_item("RenderingOptions.each_key (class)") { eachKeyClassRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.keys (class)") { keysClassRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.[]") { getValueRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.[]=") { setValueRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.each") { eachRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.each_key") { eachKeyRenderingOptionsTest } RenderingOptions_menu.add_item("RenderingOptions.keys") { keysRenderingOptionsTest } end #----------------------------------------------------------------------------- file_loaded("renderingoptionstests.rb")