I found this lisp that alerts you the lat/long. What do I need to do to make it label the lat/long? I've tried several times to get it to work with no luck.
Thanks!
DSM_dude!
(defun c:get_ll (/ as_cor ll lat lon pkpt) (setq as_cor (ade_projgetwscode)) (if (/= "" as_cor) ;checks for an assigned coordinate system (progn (ade_projsetsrc as_cor) (ade_projsetdest "LL84") ; uses lat/lon with no datum change as needed (while (not (setq pkpt (getpoint "\nPick Desired Point: ")))) (progn (setq ll (ade_projptforward pKpt)) (setq lat (car ll) lon (car (cdr ll)) ) (setq desc (ade_projgetinfo "LL84" "description")) (label (strcat "Lat: " (rtos lat 2 6) "\nLong:"(rtos lon 2 6) "\n Converted from: "as_cor "\n Converted to: " desc ) ) (princ) );progn );progn ;(alert "NO COORDINATE SYSTEM ASSIGNED TO THIS DRAWNING") (asg_coor) );if );defun (defun asg_coor (/ req ) (initget "Yes No" ) (setq req (getkword "No Coordinates Assigned to this MAP, Do you want to Assign them now? No: ")) (if (= nil req) (setq req "Yes")) (if (= req "Yes") (progn (command "ADESETCRDSYS") (if (/= "" (ade_projgetwscode)) (C:get_ll) (Alert "\nFailed to Assign Coordinates") );if );progn (princ "\nGood Bye") );if (princ) );defun
Most importantly, that code uses functions only exposed in AutoCAD Map, Land Desktop or Civil3D. If you are not using one of those verticals, you will not be able to get it to work.
If you are running MAP/LDT/C3D, there is a missing function "LABEL" (and possibly more), but the label function should not be hard to reproduce.
Thanks, just what I needed.
Works just fine for Autocad Map.
Just notice: lat and lon must be swapped
I need this for a project.... so....
;; get_ll Get Lat Long - Mark Mitchell ADP-Resources 2020
;;
;; Asks for point labels point with lat and long
;; Returns quite
;;
(defun c:get_ll (/ wscode ll lat lon pkpt angl sc)
;;; Error handling
(setq error *error*) ; save previous error method
;;
;; Define error handler
;;
(defun *error* (msg)
(if (/= msg "Function cancelled")
(progn (alert msg)
(alert "GET_LL did not end normally.")
) ; (progn
) ; (if (/= msg "Function cancelled")
(setq *error* error) ; restore previous error method
(vl-exit-with-value nil)
)
;;; (defun *error* (msg)
(setq wscode (ade_projgetwscode))
(if (/= "" wscode) ; checks for an assigned coordinate system
(progn
(setq sc 40.0) ;set scale
;;; (if (setq sc (getreal "Scale factor: (100) "))
;;; (setq sc (float sc))
;;; (setq sc 100.0)
;;; ) ; ask for scale default 1:100 returns scale factor as real
(ade_projsetsrc wscode)
(ade_projsetdest "LL84") ; uses lat/lon with no datum change as needed
(setq angl 0.0)
(while (setq pkpt (getpoint "\nPick Desired Point: "))
(setq ll (ade_projptforward pkpt)
lat (cadr ll)
lon (car ll)
)
;;; (setq desc (ade_projgetinfo "LL84" "description"))
(ADP:label (strcat "Lat: "
(rtos lat 2 8)
"\nLong:"
(rtos lon 2 8)
;;; "\n Converted from: "
;;; wscode
;;; "\n Converted to: "
;;; desc
) ; (strcat
sc
pkpt
angl
) ; (ADP:label
(princ) ; leave quitely
) ; (while (setq pkpt
) ; (progn
;; (alert "NO COORDINATE SYSTEM ASSIGNED TO THIS DRAWNING")
(ADP:asg_coor)
) ; (if (/= "" wscode)
) ; (defun c:get_ll (/ wscode ll lat lon pkpt)
(defun ADP:label (text sc pt angl / th)
(setq
th (* 0.06 sc) ; text height
pt (list (+ (car pt) (* 0.1 sc)) (- (cadr pt) (* 0.1 sc)) (caddr pt)) ; offset pt
) ; (setq
(entmake (list (cons 0 "MTEXT") ; Draft MTEXT
(cons 100 "AcDbEntity") ; 100 Entity Code
(cons 8 "0") ; Layer name
(cons 100 "AcDbMText") ; 100 Entity MText
(cons 10 pt) ; insertion point
(cons 40 th) ; text height
(cons 41 0) ; width 0
(cons 71 1) ; attachment top left
(cons 72 5) ; drawing direction bylayer
(cons 1 text) ; string (less than 250 chars
(cons 50 angl) ; rotation angle (radians)
(cons 90 3) ; background fill (transparent)
(cons 63 256)
(cons 45 1.1)
(cons 441 0)
) ; list
) ; entmake (list '(0 . "MTEXT")
(quote T) ; return T
) ; (defun ADP:label (text sc pt / )
(defun ADP:asg_coor (/ req)
(initget "Yes No")
(setq req (getkword
"No Coordinates Assigned to this MAP, \nDo you want to Assign one now? (No): "
)
)
(if (= nil req)
(setq req "No")
)
(if (= req "Yes")
(progn
(command-s "ADESETCRDSYS")
(if (/= "" (ade_projgetwscode))
(C:get_ll)
(Alert "\nFailed to Assign Coordinates")
) ; (if (/= "" (ade_projgetwscode))
) ; (progn
) ; (if (= req "Yes")
(princ)
) ; (defun asg_coor (/ req)
(princ "get_ll to get lat and long of point")
Didn't need the description on every tag. Also I am picking established blocks, so you may want to place a point on the pkpt (pick point) or draw a line from the pick point to the tag.