コード例 #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
ファイル: Details.cs プロジェクト: zhengjian211/MgdDbg
        /// <summary>
        ///
        /// </summary>
        private void DisplayMapItems()
        {
            System.Collections.IEnumerator iter = m_idMap.GetEnumerator();
            while (iter.MoveNext())
            {
                AcDb.IdPair pair = (AcDb.IdPair)iter.Current;

                try {
                    ListViewItem item = new ListViewItem(AcadUi.ObjToTypeAndHandleStr(pair.Key));
                    item.SubItems.Add(pair.Key.ToString());
                    item.SubItems.Add(pair.Value.ToString());
                    item.SubItems.Add(pair.IsCloned.ToString());
                    item.SubItems.Add(pair.IsPrimary.ToString());
                    item.SubItems.Add(pair.IsOwnerTranslated.ToString());
                    item.Tag = pair;
                    m_listViewMapItem.Items.Add(item);
                }
                catch (Autodesk.AutoCAD.Runtime.Exception e) {
                    MessageBox.Show("Couldn't add a pair from the map: " + e.Message);
                }
            }
        }
コード例 #4
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()));
            }
        }
コード例 #5
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()));
            }
        }
コード例 #6
0
ファイル: TestCmds.cs プロジェクト: zhengjian211/MgdDbg
        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()));
                }
            }
        }
コード例 #7
0
ファイル: Details.cs プロジェクト: zhengjian211/MgdDbg
        /// <summary>
        ///
        /// </summary>
        private void DisplayMapProps()
        {
            ListViewItem item = new ListViewItem();

            item.Text = "Destination Database";
            try {
                item.SubItems.Add(AcadUi.DbToStr(m_idMap.DestinationDatabase));
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e) {
                item.SubItems.Add(e.Message);
            }
            m_listViewMap.Items.Add(item);

            ListViewItem item1 = new ListViewItem();

            item1.Text = "Original Database";
            try {
                item.SubItems.Add(AcadUi.DbToStr(m_idMap.OriginalDatabase));
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e) {
                item.SubItems.Add(e.Message);
            }
            m_listViewMap.Items.Add(item1);

            ListViewItem item2 = new ListViewItem();

            item2.Text = "Deep Clone Context";
            item2.SubItems.Add(m_idMap.DeepCloneContext.ToString());
            m_listViewMap.Items.Add(item2);

            ListViewItem item3 = new ListViewItem();

            item3.Text = "Duplicate Record Cloning";
            item3.SubItems.Add(m_idMap.DuplicateRecordCloning.ToString());
            m_listViewMap.Items.Add(item3);
        }
コード例 #8
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()));
            }
        }