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));
public ObjectId Create3DPolyline(Point3dCollection points, Database db, Transaction tr)
Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; // File selection string filename = SelectKMLFile(); if (string.IsNullOrEmpty(filename)) return; import kml to autocad civil 3d 2018
tr.Commit();
public List<KmlGeometry> ParseKML(string filepath) var kmlFile = KmlFile
var pt = new AeccPoint(); pt.Northing = northing; pt.Easting = easting; pt.Elevation = elevation; // Add to block table record var bt = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; var ptId = bt.AppendEntity(pt); tr.AddNewlyCreatedDBObject(pt, true); return ptId;
var geometries = new List<KmlGeometry>(); using (var stream = File.OpenRead(filepath)) var kmlFile = KmlFile.Load(stream)
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;