AutoCAD to Google Earth - Custom AutoLISP Script

AutoCAD to Google Earth - AutoLISP Script | Er. Alish Subedi
⚡ AUTOCAD → GOOGLE EARTH | AUTOLISP

Custom AutoLISP Script
DWG to KML Converter

Transform your AutoCAD slope plans directly into Google Earth with GPS-calibrated accuracy

📐🗺️

"Not every problem has a ready-made solution. Sometimes you have to build it yourself."

— Er. Alish Subedi

🎯 The Challenge

I needed a way to visualize my AutoCAD slope plan drawings directly on Google Earth accurately, not approximately. No existing plugin did exactly what I needed. Existing tools either lacked precision, couldn't handle Nepal's coordinate system, or produced KML files with unacceptable errors.

📐 Project Coordinate Bounds

EASTING MIN
617262.0 m
EMIN
EASTING MAX
620269.0 m
EMAX
NORTHING MIN
3029816.0 m
NMIN
NORTHING MAX
3034836.0 m
NMAX

🚀 My Journey: Building the Solution

1
Identifying the Gap
No plugin could handle Nepal Grid with precision
2
Learning AutoLISP
Mastered entity reading & coordinate extraction
3
Coordinate Transformation
Nepal Grid → Lat/Long with GPS calibration
4
Testing & Refining
Achieved perfect KML output after iterations
💡

The Solution

My custom AutoLISP script reads every entity in the drawing, converts Nepal National Grid coordinates to real-world latitude and longitude, applies GPS-calibrated corrections, and exports a clean KML file ready for Google Earth.

🔧

Key Features

  • 📁 Reads all drawing entities automatically
  • 🗺️ Precise Nepal Grid → Lat/Long conversion
  • 📡 GPS-calibrated correction algorithm
  • 📄 Clean, ready-to-use KML output
  • 📐 Preserves all drawing geometry

📝 AutoLISP Code Snippet

(defun c:ExportToKML ( / ss ent coord)
  (setq ss (ssget "_X"))
  (foreach ent (vl-remove-if-not 'listp
      (mapcar 'cadr (ssnamex ss)))
    (setq coord (cdr (assoc 10 (entget ent))))
    (setq lat (nepal-grid-to-lat coord))
    (setq lon (nepal-grid-to-lon coord))
    (write-kml-point lat lon)
  )
)

The script processes each entity, transforms coordinates, and outputs clean KML markup ready for Google Earth import.

✅ What I Achieved

Accurate slope plan overlay on Google Earth
GPS-calibrated coordinate correction
Clean, ready-to-use KML files
No manual coordinate entry needed