Import Kml To Autocad Civil 3d 2018 !new! May 2026
var sourceCs = "LL84"; // EPSG:4326 alias in Civil 3D var transform = CoordinateSystemService.CreateTransform(sourceCs, targetCsCode); double x, y; transform.TransformPoint(lon, lat, out x, out y); // note: lon → X, lat → Y return new Point2d(x, y);
// Transform & import ImportGeometry(kmlData, targetCsCode, db, tr); import kml to autocad civil 3d 2018
return geometries; Use CoordinateSystemService from Civil 3D API: var sourceCs = "LL84"; // EPSG:4326 alias in
public Point2d ConvertLatLonToDrawing(double lat, double lon, string targetCsCode) var sourceCs = "LL84"
var kmlFile = KmlFile.Load(stream); var root = kmlFile.Root as Kml; if (root?.Feature is Placemark placemark) // Extract coordinates if (placemark.Geometry is Point point) var coord = point.Coordinate; geometries.Add(new KmlGeometry(GeometryType.Point, new[] new Coordinate(coord.Latitude, coord.Longitude, coord.Altitude) )); else if (placemark.Geometry is LineString line) var coords = line.Coordinates.Select(c => new Coordinate(c.Latitude, c.Longitude, c.Altitude)).ToArray(); geometries.Add(new KmlGeometry(GeometryType.Polyline, coords)); else if (placemark.Geometry is Polygon polygon) // Extract outer boundary var coords = polygon.OuterBoundary.LinearRing.Coordinates.Select(c => new Coordinate(c.Latitude, c.Longitude, c.Altitude)).ToArray(); geometries.Add(new KmlGeometry(GeometryType.Polygon, coords));
var pl = new Polyline3d(Poly3dType.SimplePoly, points, false); var bt = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; var plId = bt.AppendEntity(pl); tr.AddNewlyCreatedDBObject(pl, true); return plId;


