In AutoCAD Civil 3D we can use the LANDXMLIN command and import a LandXML file to create Civil 3D objects like Surface, Alignment, Pipe Network etc. Sometime ago, a Civil 3D application developer asked me about how do I create a Surface from a LandXML file using API ?
Civil 3D has the following COM API to create a Surface from LandXML -
IAeccSurfaces::ImportXML() -> Given the specified surface name and XML file, it creates a new surface from the imported XML data, adds it to the collection, and returns an instance of the new object.
.NET equivalent of this COM API is not yet available (in the current release), however, we can use COM Interop and create a .NET application. Here is a relevant C# code snippet -
public static void Civil3DImportLandXML(String filelocation)
{
//get editor and database
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = Application.DocumentManager.MdiActiveDocument.Database;
//start a transaction
using (Transaction trans = db.TransactionManager.StartTransaction())
{
AcadApplication oApp = (AcadApplication)Application.AcadApplication;
string sAppName = "AeccXUiLand.AeccApplication.10.0"; // Civil 3D 2013
AeccApplication aeccApp = (AeccApplication)oApp.GetInterfaceObject(sAppName);
AeccDocument aeccDoc = (AeccDocument)aeccApp.ActiveDocument;
// Get the AeccSurfaces object
Autodesk.AECC.Interop.Land.AeccSurfaces oAeccSurfaces = aeccDoc.Surfaces;
String landxmlFile = filelocation;
oAeccSurfaces.ImportXML(landxmlFile);
// Call AutoCAD COM API ZoomExtents to see the Surface object
oApp.ZoomExtents();
trans.Commit();
}
}///
Here is the result of calling the above function in Civil 3D 2013 [I used Civil 3D tutorial dataset here] -
While trying this in Civil 3D, I was thinking how about keeping my LandXML in Cloud storage and using it from anywhere, anytime ? Does it sound interesting ? I will continue this to see how we can store Civil 3D LandXML files in cloud and use them whenever and wherever I want to create a TIN surface.