明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1568|回复: 3

[基础] 求教关于读取扩展数据的问题

[复制链接]
发表于 2014-4-2 19:55 | 显示全部楼层 |阅读模式
从C#的代码转换到VB.NET的,如果选择带有扩展数据的对象,程序能正常运行,但是如果对象不包含扩展数据,就会导致CAD崩溃。我想原因是不是出在Not IsDBNull(resBuf) 这一句上,C#为(resBuf != null),我这样转换不对吗?求解
  1.         Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  2.         Dim acCurDb As Database = acDoc.Database

  3.         Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction
  4.             Dim acEntityOpts As PromptEntityOptions = New PromptEntityOptions("")
  5.             Dim acEntityRsl As PromptEntityResult = acDoc.Editor.GetEntity(acEntityOpts)
  6.             Dim acEnt As Entity = acTrans.GetObject(acEntityRsl.ObjectId, OpenMode.ForRead, True)
  7.             Dim resBuf As ResultBuffer = acEnt.XData
  8.             If Not IsDBNull(resBuf) Then
  9.                 Dim iter As IEnumerator = resBuf.GetEnumerator()
  10.                 While iter.MoveNext()
  11.                     Dim tmpVal As TypedValue = iter.Current
  12.                     acDoc.Editor.WriteMessage(vbLf & tmpVal.TypeCode.ToString & ":" & tmpVal.Value.ToString())
  13.                 End While
  14.             End If
  15.         End Using

发表于 2014-4-3 22:13 | 显示全部楼层
你把isdbnull这一句换成isnothing试试?我也没怎么使用VB,也不是太了解,希望能帮到你
 楼主| 发表于 2014-4-4 12:49 | 显示全部楼层
cdinten 发表于 2014-4-3 22:13
你把isdbnull这一句换成isnothing试试?我也没怎么使用VB,也不是太了解,希望能帮到你

改成isnothing就没有问题了,感谢
发表于 2014-4-4 17:26 | 显示全部楼层
wuqiu1986 发表于 2014-4-4 12:49
改成isnothing就没有问题了,感谢

居然被我蒙对了?哈哈
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 07:59 , Processed in 0.290993 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表