예제 #1
0
        public static DetailPlot Create(Document doc, DetailPlotMaster master, Point3d basePoint, string PlotId)
        {
            BlockRefDrawingObject refDrawingObject = BlockRefDrawingObject.Create(doc.Database, basePoint, master);
            Transaction           trans            = doc.TransactionManager.TopTransaction;
            BlockReference        reference        = (BlockReference)trans.GetObject(refDrawingObject.BaseObject, OpenMode.ForRead);

            DetailPlot newDetailPlot = new DetailPlot(doc, reference);

            DataService.Current.GetStore <HousingDocumentStore>(doc.Name).GetManager <DetailPlotManager>().Add(newDetailPlot);
            newDetailPlot.PlotId       = PlotId;
            newDetailPlot.PlotTypeName = master.PlotTypeName;
            return(newDetailPlot);
        }
예제 #2
0
        private static void ToDrawing(bool insert)
        {
            Document doc    = Application.DocumentManager.MdiActiveDocument;
            Editor   editor = doc.Editor;

            PromptResult promptResult = editor.GetString("\nEnter block template id: ");

            if (promptResult.Status != PromptStatus.OK)
            {
                return;
            }

            using (Transaction trans = doc.TransactionManager.StartTransaction())
            {
                Guid            id     = new Guid(promptResult.StringResult);
                ITemplateSource source = DataService.Current.GetTemplateSource(id);
                (Database database, TemplateDrawingObject template) = source.GetTemplate(id);
                BlockDrawingObject residentTemplateBlock;
                using (database)
                    using (database.TransactionManager.StartTransaction())
                    {
                        residentTemplateBlock = template.TransferToDocument(doc);
                    }

                if (insert)
                {
                    PromptPointResult result = editor.GetPoint("Please enter location of block:");
                    if (result.Status != PromptStatus.OK)
                    {
                        return;
                    }

                    BlockRefDrawingObject.Create(doc.Database, result.Value, residentTemplateBlock);
                }

                trans.Commit();
            }
        }