public PropertiesResponse VerifyKnownPropertiesResident(PropertiesInput pi)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            using (Transaction trans = doc.TransactionManager.StartTransaction())
            {
                IEnumerable <BlockRefDrawingObject> records = doc.Database.GetLayout(pi.LayoutName).GetBlockReferences().Select(br => new TestBlockRefDrawingObject(doc, br));
                records = records.Where(br => br.BlockName == pi.BlockName);

                if (records.Count() != 1)
                {
                    throw new ArgumentOutOfRangeException();
                }

                BlockRefDrawingObject testObject = records.ElementAt(0);

                PropertiesResponse pr = new PropertiesResponse
                {
                    Client  = testObject.GetProperty <string>("CLIENT1"),
                    Project = testObject.GetProperty <string>("PROJECT1")
                };

                return(pr);
            }
        }
        public TitleBlock(BlockRefDrawingObject reference) : base()
        {
            this._document  = reference.Document;
            this._database  = reference.Database;
            this.BaseObject = reference.BaseObject;

            GetProperties();
        }
        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);
        }
        public static void BlockToTemplate()
        {
            TypedValue[] acTypValAr = new TypedValue[1];
            acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0);
            SelectionFilter acSelFtr = new SelectionFilter(acTypValAr);

            PromptSelectionResult acSSPrompt = Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(acSelFtr);
            Document currentDoc = Application.DocumentManager.MdiActiveDocument;

            if (acSSPrompt.Status == PromptStatus.OK)
            {
                if (acSSPrompt.Value.Count > 1)
                {
                    throw new ArgumentOutOfRangeException("More items than expected");
                }

                using (Transaction trans = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
                {
                    DocumentCollection acDocMgr = Application.DocumentManager;
                    Document           newDoc   = acDocMgr.Add("");
                    using (DocumentLock lockObj = newDoc.LockDocument())
                    {
                        using (Transaction destinationTrans = newDoc.TransactionManager.StartTransaction())
                        {
                            BlockReference        refObj    = (BlockReference)trans.GetObject(acSSPrompt.Value[0].ObjectId, OpenMode.ForWrite);
                            BlockRefDrawingObject reference = new BlockRefDrawingObject(currentDoc, refObj);

                            Database              source          = Application.DocumentManager.MdiActiveDocument.Database;
                            BlockDrawingObject    newInstance     = reference.GetBlock().TransferToDocument(newDoc);
                            TemplateDrawingObject blockDefinition = newInstance.ConvertToTemplate();

                            destinationTrans.Commit();
                        }
                    }

                    Application.DocumentManager.MdiActiveDocument = newDoc;
                }
            }
        }
        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();
            }
        }