/// <summary>
        /// Sets the surface style to standard.
        /// </summary>
        /// <param name="surfaceId">The surface identifier.</param>
        public void SetSurfaceStyleToStandard(ObjectId surfaceId)
        {
            using (Transaction ts = AcadApplictionDocument.GetTransaction())
            {
                using (Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    var doc = CivilApplicationManager.ActiveCivilDocument;


                    // Select a style to use
                    ObjectId surfaceStyleId = ObjectId.Null;

                    if (GetSurfaceStyle("Standard") != null)
                    {
                        if (GetSurfaceStyle("Standard") == null)
                        {
                            SurfaceStyle();
                        }

                        surfaceStyleId = GetSurfaceStyle("Standard").ObjectId;
                    }


                    TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;

                    if (surface != null)
                    {
                        surface.StyleId = surfaceStyleId;
                    }

                    // commit the create action
                    ts.Commit();
                }
            }
        }
        //[CommandMethod("CreateFromTIN")]
        //public void CreateFromTin()
        //{
        //    var civildoc = AcadApplictionDocument.GetMdiDocument();
        //    var editor = civildoc.Editor;

        //    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();
        //    }
        //}

        //[CommandMethod("CreateTINSurface")]
        //public void CreateTINSurfaceByPointCollection()
        //{

        //    using (Transaction ts = AcadApplictionDocument.GetTransaction())
        //    {
        //        var doc = CivilApplicationManager.ActiveCivilDocument;

        //        string surfaceName = "All";
        //        // Select a style to use

        //        if (GetSurfaceStyle("pga-tour-style") == null)
        //            SurfaceStyle();

        //        ObjectId surfaceStyleId = GetSurfaceStyle("pga-tour-style").ObjectId;

        //        if (surfaceStyleId == null) return;
        //        // Create the surface
        //        ObjectId surfaceId = TinSurface.Create(surfaceName, surfaceStyleId);

        //        TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;

        //        // Add some random points
        //        Point3dCollection points = new Point3dCollection();
        //        points = ReadPointCloudFile.ReadFile(
        //            @"C:\Civil 3D Projects\PGA-8.23.2016\SV", "dtm06.txt");

        //        surface.AddVertices(points);

        //        // commit the create action
        //        ts.Commit();
        //    }


        //}

        /// <summary>
        /// Creates the tin surface by point collection.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="polylinelayer">The polylinelayer.</param>
        /// <returns>TinSurface.</returns>
        //public TinSurface CreateTINSurfaceByPointCollection(Point3dCollection points, string polylinelayer)
        //{
        //    TinSurface surface;

        //    using (Transaction ts = AcadApplictionDocument.GetTransaction())
        //    {
        //        var doc = CivilApplicationManager.ActiveCivilDocument;

        //        string surfaceName = polylinelayer;
        //        // Select a style to use

        //        if (GetSurfaceStyle(polylinelayer) == null)
        //            SurfaceStyle();

        //        ObjectId surfaceStyleId = GetSurfaceStyle(polylinelayer).ObjectId;

        //        // Create the surface
        //        ObjectId surfaceId = TinSurface.Create(surfaceName, surfaceStyleId);

        //        surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;
        //        //surface.BuildOptions.MaximumTriangleLength = 20;
        //        //surface.BuildOptions.UseMaximumTriangleLength = true;
        //        SetDefaultBuildOptions(surface); ///Todo: 2.20.2017
        //        // Add some random points
        //        //Point3dCollection points = new Point3dCollection();
        //        //points = ReadPointCloudFile.ReadFile(path, filename);


        //        surface.AddVertices(points);

        //        // commit the create action
        //        ts.Commit();
        //    }

        //    return surface;
        //}

        /// <summary>
        /// Creates the tin surface by point collection.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="filename">The filename.</param>
        public void CreateTINSurfaceByPointCollection(string path, string filename)
        {
            using (Transaction ts = AcadApplictionDocument.GetTransaction())
            {
                var doc = CivilApplicationManager.ActiveCivilDocument;

                string surfaceName = "All";

                // Select a style to use
                ObjectId surfaceStyleId = ObjectId.Null;
                //NO-DISPLAY
                //if (GetSurfaceStyle("NO-DISPLAY") != null)
                //{
                //    if (GetSurfaceStyle("NO-DISPLAY") == null)
                //        SurfaceStyle();

                //    surfaceStyleId = GetSurfaceStyle("NO-DISPLAY").ObjectId;
                //}
                if (GetSurfaceStyle("Standard") != null)
                {
                    if (GetSurfaceStyle("Standard") == null)
                    {
                        SurfaceStyle();
                    }

                    surfaceStyleId = GetSurfaceStyle("Standard").ObjectId;
                }
                // Create the surface
                ObjectId surfaceId = TinSurface.Create(surfaceName, surfaceStyleId);

                TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;

                surface.DowngradeOpen();
                SetDefaultBuildOptions(surface); ///Todo: 2.20.2017
                surface.UpgradeOpen();

                //surface.BuildOptions.MaximumTriangleLength = 200;
                //surface.BuildOptions.UseMaximumTriangleLength = true;
                //// Add some LiDAR points
                Point3dCollection points = new Point3dCollection();
                points = ReadPointCloudFile.ReadFile(path, filename);

                surface.AddVertices(points);

                SetSmoothing(surface, points);

                // commit the create action
                ts.Commit();
            }
        }