- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a routine that updates text. In lisp there is ENTUPD that allows you to visually update or regenerate an object. Below is the code I have to update the text objects. Right now I have a general REGEN whole drawing at end of routine. I would like to regen the object on the fly without having to regen whole drawing.
Dim CurrentDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
CurrentDrawing.LockDocument()
Dim acTypValAr(0) As Autodesk.AutoCAD.DatabaseServices.TypedValue
acTypValAr.SetValue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(Autodesk.AutoCAD.DatabaseServices.DxfCode.Start, "TEXT"), 0)
Dim acSelFtr As Autodesk.AutoCAD.EditorInput.SelectionFilter = New Autodesk.AutoCAD.EditorInput.SelectionFilter(acTypValAr)
Dim ed As Autodesk.AutoCAD.EditorInput.Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim acSSPrompt As Autodesk.AutoCAD.EditorInput.PromptSelectionResult
acSSPrompt = ed.SelectAll(acSelFtr)
If acSSPrompt.Status = Autodesk.AutoCAD.EditorInput.PromptStatus.OK Then
Dim acSSet As Autodesk.AutoCAD.EditorInput.SelectionSet = acSSPrompt.Value
Using Trans As Autodesk.AutoCAD.DatabaseServices.Transaction = CurrentDrawing.Database.TransactionManager.StartTransaction
For Each selObj In acSSet
Dim x As ObjectId = selObj.ObjectId
Dim textObj As Autodesk.AutoCAD.DatabaseServices.DBText = Trans.GetObject(selObj.ObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False, True)
Dim OldTextString As String = textObj.TextString
Dim NewTextString As String = Replace(OldTextString, CurrentFind, CurrentReplace, 1, -1, CompareMethod.Text)
If OldTextString <> NewTextString Then
textObj.TextString = NewTextString
End If
textObj.Dispose()
Next
Trans.Commit()
End Using
End If
Thank in advance for any input.
Solved! Go to Solution.