Ejemplo n.º 1
0
        public void AddPointsToSurface()
        {
            Editor ed = acadDoc.Editor;

            try
            {
                Point3dCollection coll3d = cMesh.GetSubDMeshVertices();
                ts.AddVertices(coll3d);
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nError: Can´t add Vertices from SubDMesh!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create the suface
        /// </summary>
        /// <param name="solidSurfaceName">Name of the surface</param>
        /// <param name="simplifySurface">Apply simplify
        /// operation</param>
        private static void CreateSolidSurface(
            string solidSurfaceName, bool simplifySurface)
        {
            // open or create the new surface
            TinSurface newSurface   = null;
            ObjectId   newSurfaceId = Util.GetSurfaceId(solidSurfaceName);

            if (!newSurfaceId.IsNull)
            {
                // open, remove all points and operations
                newSurface = _trans.GetObject(newSurfaceId,
                                              OpenMode.ForWrite) as TinSurface;
                newSurface.DeleteVertices(newSurface.Vertices);
            }
            else
            {
                // create and open
                newSurfaceId = TinSurface.Create(_db, solidSurfaceName);
                newSurface   = _trans.GetObject(newSurfaceId,
                                                OpenMode.ForWrite) as TinSurface;
            }

            // add the newly created points
            newSurface.AddVertices(_newPoints);

            // simplify surface
            if (simplifySurface)
            {
                SurfaceSimplifyOptions simplifyOptions = new
                                                         SurfaceSimplifyOptions(SurfaceSimplifyType.PointRemoval);
                simplifyOptions.MaximumChangeInElevation    = 0.0001;
                simplifyOptions.UseMaximumChangeInElevation = true;
                newSurface.SimplifySurface(simplifyOptions);
            }
        }
Ejemplo n.º 3
0
        //[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();
            }
        }
 public void AddVertices()
 {
     _surface.AddVertices(_points);
 }