//[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();
            }
        }
        /// <summary>
        /// Sets the default build options.
        /// Date: 2/19/2017
        /// </summary>
        /// <param name="surface">The surface.</param>
        public void SetDefaultBuildOptions(TinSurface surface)
        {
            try
            {
                using (Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (var tr = CivilApplicationManager.StartTransaction())
                    {
                        MessengerManager.AddLog("Start Setting Build Options");

                        if (surface == null)
                        {
                            return;
                        }

                        surface.UpgradeOpen();
                        ///Todo:Handle Breaklines for Water and Bulkhead-Added 3.7.17
                        ///
                        if (surface.Name.Contains("WATER"))
                        {
                            surface.BuildOptions.MaximumTriangleLength = 100;
                        }
                        else if (surface.Name.Contains("All"))
                        {
                            surface.BuildOptions.MaximumTriangleLength = 200;
                        }
                        else
                        {
                            surface.BuildOptions.MaximumTriangleLength = 20;
                        }

                        surface.BuildOptions.UseMaximumTriangleLength          = true;
                        surface.BuildOptions.NeedConvertBreaklines             = true;
                        surface.BuildOptions.ExecludeMinimumElevation          = true;
                        surface.BuildOptions.MinimumElevation                  = 0.1; // Possible negative elevation
                        surface.BuildOptions.CrossingBreaklinesElevationOption =
                            CrossingBreaklinesElevationType.UseLast;                  ///Todo: Changed 2/19/17 from None.
                        surface.DowngradeOpen();

                        tr.Commit();
                        MessengerManager.AddLog("End Setting Build Options");
                        MessengerManager.AddLog("Surface Settings: " + surface.Name);
                    }
                }
            }
            catch (System.Exception e)
            {
                MessengerManager.LogException(e);
            }
        }
示例#3
0
        RBA()
        {
            Surface surface = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDoc())
                {
                    ObjectIdCollection ids = BaseObjs._civDoc.GetSurfaceIds();
                    if (ids.Count == 0)
                    {
                        return;
                    }
                    foreach (ObjectId id in ids)
                    {
                        try
                        {
                            surface = (Surface)tr.GetObject(id, OpenMode.ForRead);
                            if (surface is TinSurface)
                            {
                                TinSurface tinSurface = (TinSurface)surface;
                                tinSurface.UpgradeOpen();
                                tinSurface.Rebuild();
                                tinSurface.DowngradeOpen();
                            }
                        }
                        catch (System.Exception ex)
                        {
                            BaseObjs.writeDebug(ex.Message + " cmdRB.cs: line: 71");
                        }
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " cmdRB.cs: line: 79");
            }
        }