# model_location.rb (C) 2006 jim.foltz@gmail.com # # Adds a "Lat/Long" option under the Plugins menu. # There is no error checking. # def getLatLong shadow_info = Sketchup.active_model.shadow_info si = shadow_info lat = shadow_info["Latitude"] lon = shadow_info["Longitude"] north_angle = shadow_info["NorthAngle"] city = si["City"] country = si["Country"] prompts = ["Location (City)", "Country","Latitude", "Longitude", "Show North Angle? ", "North Angle"] choices = ["", "","", "", "true|false", ""] defaults =[city, country, lat, lon, "false", north_angle] ret = UI.inputbox( prompts, defaults, choices, "Latitude / Longitude" ) return unless ret # Program exits here if user hits Cancel button # # User hits OK, so set values shadow_info["City"] = ret[0] shadow_info["Country"] = ret[1] shadow_info["Latitude"] = ret[2] shadow_info["Longitude"] = ret[3] shadow_info["DisplayNorth"] = eval(ret[4]) shadow_info["NorthAngle"] = ret[5] # No confirmation, re-run to see values. end file = "model_location.rb" unless file_loaded?(file) UI.menu("Plugins").add_item("Location") { getLatLong } file_loaded(file) end