Author Topic: Google Maps ?  (Read 3848 times)

0 Members and 1 Guest are viewing this topic.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Google Maps ?
« on: August 25, 2013, 03:52:13 PM »
I just found this, (Google API) for creating snips of the Google Map, listing the address, size, scale etc in the calling line, to create a custom map that can be used as a Locus map on a plan very handily.

https://developers.google.com/maps/documentation/staticmaps/#Limits

All works well through LISP, however I would like to cut & paste the created png/gif directly to the drawing.  Not sure how to accomplish this task...  Any ideas ?

It may be possible to copy the image the the clipboard, the ctrl-x copying method works fine to get the map into the clipboard.  Any way to simulate the keystrokes ctrl & x to programmatically copy to clipboard....


Bruce

« Last Edit: August 25, 2013, 06:31:59 PM by snownut2 »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Google Maps ?
« Reply #1 on: August 26, 2013, 01:53:32 AM »
So you would like to embed the image as an OLE object instead of simply inserting it as an image? If you want to force a copy-paste idea, then you'd have to use ActiveX to open whatever image editor/viewer is installed on the PC (probably Paint, though that "might" not be able to open PNG depending on win version and extra installs). Then depending on the program it might behave as an ActiveX server (like Excel does) or you could send-keys to it to initiate the Ctrl+C (though you might have to select all before hand, depending on the program).

Alternatively you might be able to directly create an OLE Object through the vl* methods, but I've never seen anyone using this and getting any sort of decent result.

It seems even the usual "catch-all" answer of go with DotNet/ARX won't help you here: http://forums.autodesk.com/t5/AutoCAD-Civil-3D/Insert-OLE-OBject/td-p/2523272

Even in that thread it's suggesting either inserting an already placed OLE from another DWG (i.e. insert as block and then explode) or attach an image reference (not an OLE).
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Vaidas

  • Newt
  • Posts: 66
Re: Google Maps ?
« Reply #2 on: August 26, 2013, 02:58:38 AM »
Interesting to me too. Recently I played with similar task but found only the way to search for *.png file (thumbnail) at my ...\AppData\Local\Mozilla\Firefox\Profiles\default\thumbnails folder.
(mapcar 'chr '(107 105 116 111 120 46 99 111 109))

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Google Maps ?
« Reply #3 on: August 26, 2013, 08:02:07 AM »
irneb,

It seems to work (manually anyway) to just "ctrl+x" when the image is visable on the screen without having to actually select the image.  Then a simple  "Ctrl+V" or pasteclip command in ACAD to embed the OLE object into the drawing.  So it seems what I need now is a way to trigger the "Ctrl+X" while another window is active (not the ACAD window).


Bruce
« Last Edit: August 26, 2013, 08:08:15 AM by snownut2 »

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Google Maps ?
« Reply #4 on: August 26, 2013, 08:19:33 AM »
I just found this, (Google API) for creating snips of the Google Map, listing the address, size, scale etc in the calling line, to create a custom map that can be used as a Locus map on a plan very handily.
That is pretty cool Bruce. Thanks for sharing.
TheSwamp.org  (serving the CAD community since 2003)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Google Maps ?
« Reply #5 on: August 26, 2013, 08:32:32 AM »
irneb,

It seems to work (manually anyway) to just "ctrl+x" when the image is visable on the screen without having to actually select the image.  Then a simple  "Ctrl+V" or pasteclip command in ACAD to embed the OLE object into the drawing.  So it seems what I need now is a way to trigger the "Ctrl+X" while another window is active (not the ACAD window).


Bruce
The Ctrl+V is not the issue - you can much more reliably just use the pasteclip command instead.

The issue is that you'd need to open the file in whatever other program is set to open them. On a clean install of Windows, this is usually Paint for stuff like BMP, JPG, etc. In some cases Paint does not open PNG's. But if the user ever installed a different program (e.g. PhotoShop / Gimp / AseeDsee / etc.) chances are that that would become the default program. Some of these work in a different way than Paint does, e.g. PhotoShop / Gimp would require that you first select the entire image (Ctrl+A) then do the Copy (note Ctrl+C not X as that would "delete the image to the clipboard"). So as long as you can ensure that Paint will always be used, then this issue can be resolved.

Now what about the versions of Paint. E.g. the one in XP is a lot different from the one in W7 - even just considering menu/ribbon. So some shortcut keys might even differ there - i.e. how do you open a file using only keystrokes in the one and how do you do it in the other?

Your next major problem is the asynchronous nature of ActiveX. So you start Paint, how long does it take to open? Then how long does it take to open the PNG file? Only after both these have completed can you send the Ctrl+C, otherwise the sendkey function simply sends it to whatever other window currently has focus. So now you need to add some sort of wait to allow for paint to load and open the file before you can copy, the larger the file the longer the needed wait may be, but also depending on the PC's performance (e.g. slow HDD / lots of other programs in RAM making for lots of virtual RAM swaps / etc.).

That is why I'm suggesting finding a way to link to the "Paint" program as if it is a COM/ActiveX server. That way you can call it syncronously, and also not need to worry about the UI or even if it is the default image editor. Unfortunately after some googling I don't seem to find the COM documentation for Paint. So I can't just now give you a sample.

The only other alternative (which would work and not need any external program) would be to attach the image into the DWG instead. That can be done through ImageAttach command very easily through lisp.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Google Maps ?
« Reply #6 on: August 26, 2013, 08:43:59 AM »
Actually another idea might be to use Internet Explorer to open the PNG file. It should be possible to manipulate IE's clipboard functions through ActiveX and not need to worry about any SendKeys. http://www.theswamp.org/index.php?topic=21764.0
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

MickD

  • King Gator
  • Posts: 3647
  • (x-in)->[process]->(y-out) ... simples!
Re: Google Maps ?
« Reply #7 on: August 26, 2013, 07:18:09 PM »
« Last Edit: August 26, 2013, 07:29:17 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Google Maps ? <UPDATE>
« Reply #8 on: January 11, 2015, 11:24:20 AM »
Update:

Just found this little gem, allows one to copy a file from web to hard drive. (all via command line).

I am not pasting the file as it is an exe, just the link.


http://www.activeplus.com/Products/HttpCopy
« Last Edit: January 11, 2015, 11:46:36 AM by snownut2 »