-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |