コード例 #1
0
        public static ObjectId CroppingSurface3(TinSurface surface, Polyline border)
        {
            Polyline3d newBorder   = null;
            ObjectId   newBorderId = ObjectId.Null;
            TinSurface newSurface  = null;

            using (Database destDb = new Database(true, true))
            {
                Database sourceDb = Tools.GetAcadDatabase();
                using (Transaction transSrc = Tools.StartTransaction(sourceDb))
                {
                    using (Transaction transDest = Tools.StartTransaction(destDb))
                    {
                        var points = border.GetPoints();
                        HostApplicationServices.WorkingDatabase = destDb;

                        string   surfaceName  = "Cropped_" + surface.Name + "<[Next Counter(CP)]>";
                        ObjectId newSurfaceId = TinSurface.CreateByCropping(destDb, surfaceName, surface.Id, points);
                        newSurface = transDest.GetObject(newSurfaceId, OpenMode.ForRead) as TinSurface;

                        newBorderId = ((ITerrainSurface)newSurface).GetBounds()[0];



                        HostApplicationServices.WorkingDatabase = sourceDb;
                        newBorder  = transDest.GetObject(newBorderId.ConvertToRedirectedId(), OpenMode.ForRead) as Polyline3d;
                        newBorder  = newBorder.Clone() as Polyline3d;
                        newSurface = newSurface.Clone() as TinSurface;
                    }
                }
            }
            try
            {
                newBorder = newBorder.Clone() as Polyline3d;
                Tools.AppendEntityEx(Tools.GetActiveAcadDocument(), newBorder);
            }
            catch (System.Exception ex)
            {
                Tools.GetAcadEditor().WriteMessage("\n" + ex.Message);
            }


            return(ObjectId.Null);
        }