【发布时间】:2016-01-27 13:36:19
【问题描述】:
我收到以下错误
“无法转换类型的对象
autodesk.autocad.databaseservices.polyline 键入 autodesk.autocad.databaseservices.blockreferences
在读取带有大量绘图内容的块属性时。
代码:
Dim db As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
Using tr As Transaction = db.TransactionManager.StartTransaction
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim blockids As ObjectIdCollection = New ObjectIdCollection
Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
For Each objid As ObjectId In btr
If btr.IsAnonymous = False Or btr.IsLayout = False Then
Dim blkref As BlockReference = tr.GetObject(objid, OpenMode.ForRead)
Dim attcol As AttributeCollection = blkref.AttributeCollection
For Each attid As ObjectId In attcol
Dim attref As AttributeReference = tr.GetObject(attid, OpenMode.ForRead)
ed.WriteMessage(attref.Tag.ToString & vbNewLine)
ed.WriteMessage(attref.TextString.ToString & vbNewLine)
Next
End If
Next
tr.Commit()
End Using
你能帮忙吗!!!
【问题讨论】:
标签: vb.net autocad-plugin