TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Jeremy Dunn on April 05, 2018, 05:18:39 PM

Title: Open Google Earth
Post by: Jeremy Dunn on April 05, 2018, 05:18:39 PM
I have never interacted with Google Earth through AutoLISP so I hope someone here can help out. I am trying to write a function that will take a latitude and longitude and open up Google Earth to that location. Has someone already done this?
Title: Re: Open Google Earth
Post by: lamarn on April 05, 2018, 05:34:42 PM
As extra feature for IRT, that would be a killer app!
Title: Re: Open Google Earth
Post by: NICK_VNV on April 06, 2018, 05:22:26 AM
So let's start here:

Code - Auto/Visual Lisp: [Select]
  1. (if (setq goo (vlax-create-object "GoogleEarth.ApplicationGE"))
  2.  (vl-cmdf "_delay" 3500)
  3.  (vlax-invoke-method goo 'setcameraparams 47.1036 39.4127 0 1 516.064 69.04 30.1109 5)
  4. )
  5.  (alert "Google Earth not found")
  6. )

And take some latitude and longitude, also altitude at some point :-D
Code - Auto/Visual Lisp: [Select]
  1. (setq goo (vlax-create-object "GoogleEarth.ApplicationGE"))
  2. (setq pt (vlax-invoke-method goo 'GetPointOnTerrainFromScreenCoords 47.1036 39.4127))
  3. (setq lon (vlax-get-property pt 'longitude))
  4. (setq lat (vlax-get-property pt 'latitude))
  5. (setq alt (vlax-get-property pt 'altitude))
Title: Re: Open Google Earth
Post by: Jeremy Dunn on April 06, 2018, 10:51:09 AM
Ok, we're getting closer but I need to know what the 7 numbers in 'setcameraparams mean so that I can set them properly.
Title: Re: Open Google Earth
Post by: kirby on April 06, 2018, 01:57:18 PM
Getting hard to find GE API info...

http://www.adp-gmbh.ch/win/vba/google_earth.html
8 params are:
    latitude of focus point
    longitude of focus point
    altitude of focus point
    altitude mode (unknown)
    Range
    Tilt
    Azimuth
    speed 
Title: Re: Open Google Earth
Post by: VovKa on April 06, 2018, 05:46:36 PM
As extra feature for IRT, that would be a killer app!
by writing IRT i was trying to avoid using GE :)

here's something simillar http://www.theswamp.org/index.php?topic=35739.msg536651#msg536651
Title: Re: Open Google Earth
Post by: 57gmc on April 06, 2018, 05:55:52 PM
Getting hard to find GE API info...

Looks like that may be because Google seems to be doing away with the desktop app in favor of a browser-based app. See https://www.google.com/earth/resources/ FAQ at the bottom.

For more info on Earth Engine API see https://developers.google.com/earth-engine/
Title: Re: Open Google Earth
Post by: dgpuertas on April 09, 2018, 06:56:28 AM
I have instaled Google Earth pro but when I put:

_$ (vlax-get-or-create-object "GoogleEarth.ApplicationGE")
nil
_$ (vlax-create-object "GoogleEarth.ApplicationGE")
nil
_$

Anybody knows whats happend in this case???


Thanks and sorry about my english




Title: Re: Open Google Earth
Post by: VovKa on April 09, 2018, 12:07:05 PM
I have instaled Google Earth pro but when I put:

_$ (vlax-get-or-create-object "GoogleEarth.ApplicationGE")
nil
_$ (vlax-create-object "GoogleEarth.ApplicationGE")
nil
_$

Anybody knows whats happend in this case???
i can't tell you how to solve your problem but in case you can not find the solution, try www.theswamp.org/index.php?topic=47908.0
Title: Re: Open Google Earth
Post by: Marc'Antonio Alessi on April 09, 2018, 12:18:17 PM
I have instaled Google Earth pro but when I put:

_$ (vlax-get-or-create-object "GoogleEarth.ApplicationGE")
nil
_$ (vlax-create-object "GoogleEarth.ApplicationGE")
nil
_$

Anybody knows whats happend in this case???


Thanks and sorry about my english
Maybe this can help: http://www.cruisersforum.com/forums/f121/google-earth-api-gone-144392.html
Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 03:20:53 AM
I have instaled Google Earth pro but when I put:

_$ (vlax-get-or-create-object "GoogleEarth.ApplicationGE")
nil
_$ (vlax-create-object "GoogleEarth.ApplicationGE")
nil
_$

Anybody knows whats happend in this case???


Thanks and sorry about my english
It seems GE's COM files not registered in your system. Try to register it manually. Run cmd.exe with admin rights and input two commands with right paths to directories where you installed Google Earth:
Code: [Select]
regsvr32.exe "C:\Program Files\Google\Google Earth\client\earthps.dll"
regsvr32.exe "C:\Program Files\Google\Google Earth\client\googleearth.exe"

p.s.
Also if it fails check this
http://www.nirsoft.net/utils/registered_dll_view.html
download and run regdllview.exe with admin rights and press F6, then register theese two files
Title: Re: Open Google Earth
Post by: Marc'Antonio Alessi on April 10, 2018, 03:51:12 AM
I have instaled Google Earth pro but when I put:

_$ (vlax-get-or-create-object "GoogleEarth.ApplicationGE")
nil
_$ (vlax-create-object "GoogleEarth.ApplicationGE")
nil
_$

Anybody knows whats happend in this case???


Thanks and sorry about my english
It seems GE's COM files not registered in your system. Try to register it manually. Run cmd.exe with admin rights and input two commands with right paths to directories where you installed Google Earth:
Code: [Select]
regsvr32.exe "C:\Program Files\Google\Google Earth\client\earthps.dll"
regsvr32.exe "C:\Program Files\Google\Google Earth\client\googleearth.exe"
In Pro I do not have earthps.dll  :

Comando: (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\earthps.dll")
nil

Comando: (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe")
"C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"

Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 04:02:09 AM
Main thing we need is "googleearth.exe" almost all functions are used from it
Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 04:06:09 AM
Try this
Quote
(vlax-import-type-library
  :tlb-filename
  "C:\\Program Files\\Google\\Google Earth\\client\\google~1.exe"
  :methods-prefix
  "vlg-"
  :properties-prefix
  "vlg-"
  :constants-prefix
  "gec-"
)
Then become available:
Code: [Select]
vlg-ClearResults
vlg-Clone
vlg-ConvertToZone
vlg-currentView
vlg-get-Altitude
vlg-get-AnimationController
vlg-get-AutoPilotSpeed
vlg-get-Azimuth
vlg-get-BeginTime
vlg-get-Count
vlg-get-CurrentTimeInterval
vlg-get-currentViewExtents
vlg-get-Cycles
vlg-get-Day
vlg-get-East
vlg-get-ElevationExaggeration
vlg-get-EndTime
vlg-get-FocusPointAltitude
vlg-get-FocusPointAltitudeMode
vlg-get-FocusPointLatitude
vlg-get-FocusPointLongitude
vlg-get-HasView
vlg-get-Highlighted
vlg-get-Hour
vlg-get-Item
vlg-get-Latitude
vlg-get-Longitude
vlg-get-Minute
vlg-get-Month
vlg-get-Name
vlg-get-North
vlg-get-PauseDelay
vlg-get-ProjectedOntoGlobe
vlg-get-Range
vlg-get-SearchController
vlg-get-Second
vlg-get-SliderTimeInterval
vlg-get-South
vlg-get-speed
vlg-get-StreamingProgressPercentage
vlg-get-Tilt
vlg-get-TimeInterval
vlg-get-TimeZone
vlg-get-TourController
vlg-get-Type
vlg-get-VersionAppType
vlg-get-VersionBuild
vlg-get-VersionMajor
vlg-get-VersionMinor
vlg-get-ViewExtents
vlg-get-Visibility
vlg-get-West
vlg-get-Year
vlg-get-ZeroElevationExaggeration
vlg-GetCamera
vlg-GetChildren
vlg-getCurrentVersion
vlg-GetFeatureByHref
vlg-GetFeatureByName
vlg-GetHighlightedFeature
vlg-GetLayersDatabases
vlg-GetMainHwnd
vlg-GetMyPlaces
vlg-GetParent
vlg-GetPointOnTerrainFromScreenCoords
vlg-GetRenderHwnd
vlg-GetResults
vlg-GetTemporaryPlaces
vlg-HideDescriptionBalloons
vlg-Highlight
vlg-isClientInitialized
vlg-IsInitialized
vlg-IsOnline
vlg-IsSearchInProgress
vlg-LoadKml
vlg-LoadKmlData
vlg-Login
vlg-Logout
vlg-OpenFile
vlg-OpenKmlFile
vlg-Pause
vlg-Play
vlg-PlayOrPause
vlg-put-AutoPilotSpeed
vlg-put-Azimuth
vlg-put-CurrentTimeInterval
vlg-put-Cycles
vlg-put-Day
vlg-put-ElevationExaggeration
vlg-put-FocusPointAltitude
vlg-put-FocusPointAltitudeMode
vlg-put-FocusPointLatitude
vlg-put-FocusPointLongitude
vlg-put-Hour
vlg-put-Latitude
vlg-put-Longitude
vlg-put-Minute
vlg-put-Month
vlg-put-PauseDelay
vlg-put-Range
vlg-put-Second
vlg-put-speed
vlg-put-Tilt
vlg-put-TimeZone
vlg-put-Type
vlg-put-Visibility
vlg-put-Year
vlg-QuitApplication
vlg-SaveScreenShot
vlg-Search
vlg-SetCamera
vlg-SetCameraParams
vlg-SetFeatureView
vlg-SetRenderWindowSize
vlg-setView
vlg-setViewParams
vlg-ShowDescriptionBalloon
vlg-Stop
Title: Re: Open Google Earth
Post by: dgpuertas on April 10, 2018, 04:50:05 AM
Thanks a lot, but seems that google earch api is gone in new versions......

Maybe this can help: http://www.cruisersforum.com/forums/f121/google-earth-api-gone-144392.html

Thanks Marco.

NICK_VNV: in that case (as Marco):

Code: [Select]
$ (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\earthps.dll")
nil
_$ (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe")
"C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"


$ (vlax-import-type-library
  :tlb-filename
  "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"
  :methods-prefix
  "vlg-"
  :properties-prefix
  "vlg-"
  :constants-prefix
  "gec-"
)
; error: tipo de argumento erróneo: VLA-OBJECT nil



Maybe uninstall the last version and install older is the solution.

Thanks everybody and sorry about my english.




Title: Re: Open Google Earth
Post by: Marc'Antonio Alessi on April 10, 2018, 04:57:48 AM
Thanks a lot, but seems that google earch api is gone in new versions......

Maybe this can help: http://www.cruisersforum.com/forums/f121/google-earth-api-gone-144392.html

Thanks Marco.

NICK_VNV: in that case (as Marco):

Code: [Select]
$ (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\earthps.dll")
nil
_$ (findfile "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe")
"C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"


$ (vlax-import-type-library
  :tlb-filename
  "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"
  :methods-prefix
  "vlg-"
  :properties-prefix
  "vlg-"
  :constants-prefix
  "gec-"
)
; error: tipo de argumento erróneo: VLA-OBJECT nil



Maybe uninstall the last version and install older is the solution.

Thanks everybody and sorry about my english.
me too:
$ (vlax-import-type-library  :tlb-filename  "C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe"  :methods-prefix   "vlg-"   :properties-prefix   "vlg-"  :constants-prefix   "gec-")
; error: tipo de argumento erróneo: VLA-OBJECT nil
Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 05:32:45 AM
I am using Google Earth Pro 7.3.1.4507 (32-bit) and everything works fine. What version do you have?
Title: Re: Open Google Earth
Post by: Marc'Antonio Alessi on April 10, 2018, 07:40:27 AM
I am using Google Earth Pro 7.3.1.4507 (32-bit) and everything works fine. What version do you have?
I am using Google Earth Pro 7.3.1.4507 (64-bit)
Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 08:10:07 AM
I am using Google Earth Pro 7.3.1.4507 (32-bit) and everything works fine. What version do you have?
I am using Google Earth Pro 7.3.1.4507 (64-bit)

I have uninstalled 32bit version and installed 64 bit version. Now I have the same problem.
It seems we need to use 32bit version.

p.s.
Yep I've reverted back to 32bit and it works fine again.
Title: Re: Open Google Earth
Post by: dgpuertas on April 10, 2018, 08:17:08 AM
My version
Google Earth Pro
7.3.1.4507 (64-bit)

but, can i install 32bit software in a 64bit computer?



Title: Re: Open Google Earth
Post by: NICK_VNV on April 10, 2018, 08:18:02 AM
My version
Google Earth Pro
7.3.1.4507 (64-bit)

but, can i install 32bit software in a 64bit computer?
Ofcourse
Title: Re: Open Google Earth
Post by: Marc'Antonio Alessi on April 10, 2018, 09:06:07 AM
My version
Google Earth Pro
7.3.1.4507 (64-bit)

but, can i install 32bit software in a 64bit computer?
Ofcourse
Thanks  :-)
Title: Re: Open Google Earth
Post by: rkmcswain on April 10, 2018, 10:20:36 AM
Quote from: NICK_VNV

I have uninstalled 32bit version and installed 64 bit version. Now I have the same problem.
It seems we need to use 32bit version.

p.s.
Yep I've reverted back to 32bit and it works fine again.

Good to know. It seems that Plex.Earth suffers from the same issue, must have 32-bit version of GE installed.

https://plexscape.zendesk.com/hc/en-us/articles/216073463-Communication-with-Google-Earth-Issue?mobile_site=true




Title: Re: Open Google Earth
Post by: d2010 on August 08, 2022, 01:20:53 PM
Google Earth Pro
7.3.1.4507 (64-bit)
But, can i install 32bit software in a 64bit computer?
:straight:
Sure, but your AcadVer but an exactly version-type with GoogleEarth.
Code: [Select]
//Eg1. Autocad2014.exe version x86 and GoogleEarth.x86
//Eg2. Autocad2014,exe version x64 == GoogleEarth.x64
Other solution/s check>your WindowsRegistry with
"Spy Search and Destroy.exe"
"Windoc.exe from NortonUtitiles", because "winRegistry for 'COM" contain damage-informations.
"Check the virus Attack with BitDefender.exe":
 :glare:

Title: Re: Open Google Earth
Post by: It's Alive! on August 08, 2022, 10:12:48 PM
there's a web version too

Title: Re: Open Google Earth
Post by: MSTG007 on August 15, 2022, 07:52:13 AM
Where or how did you find about Google Earth within CAD? lol. Thats pretty neat.
Title: Re: Open Google Earth
Post by: CodeDing on August 15, 2022, 01:26:50 PM
MSTG007,

Where or how did you find about Google Earth within CAD? lol. Thats pretty neat.
..."Google Earth within CAD" might be a little deceptive. It's just a web page. Probably using the Javascript API!

Source:
https://help.autodesk.com/view/OARX/2022/ENU/?guid=adsk_jsdev_autocad_javascript_api_about (https://help.autodesk.com/view/OARX/2022/ENU/?guid=adsk_jsdev_autocad_javascript_api_about)

To Test:
Save this as html document..
Code: [Select]
<html>
   <head>
       <title>Some Title</title>
       <script type="text/javascript" src="https://df-prod.autocad360.com/jsapi/v3/Autodesk.AutoCAD.js ">
       </script>
       <script type="text/javascript">

           function myFunction() {
             Acad.Application.addDocWindow("Another Title", "https://www.theswamp.org/index.php?topic=54086.msg611080#msg611080");
           }

           myFunction();

       </script>
   </head>

   <body>

   </body>
</html>

...then run code to execute your html...
Code: [Select]
(command "_.WEBLOAD" "l" "c:\\users\\me\\desktop\\myWebDocument.html")
Best,
~DD
Title: Re: Open Google Earth
Post by: CodeDing on August 15, 2022, 01:34:42 PM
To maintain the integrity of OP's original question though, last year I posted a routine to do just what was requested:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:EARTH ( / *error* GeoMarker PT->LL errMsg earthPath ptMid ptLL strKML fName f)
  2. ;; Opens Google Earth. If dwg is Geo-Located, attempts to open at user-specified location.
  3.   ;; Helper Function(s)
  4.   ;; Error handler
  5.   (defun *error* (msg / )
  6.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  7.       (princ (strcat "\nError: " msg))
  8.     );if
  9.     (princ)
  10.   );error defun
  11.   (defun GeoMarker ( / ) ;; Creates arbitrary GeoMarker, returns ename
  12.     (entmakex '((0 . "POSITIONMARKER") (100 . "AcDbEntity") (100 . "AcDbGeoPositionMarker") (90 . 0) (10 0.0 0.0 0.0) (40 . 1.0)
  13.                (1 . "") (40 . 0.5) (290 . 0) (280 . 0) (290 . 1) (101 . "Embedded Object") (100 . "AcDbEntity") (100 . "AcDbMText")
  14.                (10 0.1 0.1 0.0) (40 . 1.0) (1 . "") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 9761.9) (43 . 6666.67)))
  15.   );GeoMarker defun
  16.   (defun PT->LL (pt / e luprec return) ;; Returns Longitude & Latitude of point provided
  17.     (if (setq e (GeoMarker))
  18.       (progn
  19.         (setq e (vlax-ename->vla-object e))
  20.         (vlax-put-property
  21.           e
  22.           'Position
  23.           (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 2)) pt))
  24.         );vlax
  25.         (setq luprec (getvar 'LUPREC))
  26.         (setvar 'LUPREC 8)
  27.         (setq return
  28.           (mapcar
  29.             'atof
  30.             (list (vla-get-Longitude e) (vla-get-Latitude e) "0.")
  31.           );mapcar
  32.         );setq
  33.         (setvar 'LUPREC luprec)
  34.         (vla-delete e)
  35.         return
  36.       );progn
  37.     );if
  38.   );PT->LL defun
  39.   ;; Initial checks
  40.   (cond
  41.     ((not (setq earthPath (vl-registry-read "HKEY_LOCAL_MACHINE\\SOFTWARE\\Google\\Google Earth Pro" "InstallLocation")))
  42.       (setq errMsg "\nCould not locate Google Earth application.")
  43.     );cond 1
  44.     ((not (eq "Model" (getvar 'CTAB))) (setq errMsg "\nMust be in Model space to select location."))
  45.     ((eq "" (getvar 'CGEOCS)) (setq errMsg "\nDrawing is not Geo-Located."))
  46.   );cond
  47.   (if earthPath (setq earthPath (strcat earthPath "googleearth.exe")))
  48.   ;; Open Earth now if path found and error found, or test for other error.
  49.   (cond
  50.     ((and earthPath errMsg) (startapp earthPath) (prompt errMsg) (exit))
  51.     (errMsg (prompt errMsg) (alert errMsg) (exit))
  52.   );cond
  53.   (prompt "\nPreparing to open location in Google Earth...")
  54.   ;; User-selected or arbitrary mid point of project data
  55.   (setq ptMid
  56.     (cond ((getpoint "\nSelect Point or (Enter) for default: "))
  57.           ((getvar 'VIEWCTR))
  58.     );cond
  59.   );setq
  60.   ;; Transform to Lat Long
  61.   (setq ptLL (PT->LL ptMid))
  62.   (print ptLL)
  63.   ;string for KML file
  64.   (if *earth_marker_count*
  65.     (setq *earth_marker_count* (1+ *earth_marker_count*))
  66.     (setq *earth_marker_count* 1)
  67.   );if
  68.   (setq strKML
  69.     (strcat
  70.       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  71.       "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
  72.       "  <Placemark>"
  73.       "    <name>" (getvar 'DWGNAME) " (" (itoa *earth_marker_count*) ")</name>"
  74.       "    <Point>"
  75.       "      <coordinates>" (rtos (car ptLL) 2 7) "," (rtos (cadr ptLL) 2 7) ",0</coordinates>"
  76.       "    </Point>"
  77.       "  </Placemark>"
  78.       "</kml>"
  79.     );strcat
  80.   );setq
  81.   ;; Write string to KML file
  82.   (setq fName (vl-filename-mktemp "C3D" nil ".kml"))
  83.   (write-line strKML (setq f (open fName "w")))
  84.   (close f)
  85.   ;; Open KML in Google Earth
  86.   (startapp earthPath fName)
  87.   (prompt "\nEARTH Complete.")
  88.   (princ)
  89. );defun
  90.  

Sauce:
https://forums.autodesk.com/t5/civil-3d-customization/google-earth-command-in-autocad/td-p/10598071 (https://forums.autodesk.com/t5/civil-3d-customization/google-earth-command-in-autocad/td-p/10598071)

Best,
~DD
Title: Re: Open Google Earth
Post by: It's Alive! on August 16, 2022, 02:59:54 AM
MSTG007,

Where or how did you find about Google Earth within CAD? lol. Thats pretty neat.
..."Google Earth within CAD" might be a little deceptive. It's just a web page. Probably using the Javascript API!

yeah AutoCAD has a built in web browser, as you found, I used C++ function acedAddHTMLDocWindow(TITLE, URL)
surprised its not in lisp