如何复制一个打开的图形文件,我的出错了
本帖最后由 lindunling 于 2012-2-29 10:47 编辑<CommandMethod("CreateTkMap")> Public Sub CreateTkMap()
Dim acObjIdColl As ObjectIdCollection = New ObjectIdCollection()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim acSSPrompt As PromptSelectionResult
acSSPrompt = acDocEd.SelectAll()
If acSSPrompt.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = acSSPrompt.Value
For Each acSSObj As SelectedObject In acSSet
acObjIdColl.Add(acSSObj.ObjectId)
Next
Else
Application.ShowAlertDialog("活动文档无内容或复杂过程出现错误!")
Exit Sub ' 退出
End If
Dim sLocalRoot As String = Application.GetSystemVariable("LOCALROOTPREFIX")
Dim sTemplatePath As String = sLocalRoot + "Template\acad.dwt"
Dim acDocMgr As DocumentCollection = Application.DocumentManager
Dim acNewDoc As Document = acDocMgr.Add(sTemplatePath)
Dim acDbNewDoc As Database = acNewDoc.Database
Using acLckDoc As DocumentLock = acNewDoc.LockDocument()
Using acTrans = acDbNewDoc.TransactionManager.StartTransaction()
Dim acBlkTblNewDoc As BlockTable
acBlkTblNewDoc = acTrans.GetObject(acDbNewDoc.BlockTableId, OpenMode.ForWrite)
Dim acBlkTblRecNewDoc As BlockTableRecord
acBlkTblRecNewDoc = acTrans.GetObject(acBlkTblNewDoc(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim acIdMap As IdMapping = New IdMapping()
'acIdMap.DestinationDatabase = acCurDb
acDocMgr.MdiActiveDocument = acNewDoc
acCurDb.WblockCloneObjects(acObjIdColl, acBlkTblRecNewDoc.ObjectId, acIdMap, DuplicateRecordCloning.Replace, False)
acTrans.Commit()
End Using
End Using
'acDocMgr.MdiActiveDocument = acNewDoc
'对新图形文件继续操作出问题 如双击图形
End Sub 本帖最后由 lindunling 于 2012-2-29 10:47 编辑
我是想把一个打开的图形文件复制一份,然后在复制的文件上进行进一步的操作。
如果执行下面的命令是没有问题的,保存的图形也是没有问题的
acNewDoc.CloseAndSave("c:\fft.dwg")' 关闭 保存
但是我要执行别的操作,如缩放,程序崩溃了。
大家能不能帮我找找问题所在 换一个版本呢 秋天的飓风 发表于 2012-2-29 10:50 static/image/common/back.gif
换一个版本呢
画一些简单的线条 再执行这个命令 程序没有什么问题
再用一下工程图执行这个命令 就出现问题了
我想是不是拷贝过程,没有收尾的操作
应该不是版本问题
页:
[1]