So, I'm trying to build a filter to select all text in a document, but the version of
Autodesk.AutoCAD.DatabaseServices.DxfCode that comes with Autodesk Map doesn't seem to have the Operator code included in it.
How do I access operators with Autodesk Map?
I might be missing something here. This method from Hallex in the .net forum selects all text. This is generic autocad - not specific to any vertical product (Autodesk.AutoCad.EditorInput namespace in the accoremgd assembly).
' Imports System.Collections.Specialized
Private Function ExtractText() As StringCollection
Dim txtcoll As New StringCollection
Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Try
Using tr As Transaction = db.TransactionManager.StartTransaction
Dim res As PromptSelectionResult
Dim filterList(,) As Object = New Object(,) {{-4, "<or"}, {0, "text"}, {0, "mtext"}, {-4, "or>"}} '' etc
Dim tvs(filterList.GetUpperBound(0)) As TypedValue
For i As Integer = 0 To filterList.GetUpperBound(0)
tvs(i) = New TypedValue(Convert.ToInt32(filterList(i, 0)), filterList(i, 1))
Next
Dim filt As SelectionFilter = New SelectionFilter(tvs)
res = ed.SelectAll(filt)
If res.Status <> PromptStatus.OK Then
Return Nothing
End If
For Each sobj As SelectedObject In res.Value
Dim ent As Entity = tr.GetObject(sobj.ObjectId, OpenMode.ForRead)
Dim txt As DBText = TryCast(ent, DBText)
If txt IsNot Nothing Then
txtcoll.Add(txt.TextString)
End If
Dim mtxt As MText = TryCast(ent, MText)
If mtxt IsNot Nothing Then
txtcoll.Add(mtxt.Contents)
End If
Next
End Using
Catch exs As System.Exception
ed.WriteMessage(exs.Message & vbLf & exs.StackTrace)
Return Nothing
Finally
End Try
Return txtcoll
End Function