Model GeoReference

I had a Ruby application back around 2008-2012. It used the code below to set the model GeoReference. When I use the same code now (in SketchUp 2021 and 2022), it does not seem to work. The printf line at the end prints out the latitude and longitude I intended to set, but when I look at the “Geo-Location” tab in the “Model Info” window, it says “this model is not geo-located”

Is there something else I need to do? Here is the code:

    model.shadow_info["Latitude"]  = latitude
    model.shadow_info["Longitude"] = longitude
    model.shadow_info["NorthAngle"] = 0.0
    model.attribute_dictionary("GeoReference", true)
    model.set_attribute("GeoReference", "Latitude", latitude)
    model.set_attribute("GeoReference", "Longitude", longitude)
    model.set_attribute("GeoReference", "GeoReferenceNorthAngle", 0.0)
    model.set_attribute("GeoReference", "LocationSource", "Manual")
    model.set_attribute("GeoReference", "ModelTranslationX", 0)
    model.set_attribute("GeoReference", "ModelTranslationY", 0)
    model.set_attribute("GeoReference", "ModelTranslationZ", 0)
    model.set_attribute("GeoReference", "ZValueCentered", 0)
    model.set_attribute("GeoReference", "UsesGeoReferencing", true)
    printf("tf_geoReference: %f, %f\n", latitude, longitude)

Is that required?

It’s better for all of us. You can edit your post, you don’t need to write again.

Yes, the forum converts quotation marks to smart quotes, so we cannot copy and paste your code (as is) to test.

    model.shadow_info["Longitude"] = longitude
    model.shadow_info["NorthAngle"] = 0.0
    model.attribute_dictionary("GeoReference", true)
    model.set_attribute("GeoReference", "Latitude", latitude)
    model.set_attribute("GeoReference", "Longitude", longitude)
    model.set_attribute("GeoReference", "GeoReferenceNorthAngle", 0.0)
    model.set_attribute("GeoReference", "LocationSource", "Manual")
    model.set_attribute("GeoReference", "ModelTranslationX", 0)
    model.set_attribute("GeoReference", "ModelTranslationY", 0)
    model.set_attribute("GeoReference", "ModelTranslationZ", 0)
    model.set_attribute("GeoReference", "ZValueCentered", 0)
    model.set_attribute("GeoReference", "UsesGeoReferencing", true)
    printf("tf_geoReference: %f, %f\n", latitude, longitude)

Just a thought interjected here. The “GeoReference” attribute dictionary (I think) was originally designed to be populated by the built-in Google Earth location service. (This would populate the X, Y, and Z attributes in inches from the geographic datum.)

When Google sold SketchUp to Trimble the latter was given a certain amount of time to wean off of using Google Earth. The built-in location feature now uses other non-Google services. (I am unsure if they even use this old dictionary.)

The change you’ve noticed (circa SU2021 release) might coincide with the full weaning from Google Earth.


Besides (or perhaps instead of) setting the values in the “GeoReference” attribute dictionary, I think you likely need to set some values in the model’s ShadowInfo object.

  • EDIT: I see you did set longitude, latitude and north angle in shadow info.

Also there are several open API issues: