Example #1
0
        Wblock()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            try {
                Database db = m_db.Wblock();
                using (TransactionHelper trHlp = new TransactionHelper(db)) {
                    trHlp.Start();

                    Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp);
                    dbForm.Text = "Destination Database (In memory only)";
                    dbForm.ShowDialog();

                    trHlp.Commit();
                }
            }
            catch (AcRx.Exception e) {
                AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString()));
            }
        }
Example #2
0
        WblockObjects2()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            ObjectIdCollection objIds;

            if (!Utils.AcadUi.GetSelSetFromUser(out objIds))
            {
                return;
            }

            String message = "\nDuplicate Record Cloning Options:";
            Array  enums   = Enum.GetValues(typeof(DuplicateRecordCloning));

            foreach (int option in enums)
            {
                message += string.Format("\n{0} = {1}", option,
                                         Enum.GetName(typeof(DuplicateRecordCloning), option));
            }

            PromptIntegerOptions prOpts = new PromptIntegerOptions(message);

            prOpts.LowerLimit = 0;
            prOpts.UpperLimit = enums.Length;

            Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptIntegerResult prRes = ed.GetInteger(prOpts);

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

            Database db = new Database(true, true);

            DuplicateRecordCloning drc = (DuplicateRecordCloning)prRes.Value;

            if (drc == DuplicateRecordCloning.NotApplicable ||
                drc == DuplicateRecordCloning.RefMangleName)
            {
                ed.WriteMessage("Invalid Input");
                return;
            }

            using (TransactionHelper trHlp = new TransactionHelper(m_db)) {
                trHlp.Start();

                m_db.Wblock(db, objIds, new Point3d(0, 0, 0), drc);

                trHlp.Commit();
            }

            using (TransactionHelper trHlp = new TransactionHelper(db)) {
                trHlp.Start();

                Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp);
                dbForm.Text = "Destination Database (In memory only)";
                dbForm.ShowDialog();

                trHlp.Commit();
            }
        }
Example #3
0
        WblockObjects1()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            PromptKeywordOptions prOpts = new PromptKeywordOptions("\nWblock a block or objects");

            prOpts.Keywords.Add("Block", "Block", "Block", true, true);
            prOpts.Keywords.Add("Objects", "Objects", "Objects", true, true);

            Editor       ed    = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptResult prRes = ed.GetKeywords(prOpts);

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

            Database db = null;

            using (TransactionHelper trHlp = new TransactionHelper(m_db)) {
                trHlp.Start();

                ObjectIdCollection objIds;
                if (!Utils.AcadUi.GetSelSetFromUser(out objIds))
                {
                    return;
                }

                if (prRes.StringResult == "Block")
                {
                    if (objIds.Count > 1)
                    {
                        ed.WriteMessage("\nSelect only one block");
                        return;
                    }
                    DBObject       obj  = trHlp.Transaction.GetObject(objIds[0], OpenMode.ForRead);
                    BlockReference bRef = obj as BlockReference;
                    if (bRef != null)
                    {
                        db = m_db.Wblock(bRef.BlockTableRecord);
                    }
                }

                if (prRes.StringResult == "Objects")
                {
                    db = m_db.Wblock(objIds, new Point3d(0, 0, 0));
                }

                trHlp.Commit();
            }

            if (db == null)
            {
                return;
            }

            using (TransactionHelper trHlp = new TransactionHelper(db)) {
                trHlp.Start();

                Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp);
                dbForm.Text = "Destination Database (In memory only)";
                dbForm.ShowDialog();

                trHlp.Commit();
            }
        }