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

Hey CodeDing

 

I'm actually looking for a way to do this in LISP.. Are you aware of any examples of people doing this in lisp?

 

I have code that works only with a local projection. I would like to get a specific projection (PseudoMercator.WGS84)

 

Here is my code currentlY, its just interpolating the coordinates based  on the origin point of the drawing. This works like I said only with local coordinates. 

 

(defun convert_coordinate (point / )
  ; Get geographic marker coordinates
  ; NOTE: this point must be at the (0, 0) UCS origin point
  (setq lat (getvar "LATITUDE"))
  (setq lon (getvar "LONGITUDE"))

  ; Earth's radius, sphere
  (setq earth_radius 6378137.0)

  ; Offsets in meters from origin point
  (setq distance_north (car (cdr point)))
  (setq distance_east (car point))

  ; Coordinate offsets in radians
  (setq dLat (/ distance_north earth_radius))
  (setq dLon (/ distance_east (* earth_radius (cos (/ (* Pi lat) 180.0)))))

  ; OffsetPosition, decimal degrees
  (setq point_lat (+ lat (/ (* dLat 180.0) Pi)))
  (setq point_lon (+ lon (/ (* dLon 180.0) Pi)))


  (prompt (strcat 
    "\nLat: " (rtos lat 2 16)
    "\nLon: " (rtos lon 2 16)
    "\nNorth Distance: " (rtos distance_north 2 16)
    "\nEast Distance: " (rtos distance_east 2 16)
    "\nOutput Lat: " (rtos point_lat 2 16)
    "\nOutput Lon: " (rtos point_lon 2 16)
    "\n----------"
  ))

  ; Return coordinate
  (list point_lon point_lat)
)