- 积分
- 623
- 明经币
- 个
- 注册时间
- 2012-6-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
如果不选择实体,重复多次点同一个按钮,cad崩溃,如何释放??求教。。。
Dim strNum As String
Dim text1 As DBText
'Dim BReference As BlockReference
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim documentLock As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim opt As New PromptEntityOptions("请选择界址线" + vbCrLf)
Dim res As PromptEntityResult = ed.GetEntity(opt)
If res.Status <> PromptStatus.OK Then
Exit Function
End If
Dim ent As Entity = trans.GetObject(res.ObjectId, OpenMode.ForWrite)
If ent.GetType().Name.ToString() <> "Polyline" Then
Application.ShowAlertDialog("选择的实体类型不对!")
Exit Function
End If
'Dim pt As Point3d = BReference.Position
Dim reg As RegAppTable = trans.GetObject(db.RegAppTableId, OpenMode.ForWrite)
If Not reg.Has("界址线类别") Then
Dim app As New RegAppTableRecord
app.Name = "界址线类别"
reg.Add(app)
trans.AddNewlyCreatedDBObject(app, True)
End If
Dim rb As New ResultBuffer( _
New TypedValue(DxfCode.ExtendedDataRegAppName, "界址线类别"), _
New TypedValue(DxfCode.ExtendedDataAsciiString, str))
ent.XData = rb
trans.Commit()
ed.WriteMessage("添加成功!" + vbCrLf)
End Using
documentLock.Dispose()
|
|