- 积分
- 1195
- 明经币
- 个
- 注册时间
- 2010-1-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
报错-----尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
查了一下原来的帖子说是函数本身有问题,还有能解决的办法没,想复制块到数据库中,然后插入块
原来用2010的,但是有个小程序要用06写,有木有什么解决办法
- Dim documents As DocumentCollection = Application.DocumentManager Dim editor As Editor = documents.MdiActiveDocument.Editor Dim database As Database = documents.MdiActiveDocument.Database Dim sourceDb As New Database(False, False) Dim ex As Autodesk.AutoCAD.Runtime.Exception Try sourceDb.ReadDwgFile(sourceFileName, FileShare.Write, True, Nothing) Dim ids As ObjectIdCollection = New ObjectIdCollection() Dim manager As Autodesk.AutoCAD.DatabaseServices.TransactionManager = sourceDb.TransactionManager Dim transaction As Transaction = manager.StartTransaction Using transaction Dim table As BlockTable = CType(manager.GetObject(sourceDb.BlockTableId, OpenMode.ForRead, False), BlockTable) Dim id As ObjectId For Each id In table Dim record As BlockTableRecord = CType(manager.GetObject(id, OpenMode.ForRead, False), BlockTableRecord) If Not record.IsAnonymous And Not record.IsLayout Then ids.Add(id) record.Dispose() End If Next transaction.Commit() table.Dispose() transaction.Dispose() End Using 'Dim mapping As New IdMapping 'Dim cloning As New DuplicateRecordCloning sourceDb.WblockCloneObjects(ids, database.BlockTableId, DuplicateRecordCloning.Replace, False) 'doctemp.CloseAndDiscard() 'doctemp.Dispose() Catch ex editor.WriteMessage("复制出错" + ex.Message) End Try sourceDb.Dispose() database.Dispose()
|
|