Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Anonymous
en respuesta a: CodeDing

Hi CodeDing,

 

This is for AutoCAD 2018 - and yes you are correct, I would like to specify an x/y from an entity and retrieve the Lat/Lon from it.

 

I just found the below function that works with a position marker... but I'm not very proficient with AutoLisp API to be able to convert it into what I need (using entities). Specifically the 

 

(vla-get-Latitude) 
(vla-get-Longitude)

 

I don't know what to pass into those functions to get a proper result. 

 

 

 

 

 

 

;;Get Position Marker Geo-Coordinates
;;
;;By Steve Carson
;;
(vl-load-com)
(defun c:PMCoords ( / ss obj)
(setq ss (ssget '((0 . "POSITIONMARKER"))))
(repeat (setq i (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
    (princ (strcat "\n" (vla-get-TextString obj)))
    (princ (strcat "\nNorthing: " (rtos (cadr (vlax-safearray->list 
                                                  (vlax-variant-value 
                                                      (vla-get-Position obj)
                                                  )
                                              )
                                        )
                                   2 8)))
    (princ (strcat "\nEasting: " (rtos (car (vlax-safearray->list 
                                                  (vlax-variant-value 
                                                      (vla-get-Position obj)
                                                  )
                                              )
                                        )
                                   2 8)))
    (princ (strcat "\nLatitude: " (vla-get-Latitude obj)))
    (princ (strcat "\nLongitude: " (vla-get-Longitude obj)))
    (princ "\n")
)
(textscr)
(princ)
)