# 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. # A ShadowInfo object contains the following Keys: # City (Location), Country, Dark MI>S (20), DaylightSavings (false), DisplayNorth - MI>Location>ShowInModel (false), DisplayOnAllFaces MI>S (true), DisplayOnGroundPlane MI>S (true) # DisplayShadows ModelInfo > Shadows (false), EdgeCastShadows MI>S (false), Latitude (Set Custom Location 40.017), Light MI>S (80), Longitutde - SCL (-105.283), NorthAngle - MI>Location (0.0), # ShadowTime MI>S (Mon Jun 21 07:30:00 Mountain Daylight Time 2004) # SunRise (Sun Jun 20 22:37:22 Mountain Daylight Time 2004), SunSet (Mon Dun 21 13:28:22 Mountain Daylight Time 2004), TZOffset - SCL (-7.0), UseSunForAllShading (false), def eachKeyClassShadowTest Sketchup::ShadowInfo.each_key { |key | UI.messagebox key } end def keysClassShadowTest key = Sketchup::ShadowInfo.keys[0] UI.messagebox key end def getValueShadowTest model = Sketchup.active_model shadowinfo = model.shadow_info value = shadowinfo["City"] UI.messagebox value end def setValueShadowTest model = Sketchup.active_model shadowinfo = model.shadow_info value = shadowinfo["City"] UI.messagebox value value = shadowinfo["City"]="Denver, CO" UI.messagebox value end def eachShadowTest model = Sketchup.active_model shadowinfo = model.shadow_info shadowinfo.each { |key, value| UI.messagebox key } shadowinfo.each { |key, value| UI.messagebox value } end def eachKeyShadowTest model = Sketchup.active_model shadowinfo = model.shadow_info shadowinfo.each_key { |key | UI.messagebox key } end def keysShadowTest model = Sketchup.active_model shadowinfo = model.shadow_info keys = shadowinfo.keys key = keys[0] UI.messagebox key end if( not file_loaded?("shadowinfotests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") ShadowInfo_menu = plugins_menu.add_submenu("ShadowInfo Tests") ShadowInfo_menu.add_item("ShadowInfo.each_key (class)") { eachKeyClassShadowTest } ShadowInfo_menu.add_item("ShadowInfo.keys (class)") { keysClassShadowTest } ShadowInfo_menu.add_item("ShadowInfo.[]") { getValueShadowTest } ShadowInfo_menu.add_item("ShadowInfo.[]=") { setValueShadowTest } ShadowInfo_menu.add_item("ShadowInfo.each") { eachShadowTest } ShadowInfo_menu.add_item("ShadowInfo.each_key") { eachKeyShadowTest } ShadowInfo_menu.add_item("ShadowInfo.keys") { keysShadowTest } end #----------------------------------------------------------------------------- file_loaded("shadowinfotests.rb")