从C#的代码转换到VB.NET的,如果选择带有扩展数据的对象,程序能正常运行,但是如果对象不包含扩展数据,就会导致CAD崩溃。我想原因是不是出在Not IsDBNull(resBuf) 这一句上,C#为(resBuf != null),我这样转换不对吗?求解
- Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
- Dim acCurDb As Database = acDoc.Database
- Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction
- Dim acEntityOpts As PromptEntityOptions = New PromptEntityOptions("")
- Dim acEntityRsl As PromptEntityResult = acDoc.Editor.GetEntity(acEntityOpts)
- Dim acEnt As Entity = acTrans.GetObject(acEntityRsl.ObjectId, OpenMode.ForRead, True)
- Dim resBuf As ResultBuffer = acEnt.XData
- If Not IsDBNull(resBuf) Then
- Dim iter As IEnumerator = resBuf.GetEnumerator()
- While iter.MoveNext()
- Dim tmpVal As TypedValue = iter.Current
- acDoc.Editor.WriteMessage(vbLf & tmpVal.TypeCode.ToString & ":" & tmpVal.Value.ToString())
- End While
- End If
- End Using
|