Georeferencing
-
Has anyone found a Ruby method to enable the "Use georeferencing" checkbox in Model info:location?
I've scanned the API but no luck. -
Hi John,
I did some playing around... found that a new attribute_dictionary is created when you turn on Georeferencing the fist time - the AD is named "GeoReference"
The dictionary stays when the Georeferencing option is then disabled, but there is a flag in the attribute dictionary itself called "UsesGeoReferencing".
ad = Sketchup.active_model.attribute_dictionary("GeoReference") #<Sketchup;;AttributeDictionary;0x7524320> ad.to_a [["Latitude", 40.017], ["LocationSource", "Manual"], ["Longitude", -105.283], ["ModelTranslationX", -18734219.6437523], ["ModelTranslationY", -174396944.990963], ["ModelTranslationZ", 0.0], ["UsesGeoReferencing", false], ["ZValueCentered", 0.0]] -
Thanks, Jim.
Working off your observation, I opened a new drawing, and as you said, the attribute dictionary "Georeference" is empty. All the default geodata is in the shadow_info object (or hash, I'm not sure of the proper term). I listed it like this:am = Sketchup.active_model #<Sketchup;;Model;0x63be010> am.shadow_info.each{|k,v| puts "#{k} #{v}"} City Boulder (CO) Country USA Dark 45 DayOfYear 312 DaylightSavings false DisplayNorth false DisplayOnAllFaces true DisplayOnGroundPlane true DisplayShadows false EdgesCastShadows false Latitude 40.017 Light 80 Longitude -105.283 NorthAngle 0.0 ShadowTime Fri Nov 08 07;30;00 Central Standard Time 2002 ShadowTime_time_t 1036762200 SunDirection (-0.423824071310226, -0.772439983723215, 0.472979521886207) SunRise Fri Nov 08 00;43;14 Central Standard Time 2002 SunRise_time_t 1036737794 SunSet Fri Nov 08 10;46;34 Central Standard Time 2002 SunSet_time_t 1036773994 TZOffset -7.0 UseSunForAllShading false nilChecking the "Use Georeference" box creates the attribute dictionary and probably uses the shadow_info coordinates to set the lat and long.
I want to programatically check the "Use Georeference" box on a batch of files. I can't assume it exists so I'll need to create the attribute dictionary "Georeference" exactly. I suppose I should make the shadow lat/long and the georeference lat/long match to avoid future confusion.
I this the way to go? -
Hi John,
That seems reasonable to me. It does look like the Lat/Lon are taken from the Shadow_Info, but I have no idea what the other attributes in GeoReference mean. I think you'll just have to experiment until you figure it out.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement