Message 1 of 6
AutoCAD crashes by using ObjectAppended only with some entities
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I would like to re-encode my plug-in lighter, in order to optimize tasks.
So I would like to store dynamically, in an ArrayList or else, entities properties (ID, Layer, Bounds...etc.) by using reactors.
It works! but not with every entity! For instance AutoCAD crashes when I create a CIRCLE while ObjectAppended is invoking.
Here is a simply code to resume:
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.EditorInput Public Class Class1 Friend acDoc As Document = Application.DocumentManager.MdiActiveDocument Friend acCurDb As Database = acDoc.Database Friend ed As Editor = acDoc.Editor <CommandMethod("Test")> _ Public Sub Test() AddHandler acCurDb.ObjectAppended, AddressOf MyDelegate End Sub Public Sub MyDelegate(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs) On Error Resume Next Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acblktbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) Dim acblkTblRec As BlockTableRecord = acTrans.GetObject(acblktbl(BlockTableRecord.ModelSpace), OpenMode.ForRead) For Each acObjId As ObjectId In acblkTblRec If acObjId = e.DBObject.ObjectId Then Dim MyEnt As Entity = acTrans.GetObject(acObjId, OpenMode.ForRead) Dim message As String = MyEnt.GetRXClass.DxfName.ToString & vbLf Select Case MyEnt.GetRXClass.DxfName Case Is = "LWPOLYLINE" Dim Mypolyline As Polyline = CType(MyEnt, Entity) message += "Area= " & Mypolyline.Area.ToString & vbLf message += "Layer= " & Mypolyline.Layer.ToString & vbLf message += "Min point= " & Mypolyline.Bounds.Value.MinPoint.ToString & vbLf message += "Max point= " & Mypolyline.Bounds.Value.MaxPoint.ToString & vbLf Case Is = "CIRCLE" Dim Mycircle As Circle = CType(MyEnt, Circle) message += "Area= " & Mycircle.Area.ToString & vbLf message += "Calque= " & Mycircle.Layer.ToString & vbLf message += "Radius= " & Mycircle.Radius.ToString & vbLf End Select MsgBox(message) End If Next End Using End Sub End Class
What can I do to solve that!?