Skip to content

Commit 801ec22

Browse files
committed
Create QuickSelectFilter.cs
1 parent fc4e6cd commit 801ec22

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Autodesk.AutoCAD.ApplicationServices.Core;
2+
using Autodesk.AutoCAD.DatabaseServices;
3+
using Autodesk.AutoCAD.EditorInput;
4+
using Autodesk.AutoCAD.Runtime;
5+
6+
namespace Test.Selection;
7+
8+
public class QuickSelectFilter
9+
{
10+
[CommandMethod("SelectText")]
11+
public static void SelectText()
12+
{
13+
var doc = Application.DocumentManager.MdiActiveDocument;
14+
var db = doc.Database;
15+
var ed = doc.Editor;
16+
var peo = new PromptEntityOptions("\nSelect a text: ");
17+
peo.SetRejectMessage("\nSelected object is not a text.");
18+
peo.AddAllowedClass(typeof(DBText), true);
19+
var per = ed.GetEntity(peo);
20+
if (per.Status != PromptStatus.OK)
21+
return;
22+
using (var tr = db.TransactionManager.StartTransaction())
23+
{
24+
var ent = (DBText)tr.GetObject(per.ObjectId, OpenMode.ForRead);
25+
ed.WriteMessage($"\n{ent.TextString}");
26+
tr.Commit();
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)