Message 1 of 3

Not applicable
12-28-2018
12:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been looking for answers everywhere but I cannot find much on filters for multileaders. I figured it should be like Mtext but multileader but my code does not pick up any multileaders in my draft. The following code looks for Mtext and then Mleader, I separated the filters to try narrow down on where it was all going wrong but I still don't know why it wont pick them up. I have a pic of my test drawing; it deletes the text with numbers and both Mleaders but I am only trying to delete one of them.
using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; namespace DataCollection.Classes.Data { class deleteText { public static void delete(Database db, Editor ed, BlockTableRecord BtrModelWrite) { //////////////// TypedValue[] acTypValAr = new TypedValue[4]; acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "<and"), 0); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "MTEXT"), 1); acTypValAr.SetValue(new TypedValue((int)DxfCode.Text, "[~0123456789]"), 2); acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "and>"), 3); // Assign the filter criteria to a SelectionFilter object //SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); SelectionFilter sf = new SelectionFilter(acTypValAr); PromptSelectionResult psr = ed.SelectAll(sf); //// Request for objects to be selected in the drawing area //PromptSelectionResult acSSPrompt; //acSSPrompt = ed.GetSelection(acSelFtr); //SelectionSet acSSPrompt = selectAll.getSelectionSet(ed); if (psr.Status == PromptStatus.OK) { using (Transaction Trans = db.TransactionManager.StartTransaction()) { foreach (ObjectId text in psr.Value.GetObjectIds()) { //Check to see if the object is a polyline var rxClassPline = RXClass.GetClass(typeof(MText)); //Test the object for entity type if (text.ObjectClass.IsDerivedFrom(rxClassPline)) { MText hDelete = (MText)Trans.GetObject(text, OpenMode.ForWrite); hDelete.Erase(); } } Trans.Commit(); } } //////////////// acTypValAr = new TypedValue[4]; acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "<and"), 0); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "MULTILEADER"), 1); acTypValAr.SetValue(new TypedValue((int)DxfCode.Text, "[~0123456789]"), 2); acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "and>"), 3); // Assign the filter criteria to a SelectionFilter object //SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); sf = new SelectionFilter(acTypValAr); psr = ed.SelectAll(sf); //// Request for objects to be selected in the drawing area //PromptSelectionResult acSSPrompt; //acSSPrompt = ed.GetSelection(acSelFtr); //SelectionSet acSSPrompt = selectAll.getSelectionSet(ed); if (psr.Status == PromptStatus.OK) { using (Transaction Trans = db.TransactionManager.StartTransaction()) { foreach (ObjectId leaders in psr.Value.GetObjectIds()) { //Check to see if the object is a polyline var rxClassPline = RXClass.GetClass(typeof(MLeader)); //Test the object for entity type if (leaders.ObjectClass.IsDerivedFrom(rxClassPline)) { MLeader hDelete = (MLeader)Trans.GetObject(leaders, OpenMode.ForWrite); hDelete.Erase(); } } Trans.Commit(); } } } } }
Solved! Go to Solution.