你好,
我有一个问题。从今天开始,我测试我的代码以将autocadversion从2014年更改为2017年。
在2014年工作正常,但在2017年抛出eWrongDatase错误。我的失败是什么?
2014年的代码工作:
- // objectIds selected by typevalue selection on editor
- selectedIds = new ObjectIdCollection(acPromptSelectionResult.Value.GetObjectIds());
- if (selectedIds != null)
- {
- if (selectedIds.Count > 0)
- {
- String newFilename = "";
- if (item.UseCurrentDwgName)
- {
- newFilename = System.IO.Path.GetFileName(myTransaction.AcDocument.Name);
- newFilename = newFilename.Remove(newFilename.Length - 4);
- if (!ClassStringTools.IsNullOrWhiteSpace(item.Prefix))
- newFilename = item.Prefix + newFilename;
- if (!ClassStringTools.IsNullOrWhiteSpace(item.Postfix))
- newFilename += item.Postfix;
- newFilename += ".dwg";
- }
- else
- {
- newFilename = item.ManualSeparationName;
- if (!newFilename.ToLower().EndsWith(".dwg"))
- newFilename += ".dwg";
- }
- if (System.IO.Directory.Exists(item.Path))
- {
- newFilename = ClassFileTools.addBackslashIfMissing(item.Path) + newFilename;
- Database oldACDatabase = HostApplicationServices.WorkingDatabase;
- using (Document newDoc = DocumentCollectionExtension.Add(Application.DocumentManager, AppSettingsSeparation.getSettings().NewDWGTemplate))
- //Application.DocumentManager.Add(AppSettingsSeparation.getSettings().NewDWGTemplate))
- {
- Boolean canWrite = true;
- using (DocumentLock newDocLoc = newDoc.LockDocument())
- {
- using (Database newDb = newDoc.Database)
- {
- try
- {
- if (System.IO.File.Exists(newFilename))
- {
- if (!ClassFileTools.DeleteToRecycleBin(newFilename))
- canWrite = false;
- }
- if (canWrite)
- {
- // -------- now chrashed -----
- myTransaction.AcDatabase.Wblock(newDb, selectedIds, Point3d.Origin, DuplicateRecordCloning.Ignore);
- // <<< this crashed.
- }
- }
- catch (System.Exception ex)
- {
- clEditor.LogException(ex);
- Log.LogException(ex);
- }
- }
- }
- if (canWrite)
- {
- try
- {
- clTransaction newTransaction = clSingletonTransaktionsManager.Instance.getTransaction(newDoc, TRANSACTIONNAME); // is my transactionmanager
- clDatabase.purgeGeoPlaceMarker(newTransaction);
- if (iAmNotAutoCAD)
- clKillProxy.cleanCivilObjects(newTransaction);
- clSingletonTransaktionsManager.Instance.CommitTransaction(newTransaction);
- clTransaction.lockDatabase(newDoc);
- newDoc.Database.SaveAs(newFilename, DwgVersion.Newest);
- newDoc.CloseAndDiscard();
- result = true;
- }
- catch (System.Exception ex)
- {
- Log.LogException(ex);
- clEditor.LogException(ex);
- result = false;
- }
- }
- else
- {
- newDoc.CloseAndDiscard();
- result = false;
- }
- }
- Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = sourceDocument;
- }
- }
- }
- }
有任何机构在2017年工作的例子吗?
问候马里奥
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |