How to find model's current geo-location via API

Looking for a command that will report back the current model’s geo-location in Lat/Long, just like it shows in the Model Info dialog. Any ideas?

You can use the ShadowInfo class, which contains various properties related to shadows and geo-location. Here is how you can retrieve geo-location (latitude, longitude) and other related information:

# Access the active model's ShadowInfo
shadow_info = Sketchup.active_model.shadow_info

# Retrieve geo-location information
latitude = shadow_info["Latitude"]
longitude = shadow_info["Longitude"]

# Additionally, you can access other related properties
city = shadow_info["City"]
country = shadow_info["Country"]
north_angle = shadow_info["NorthAngle"]
time_zone = shadow_info["TZOffset"]

# Output the geo-location information
puts "Latitude: #{latitude}"
puts "Longitude: #{longitude}"
puts "City: #{city}"
puts "Country: #{country}"
puts "North Angle: #{north_angle} degrees"
puts "Time Zone Offset: #{time_zone}"

This script accesses the active SketchUp model’s ShadowInfo and retrieves the latitude and longitude, which represent the geo-location. It also demonstrates how to access additional related information such as the city, country, the angle towards the north, and the time zone offset if available. Keep in mind that the availability of city and country information depends on whether the model has been geo-located using SketchUp’s “Add Location” feature.


Perfect, many thanks!