![]() |
【转帖】vb.net的代码问题
vb.net的代码问题
www.dimcax.com vb.net的代码问题 dim strfilename as string '文件名 dim acadapp as new acadapplication dim doc as acaddocument opfd.showdialog() '获取文件名 strfilename = opfd.filename doc = acadapp.documents.open(strfilename) '打开cad文件 dim ssetobj as acadselectionset '定义一个选择集 dim acadent as acadentity '定义一个图元实体 dim adadpl as acadpolyline ssetobj = acadapp.activedocument.selectionsets.add("test") ssetobj.select(acselect.acselectionsetall, , , , ) '选择所有实体 for each acadent in ssetobj if acadent.objectname = "acdbpolyline" then adadpl = acadent ' 这句出错 end if next 以上代码的红色部分出错,本人初学,弄了很长时间不知道原因,请高手解答!! 错误原因: 无法将类型为“system.__comobject”的 com 对象强制转换为接口类型“autocad.acadpolyline”。此操作失败的原因是对 iid 为“{4d07b3da-1d65-4d58-967a-e3a02e255ee0}”的接口的 com 组件调用 queryinterface 因以下错误而失败: 不支持此接口 (异常来自 hresult:0x80004002 (e_nointerface))。 [此贴子已经被作者于 adadpl 是 acadpolyline acadent 是 acadentity 两者的数据类型不一样,这样的赋值需要一个显式转换 adadpl = (acadpolyline)acadent 这是c#的语法,vb的忘了! 不敢肯定是这个原因或只有这个原因导致出错,你应该把出错提示贴出来 我是想得到图层所有acadpolyline 的有关数据,楼上所说我试过了,还是有问题 不过还是谢谢楼上的大哥 |
| 所有的时间均为北京时间。 现在的时间是 02:17 AM. |