Creating a TIN Surface from a TIN file

You can create a new TIN surface from a binary .tin file using the TinSurface.CreateFromTin() method. This method takes two arguments, the database for the drawing to which the TIN surface will be added, and the path to a .tin file, as a string.

[CommandMethod("CreateFromTIN")]
public void CreateFromTin()
{
    using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
    {
        // Example TIN surface from Civil Tutorials:
        string tinFile = @"C:\Program Files\Autodesk\AutoCAD Civil 3D 2013\Help\Civil Tutorials\Corridor surface.tin";
        try
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            ObjectId tinSurfaceId = TinSurface.CreateFromTin(db, tinFile);
            editor.WriteMessage("Import succeeded: {0} \n {1}", tinSurfaceId.ToString(), db.Filename);
        }
        catch (System.Exception e)
        {
            // handle bad file path 
            editor.WriteMessage("Import failed: {0}", e.Message);
        }

        // commit the transaction
        ts.Commit();
    }
}