Skip to content

Commit

Permalink
Create QuickSelectFilter.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed May 29, 2022
1 parent fc4e6cd commit 801ec22
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Test/Selection/QuickSelectFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Autodesk.AutoCAD.ApplicationServices.Core;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

namespace Test.Selection;

public class QuickSelectFilter
{
[CommandMethod("SelectText")]
public static void SelectText()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var peo = new PromptEntityOptions("\nSelect a text: ");
peo.SetRejectMessage("\nSelected object is not a text.");
peo.AddAllowedClass(typeof(DBText), true);
var per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
return;
using (var tr = db.TransactionManager.StartTransaction())
{
var ent = (DBText)tr.GetObject(per.ObjectId, OpenMode.ForRead);
ed.WriteMessage($"\n{ent.TextString}");
tr.Commit();
}
}
}

0 comments on commit 801ec22

Please sign in to comment.