Пример #1
0
        InsertInModelSpace()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            string dwgName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to insert from", "Dwg files (*.dwg)|*.dwg");

            if (dwgName.Length == 0)
            {
                return;
            }

            Database extDb = new Database(false, true);

            extDb.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, null);

            if (extDb == null)
            {
                return;
            }

            try {
                m_db.Insert(Matrix3d.Identity, extDb, true);
            }
            catch (AcRx.Exception e) {
                AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString()));
            }
        }
Пример #2
0
        CountHardReferences()
        {
            Snoop.ObjIdSet objSet = Snoop.Utils.GetSnoopSet();
            if (objSet == null)
            {
                return;
            }

            int[] countArray = new int[objSet.Set.Count];

            if (countArray.Length > 0)
            {
                objSet.Db.CountHardReferences(objSet.Set, countArray);
            }

            for (int i = 0; i < objSet.Set.Count; i++)
            {
                AcadUi.PrintToCmdLine(string.Format("\n{0,-30}: {1:d}", AcadUi.ObjToTypeAndHandleStr(objSet.Set[i]), countArray[i]));
            }
        }
Пример #3
0
        InsertInBlockTable()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            string dwgName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to insert from", "Dwg files (*.dwg)|*.dwg");

            if (dwgName.Length == 0)
            {
                return;
            }

            try {
                Database extDb = new Database(false, true);
                extDb.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, null);

                ObjectId objId = m_db.Insert("MgdDbg_InsertedBlock", extDb, true);     // TBD: should allow user to name the destination block
                using (TransactionHelper trHlp = new TransactionHelper(m_db)) {
                    trHlp.Start();

                    ObjectIdCollection objIds = new ObjectIdCollection();
                    objIds.Add(objId);

                    Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(objIds, trHlp);
                    objs.Text = "Inserted Block";
                    objs.ShowDialog();

                    trHlp.Commit();
                }
            }
            catch (AcRx.Exception e) {
                AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString()));
            }
        }
Пример #4
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()));
            }
        }
Пример #5
0
        SnoopEntityByHandle()
        {
            ObjectId           id     = ObjectId.Null;
            ObjectIdCollection selSet = new ObjectIdCollection();

            Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;

            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            PromptStringOptions options = new PromptStringOptions("Handle of database object");

            String str = ed.GetString(options).StringResult;

            if (str != String.Empty)
            {
                Handle h = Utils.Db.StringToHandle(str);

                try {
                    id = Utils.Db.HandleToObjectId(db, h);

                    selSet.Add(id);

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

                        Snoop.Forms.DBObjects dbox = new Snoop.Forms.DBObjects(selSet, trHlp);
                        dbox.Text = "Selected Entities";
                        AcadApp.ShowModalDialog(dbox);

                        trHlp.Commit();
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception x) {
                    AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((ErrorStatus)x.ErrorStatus).ToString()));
                }
            }
        }
Пример #6
0
        Purge()
        {
            m_db = Utils.Db.GetCurDwg();
            if (m_db == null)
            {
                return;
            }

            Snoop.ObjIdSet objSet = Snoop.Utils.GetSnoopSet();
            if (objSet == null)
            {
                return;
            }

            // set the purgeableIds to everything selected
            ObjectIdCollection purgableIds = new ObjectIdCollection();

            foreach (ObjectId objId in objSet.Set)
            {
                purgableIds.Add(objId);
            }

            ObjectIdCollection nonPurgableIds = new ObjectIdCollection();

            try {
                m_db.Purge(purgableIds);

                // see which ones were non-purgeable by seeing which ones got taken out of the array
                foreach (ObjectId objId in objSet.Set)
                {
                    if (!purgableIds.Contains(objId))
                    {
                        nonPurgableIds.Add(objId);
                    }
                }

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

                    if (purgableIds.Count == 0)
                    {
                        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("No purgable objects");
                    }
                    else
                    {
                        Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(purgableIds, trHlp);
                        objs.Text = "Purgable objects";
                        objs.ShowDialog();
                    }

                    if (nonPurgableIds.Count == 0)
                    {
                        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("No non-purgable objects");
                    }
                    else
                    {
                        Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(nonPurgableIds, trHlp);
                        objs.Text = "Non-purgable objects";
                        objs.ShowDialog();
                    }

                    trHlp.Commit();
                }
            }
            catch (AcRx.Exception e) {
                AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString()));
            }
        }