删除对象出错
我想删除这个对象,但是一运行 obj.Erase(True) cad就崩掉,要怎么操作才能删除它啊,求解,谢谢!Public Sub GetXData()
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim peo As PromptEntityOptions = New PromptEntityOptions("\n请选择实体:")
Dim per As PromptEntityResult = ed.GetEntity(peo)
'Dim ent As Entity = Nothing
If per.Status = PromptStatus.OK Then
Dim trans As Transaction = doc.TransactionManager.StartTransaction()
Dim obj As Entity = trans.GetObject(per.ObjectId, OpenMode.ForRead)
Dim rb As ResultBuffer = obj.XData
If rb Is Nothing Then
ed.WriteMessage("\n实体不包括扩展数据")
Else
Dim n As Integer = 0
Dim tv As TypedValue
For Each tv In rb
ed.WriteMessage("\n类型值{0} - 类型: {1}, 值: {2}", n, tv.TypeCode, tv.Value)
n = n + 1
Next
Try
If Not obj = Nothing Then
obj.Erase(True)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
rb.Dispose()
End If
trans.Dispose()
End If
End Sub
实体删除要写打开 果然如此啊,是我粗心了。谢谢!
页:
[1]