Exemplo n.º 1
0
        public override void DeleteCADObject(Autodesk.AutoCAD.ApplicationServices.Document doc)
        {
            string[] Layers = null;

            if (this.SURVEY_ID.StartsWith("WS"))
            {
                Layers = new string[] { "0", "WSPoint", "WSText" }
            }
            ;
            else
            {
                Layers = new string[] { "0", "YSPoint", "YSText" }
            };
            Autodesk.AutoCAD.Interop.AcadDocument AcadDoc = doc.AcadDocument as Autodesk.AutoCAD.Interop.AcadDocument;

            Editor ed    = doc.Editor;
            int    count = 0;

            foreach (string Layer in Layers)
            {
                TypedValue[] tvs = new TypedValue[]

                {
                    new TypedValue((int)DxfCode.LayerName, Layer)
                };
                SelectionFilter sf = new SelectionFilter(tvs);

                PromptSelectionResult psr = ed.SelectAll(sf);

                if (psr.Status == PromptStatus.OK)
                {
                    SelectionSet SS = psr.Value;

                    ObjectId[] idArray = SS.GetObjectIds();

                    for (int i = 0; i < idArray.Length; i++)
                    {
                        if (this is IPipePoint && count == 2)
                        {
                            break;
                        }
                        else if (this is IPIPELine && count == 3)
                        {
                            break;
                        }
                        //Entity ent = (Entity)Tools.GetDBObject(idArray[i]);
                        AcadEntity pAcadEntity = AcadDoc.ObjectIdToObject(idArray[i].OldIdPtr.ToInt64()) as AcadEntity;

                        string ObjectID = GetPointObjectID(pAcadEntity);
                        if (ObjectID.Equals(this.ID))
                        {
                            pAcadEntity.Delete();
                            count++;
                        }
                    }
                }
            }
            AcadDoc.Save();
        }