# 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' #----------------------------------------------------------------------------- def newLatLongTest ll = [40.01700, 105.28300] latlong = Geom::LatLong.new(ll) if (latlong) UI.messagebox latlong else UI.messagebox "Failure" end end def latitudeLatLongTest coordinates = [10, 10, 10] model = Sketchup.active_model point = Geom::Point3d.new(coordinates) latlong = model.point_to_latlong point latitude = latlong.latitude if (latitude) UI.messagebox latitude else UI.messagebox "Failure" end end def longitudeLatLongTest coordinates = [10, 10, 10] model = Sketchup.active_model point = Geom::Point3d.new(coordinates) latlong = model.point_to_latlong point longitude = latlong.longitude if (longitude) UI.messagebox longitude else UI.messagebox "Failure" end end # converts a latlong to an array of two values. def toALatLongTest coordinates = [10, 10, 10] model = Sketchup.active_model point = Geom::Point3d.new(coordinates) latlong = model.point_to_latlong point a = latlong.to_a if (a) UI.messagebox a else UI.messagebox "Failure" end end def toSLatLongTest coordinates = [10, 10, 10] model = Sketchup.active_model point = Geom::Point3d.new(coordinates) latlong = model.point_to_latlong point s = latlong.to_s if (s) UI.messagebox s else UI.messagebox "Failure" end end def toUTMLatLongTest coordinates = [10, 10, 10] model = Sketchup.active_model point = Geom::Point3d.new(coordinates) latlong = model.point_to_latlong point utm = latlong.to_utm if (utm) text = utm.to_s UI.messagebox text else UI.messagebox "Failure" end end if( not file_loaded?("latlongtests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") LatLong_menu = plugins_menu.add_submenu("LatLong Tests") LatLong_menu.add_item("LatLong::new") { newLatLongTest } LatLong_menu.add_item("LatLong.latitude") { latitudeLatLongTest } LatLong_menu.add_item("LatLong.longitude") { longitudeLatLongTest } LatLong_menu.add_item("LatLong.to_a") { toALatLongTest } LatLong_menu.add_item("LatLong.to_s") { toSLatLongTest } LatLong_menu.add_item("LatLong.to_utm") { toUTMLatLongTest } end #----------------------------------------------------------------------------- file_loaded("latlongtests.rb")