Community
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<MRHooker2u> wrote in messageI
href="news:6254527@discussion.autodesk.com">news:6254527@discussion.autodesk.com...
am trying to update some text in a group of drawings outside of AutoCAD's
drawing editor using VB.NET. The code runs without error but the text is not
updated in the drawing file. With a few minor tweeks, most of this code is
from Jerry Winter's VB.NET programming book. Where I think I am having the
problem is myText = myEnt, doing the edit to myText, then saying myEnt =
myText. I have tried the statement: myText.UpgradeOpen() and leaving out the
myEnt = myText statement but I get the same results.
Any insight would be
helpful. Thanks!
Added Note: If I insert a myDB.SaveAs after the
myTrans.Commit and save the drawings under a different name the text edits
have been made.
Code:
Dim myTransMan As
Autodesk.AutoCAD.DatabaseServices.TransactionManager = Nothing
Dim myText
As New DBText
' Reads a log file and builds list of files to update
getISOGenFiles(ProjectID)
Try
For Each FileName As String In
colIsoNumber
' Now open the .dwg file and extract the line data
Dim myDB
As New DatabaseServices.Database
myDB.ReadDwgFile(FileName,
IO.FileShare.Read, True, "")
Dim myTrans As
Autodesk.AutoCAD.DatabaseServices.Transaction
myTransMan =
myDB.TransactionManager
myTrans = myTransMan.StartTransaction
myBT =
myDB.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
mySTE =
myBT.GetEnumerator
While mySTE.MoveNext
myBTR =
mySTE.Current.GetObject(DatabaseServices.OpenMode.ForRead)
If
myBTR.IsLayout = True Then
myBTE = myBTR.GetEnumerator
Dim myEnt As
DatabaseServices.Entity
While myBTE.MoveNext
myEnt =
myBTE.Current.GetObject(DatabaseServices.OpenMode.ForRead)
If TypeOf myEnt
Is DatabaseServices.DBText Then
myText = myEnt
If
myText.TextString.Contains("NOINS") Or _
myText.TextString.Contains("_")
Then
myEnt.UpgradeOpen()
' This function updates the text
string
myText.TextString = ExtractText(myText.TextString)
myEnt =
myText
End If
End If
End While
End If
End
While
myTrans.Commit()
myTrans.Dispose()
Next
Catch ex As
System.Exception
MessageBox.Show(ex.Message & vbCrLf & vbCrLf &
ex.StackTrace,
ex.GetType().ToString())
Finally
myTransMan.Dispose()
End Try Edited
by: MRHooker2u on Sep 15, 2009 2:23 PM Edited by: MRHooker2u on Sep 15, 2009
2:27 PM