示例#1
0
        public ILibraryItem GetFrom(string Name, Database from)
        {
            CivilDocumentStore sourceStore = from.GetDocumentStore <CivilDocumentStore>();
            PlotType           source      = (from pt in sourceStore.PlotTypes where pt.PlotTypeName == Name select pt).First();

            return(source);
        }
示例#2
0
        private void Transfer(Database to, Database from, CivilDocumentStore destinationStore)
        {
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction tr = acCurDb.TransactionManager.StartTransaction())
            {
                ObjectIdCollection collection = new ObjectIdCollection();

                //Generate list of objects to transfer

                /*collection.Add(BackgroundBlockID);
                 * collection.Add(BasepointID);*/
                collection.Add(BlockID);

                /*foreach (ObjectId accessPointLocation in AccessPointLocations.Collection)
                 * {
                 *  collection.Add(accessPointLocation);
                 * }
                 *
                 * foreach (WallSegment wallSegment in Segments)
                 * {
                 *  collection.Add(wallSegment.PerimeterLine);
                 * }*/

                IdMapping acMapping = new IdMapping();

                to.WblockCloneObjects(collection, to.BlockTableId, acMapping, DuplicateRecordCloning.Ignore, false);

                PlotType destination = (PlotType)this.Clone();

                destination.BackgroundBlockID = TranslateMapping(BackgroundBlockID, acMapping);
                destination.BasepointID       = TranslateMapping(BasepointID, acMapping);
                destination.BlockID           = TranslateMapping(BlockID, acMapping);

                for (int i = 0; i < destination.AccessPointLocations.Count; i++)
                {
                    destination.AccessPointLocations[i] = TranslateMapping(AccessPointLocations[i], acMapping);
                }

                foreach (WallSegment wallSegment in destination.Segments)
                {
                    wallSegment.PerimeterLine = TranslateMapping(wallSegment.PerimeterLine, acMapping);
                }

                destinationStore.PlotTypes.Add(destination);
                destinationStore.Save();

                tr.Commit();
            }
        }
示例#3
0
        public static void Finalise()
        {
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction tr = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable bt = (BlockTable)tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead);

                ObjectId         newBlockId = bt[PlotType.CurrentOpen.PlotTypeName];
                BlockTableRecord btr        = tr.GetObject(newBlockId, OpenMode.ForWrite) as BlockTableRecord;
                foreach (ObjectId e in btr)
                {
                    Entity temp = tr.GetObject(e, OpenMode.ForWrite) as Entity;
                    temp.Erase();
                }

                ObjectIdCollection plotObjects = new ObjectIdCollection();

                plotObjects.Add(PlotType.CurrentOpen.BackgroundBlockID);
                plotObjects.Add(PlotType.CurrentOpen.BasepointID);

                foreach (WallSegment ws in PlotType.CurrentOpen.Segments)
                {
                    plotObjects.Add(ws.PerimeterLine);
                }

                foreach (ObjectId c in PlotType.CurrentOpen.AccessPointLocations.Collection)
                {
                    plotObjects.Add(c);
                }

                btr.AssumeOwnershipOf(plotObjects);

                tr.Commit();
            }

            //Triggeer regen to update blocks display
            //alternatively http://adndevblog.typepad.com/autocad/2012/05/redefining-a-block.html
            Application.DocumentManager.CurrentDocument.Editor.Regen();

            //Add to the document store
            CivilDocumentStore cds = acDoc.GetDocumentStore <CivilDocumentStore>();

            cds.PlotTypes.Add(PlotType.CurrentOpen);

            PlotType.CurrentOpen = null;
            OnCurrentOpenChanged?.Invoke();
        }
        private void dataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            Document           acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            CivilDocumentStore cds   = acDoc.GetDocumentStore <CivilDocumentStore>();


            using (DocumentLock dl = acDoc.LockDocument())
            {
                cds.Plots[dataGrid.SelectedIndex].Highlight();
                cds.Plots[dataGrid.SelectedIndex].Update();

                // Redraw the drawing
                Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen();
            }
        }
示例#5
0
        public void Transfer(Database to, Database from)
        {
            CivilDocumentStore destinationStore = to.GetDocumentStore <CivilDocumentStore>();

            Transfer(to, from, destinationStore);
        }