Author Topic: Changing a getpoint to a window  (Read 1421 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Changing a getpoint to a window
« on: July 24, 2020, 11:43:11 AM »
I am messing around trying to swap our the getpoint to use a window coordinate instead. I am not having much luck and thought I might get a direction.

Currently it will take the point and convert it to a LONG and LAT then over to a web browser map.

The new map I am trying to get needs to have 2 coordinates instead of the one.

Code: [Select]
(defun c:LiDar (/ COORDS LONGLAT LONG LAT PROJDEST PROJSRC)
(Alert "A Coordinate System Must be set.")
(setq PROJSRC (ade_projgetwscode))
(if (/= (getvar "ctab") "Model") (command "_layout" "Set" "Model"))
(ade_projsetsrc PROJSRC)
(ade_projsetdest "LL84")
(setq COORDS (getpoint "\nPick a Point within Modelspace: "));;; Pick a Window?
(setq LONGLAT (ade_projptforward COORDS))
(setq LONG (car LONGLAT))
(setq LONG (rtos LONG 2 6))
(setq LAT (car (cdr LONGLAT)))
(setq LAT (rtos LAT 2 6))
(setq PROJDEST (ade_projgetinfo "LL84" "description"))
(princ (strcat
"\n X,Y: " (rtos (car COORDS) 2 6) "," (rtos (cadr COORDS) 2 6)
"\n Projection SOURCE :  " PROJSRC
"\n Projection CIBLE(Target) :  " PROJDEST
"\n Longitude,Latitude: " LONG "," LAT
"\n"))
(setq Website (strcat "https://portal.opentopography.org/datasets?minX=" LONG "&minY=" LAT "&maxX=" LONG "&maxY=" LAT ""))
(command "_browser" Website)
(princ)
)
(C:LiDAR)


Thanks guys.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Changing a getpoint to a window
« Reply #1 on: July 24, 2020, 01:39:14 PM »
getpoint followed by getcorner?

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Changing a getpoint to a window
« Reply #2 on: July 24, 2020, 09:20:59 PM »
Bit like Lee if point is centre then what scale and work out using polar 2 new pts  or a distance very easy.
A man who never made a mistake never made anything

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Changing a getpoint to a window
« Reply #3 on: July 26, 2020, 08:46:41 AM »
If you are trying to get 2 coordinates from one pick simply add the offset to the coordinates.
Code: [Select]
(setq cp (getpoint)
        x-offset 200.0
        y-offset 300.0
        ll  (list (- (car cp) x-offset)(- (cadr cp) y-offset))
        ur  (list (+ (car cp) x-offset)(+ (cadr cp) y-offset))
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Changing a getpoint to a window
« Reply #4 on: July 27, 2020, 07:35:12 AM »
getpoint followed by getcorner?

Lee, I think that's what I am after. Click to create a window with the two points.

As I look through the code, does it make sense to create a LAT1 LONG1 and then a LAT2 LONG2 to carry the coordinates into the right place for the web address?

I know I have not changed the getpoint to the window, but I am guessing this is how I would carry the variables through the rest of the of the code.

Code: [Select]
(defun c:LiDar (/ COORDS LONGLAT1 LONG1 LAT1 LONGLAT2 LONG2 LAT2 PROJDEST PROJSRC)
(Alert "A Coordinate System Must be set.")
(setq PROJSRC (ade_projgetwscode))
(if (/= (getvar "ctab") "Model") (command "_layout" "Set" "Model"))
(ade_projsetsrc PROJSRC)
(ade_projsetdest "LL84")


(setq COORDS (getpoint "\nPick a Point within Modelspace: "));;; Pick a Window?


(setq LONGLAT1 (ade_projptforward COORDS))
(setq LONGLAT2 (ade_projptforward COORDS))

(setq LONG1 (car LONGLAT1))
(setq LONG1 (rtos LONG 2 6))

(setq LAT1 (car (cdr LONGLAT1)))
(setq LAT1 (rtos LAT 2 6))

(setq LONG2 (car LONGLAT2))
(setq LONG2 (rtos LONG 2 6))

(setq LAT2 (car (cdr LONGLAT2)))
(setq LAT2 (rtos LAT 2 6))

(setq PROJDEST (ade_projgetinfo "LL84" "description"))
(princ (strcat

"\n X,Y: " (rtos (car COORDS) 2 6) "," (rtos (cadr COORDS) 2 6)

"\n Projection SOURCE :  " PROJSRC
"\n Projection CIBLE(Target) :  " PROJDEST
"\n Longitude,Latitude: " LONG1 "," LAT1

"\n Longitude,Latitude: " LONG2 "," LAT2

"\n"))


(setq Website (strcat "https://portal.opentopography.org/datasets?minX=" LONG1 "&minY=" LAT1 "&maxX=" LONG2 "&maxY=" LAT2 ""))
(command "_browser" Website)
(princ)
)
(C:LiDAR)


Civil3D 2020