Is there anyway to open the Geo-location->Add location dialog by ruby?

geolocation
georeference

#1

I just want to open the dialog in my own plugin. Or if there is anyway to call the function of a exist menu?

Thanks!


Geocoder for Sketchup ruby API
#2

PC ONLY

Set up local integer constants within your module:

GEOLOCATION_ADD_DIALOG = 24216

So call the dialog (from within your module) via:

Sketchup::send_action(GEOLOCATION_ADD_DIALOG)

I do not know the Automation ID for the “Set Manual Location” button. Jim Foltz has a quick & dirty inputbox script that mimics the native manual location dialog.


#3

Thanks for your help!


#4

Hello Dan,

Another question, is there a action number means “Clear Geo Location”?

Thanks again.


#5

GEOLOCATION_CLEAR = 24197

You can test a model instance if it is geo-located:
Sketchup::active_model.georeferenced?

But it looks like “Clear Geo-Location” command does NOT reset the model’s shadow info hash, nor remove the model’s “GeoReference” attribute dictionary that the “Add Location” dialog created.


#7

It’s enough to meet my needs.
Thanks a lot.

BTW,seems like many functions useful(GEOLOCATION_ADD_DIALOG, GEOLOCATION_CLEAR, etc.) aren’t wrote in the API document. Do you know why?


#8

Keep in mind those are just constant names that * I myself * made up.

No not really something I can answer definitively. Seems a simple question, but the reality is complex. SketchUp has been owned by 3 separate companies so far, each having different goals for SketchUp and it’s APIs. Priorities change from time to time, etc.

Basically I can only guess that these kinds of things are low priority, and never rise to the top of the “to do” list.


#9

Hi, Dan,
I would like to know for the actions add/clear Geolocation, if there is any way to do that by ruby script for Mac?
Thanks


#10

You can open the regular geo-location dialog on the Mac via:

Sketchup.send_action "showGeoLocation:"

If a location has been set, you can clear it via:

Sketchup.send_action "clearLocation:"

Since a Geo Location involves multiple values. If you want to set them entirely via Ruby you need to manipulate the appropriate entries in the model’s ShadowInfo object, accessed via Model#shadow_info


#11

Thanks dude, I’ve check these actions and they work, but i means open the dialog of adding Google maps directly instead of regular dialog, if it is possible?

Thanks again


#12

That one I don’t know. Will take some research to see. I should point out that neither of the actions I gave before are officially documented.


#14

Yeah i noticed that, really admire that you can find these deep hided strings :grinning:

Thanks


#15

Try this one:

Sketchup.send_action "importFromGoogleEarth:"

Again, with the warning that these actions are undocumented so you use them at your own risk. Since Trimble chose not to explain them, I can’t give you any assurance about whether they have side effects or bugs. Nor about which versions of SketchUp do or do not support them.