- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm inserting a blockref and text to a drawing using a modeless windows form.
So I lock the document first before doing anything
I make the blockref and insert it using entityjig, add the newly created blockref, then rotate it with jig, commit and then add xdata to it
No problem so far, and then, in the same sub, I add a single line text (DBText), and set xdata for it (calling the same sub below)
The problem is that AutoCAD crashes with an unhandled exception when setting the xdata for the text entity.
If I don't set xdata for the Text, everything works fine.
Any ideas ??
Public Sub SetXData(mcaja As Entity, appname As String, idc As Long, ncaja As String)
Dim rb As ResultBuffer
Dim adoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim tr As Transaction = adoc.TransactionManager.StartTransaction()
Using tr
Dim obj As DBObject = tr.GetObject(mcaja.ObjectId, OpenMode.ForWrite)
AddRegAppTableRecord(appname, adoc)
rb = New ResultBuffer(New TypedValue(1001, appname), New TypedValue(1000, ncaja), New TypedValue(1071, idc))
obj.XData = rb
rb.Dispose()
tr.Commit()
End Using
End Sub
Public Shared Sub AddRegAppTableRecord(regAppName As String, ByRef doc As Document)
'Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim tr As Transaction = doc.TransactionManager.StartTransaction()
Using tr
Dim ratab As RegAppTable = CType(tr.GetObject(db.RegAppTableId, OpenMode.ForRead, False), RegAppTable)
If Not ratab.Has(regAppName) Then
ratab.UpgradeOpen()
Dim ratrec As New RegAppTableRecord()
ratrec.Name = regAppName
ratab.Add(ratrec)
tr.AddNewlyCreatedDBObject(ratrec, True)
End If
tr.Commit()
End Using
End Sub
Solved! Go to Solution.