private void btnRun_Click(object sender, EventArgs e) { var arguments = GeneralCommandArguments(); if (arguments == null) { return; } using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, this); return; } } try { var executePath = Assembly.GetExecutingAssembly().Location; Process.Start(executePath, arguments); } catch (Win32Exception) { var message = StringsUI.CommandCallIsBlocked; MessageBox.Show(message, Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
bool IExportControl.Run() { var filePath = txtTargetPath.Text; if (string.IsNullOrEmpty(filePath)) { ShowMessageBox(Strings.MessageSelectOutputPathFirst); return(false); } #if !R2014 if (CustomExporter.IsRenderingSupported() == false && ShowConfirmBox(Strings.ExportWillFailBecauseMaterialLib) == false) { return(false); } #endif if (File.Exists(filePath) && ShowConfirmBox(Strings.OutputFileExistedWarning) == false) { return(false); } var homePath = InnerApp.GetHomePath(); if (InnerApp.CheckHomeFolder(homePath) == false && ShowConfirmBox(Strings.HomeFolderIsInvalid) == false) { return(false); } var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo; if (visualStyle != null) { foreach (var p in visualStyle.Features) { _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value); } } var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault; #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } SetFeature(FeatureType.Export2DViewAll, rb2DViewsAll.Checked); SetFeature(FeatureType.Export2DViewOnlySheet, rb2DViewsOnlySheet.Checked); SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked); //SetFeature(FeatureType.GenerateElementData, cbGeneratePropDbJson.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.GenerateLeaflet, cbGenerateLeaflet.Checked); SetFeature(FeatureType.GenerateDwgDrawing, cbGenerateDwg.Checked); SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked); SetFeature(FeatureType.ExportRooms, cbIncludeRooms.Checked); SetFeature(FeatureType.ExcludeProperties, cbExcludeElementProperties.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked); SetFeature(FeatureType.ConsolidateGroup, cbConsolidateArrayGroup.Checked); SetFeature(FeatureType.ConsolidateAssembly, cbConsolidateAssembly.Checked); SetFeature(FeatureType.UseLevelCategory, rbGroupByLevelDefault.Checked); SetFeature(FeatureType.UseNwLevelCategory, rbGroupByLevelNavisworks.Checked); SetFeature(FeatureType.UseBoundLevelCategory, rbGroupByLevelBoundingBox.Checked); SetFeature(FeatureType.UseCurrentViewport, cbUseCurrentViewport.Checked); #endregion var isCanncelled = false; using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, ParentForm); return(false); } #region 保存设置 var config = _LocalConfig; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = txtTargetPath.Text; config.VisualStyle = visualStyle?.Key; config.LevelOfDetail = levelOfDetail?.Value ?? -1; _Config.Save(); #endregion var sw = Stopwatch.StartNew(); try { var setting = new ExportSetting(); setting.LevelOfDetail = config.LevelOfDetail; setting.ExportType = ExportType.Zip; setting.OutputPath = config.LastTargetPath; setting.Features = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList(); setting.SelectedElementIds = _ElementIds?.Where(x => x.Value).Select(x => x.Key).ToList(); setting.Selected2DViewIds = rb2DViewCustom.Checked ? _ViewIds : null; setting.Oem = LicenseConfig.GetOemInfo(homePath); var hasSuccess = false; using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); #if !DEBUG //在有些 Revit 会遇到时不时无法转换的问题,循环多次重试, 应该可以成功 for (var i = 0; i < 5; i++) { try { StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken); hasSuccess = true; break; } catch (Autodesk.Revit.Exceptions.ExternalApplicationException) { Application.DoEvents(); } catch (IOException ex) { ShowMessageBox("文件保存失败: " + ex.Message); hasSuccess = true; break; } } #endif //如果之前多次重试仍然没有成功, 这里再试一次,如果再失败就会给出稍后重试的提示 if (hasSuccess == false) { StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken); } isCanncelled = cancellationToken.IsCancellationRequested; } sw.Stop(); var ts = sw.Elapsed; ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分 Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration); if (isCanncelled == false) { { ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration)); } } } catch (IOException ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message)); } catch (Autodesk.Revit.Exceptions.ExternalApplicationException) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(Strings.MessageOperationFailureAndTryLater); } catch (Exception ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(ex.ToString()); } } return(isCanncelled == false); }
bool IExportControl.Run() { var siteInfo = GetSiteInfo(); if (siteInfo == null) { ShowMessageBox(Strings.SiteLocationInvalid); return(false); } var filePath = txtTargetPath.Text; if (string.IsNullOrEmpty(filePath)) { ShowMessageBox(Strings.MessageSelectOutputPathFirst); return(false); } #if !R2014 if (CustomExporter.IsRenderingSupported() == false && ShowConfirmBox(Strings.ExportWillFailBecauseMaterialLib) == false) { return(false); } #endif if (File.Exists(filePath) && ShowConfirmBox(Strings.OutputFileExistedWarning) == false) { return(false); } var homePath = InnerApp.GetHomePath(); if (InnerApp.CheckHomeFolder(homePath) == false && ShowConfirmBox(Strings.HomeFolderIsInvalid) == false) { return(false); } var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo; if (visualStyle != null) { foreach (var p in visualStyle.Features) { _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value); } } var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault; #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } //SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked); SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked); //SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked); SetFeature(FeatureType.EnableQuantizedAttributes, cbEnableQuantizedAttributes.Checked); SetFeature(FeatureType.EnableTextureWebP, cbEnableTextureWebP.Checked); SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked); SetFeature(FeatureType.EnableUnlitMaterials, cbEnableUnlitMaterials.Checked); SetFeature(FeatureType.EnableEmbedGeoreferencing, cbEmbedGeoreferencing.Checked); #endregion var isCancelled = false; using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, ParentForm); return(false); } #region 保存设置 var config = _LocalConfig; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = txtTargetPath.Text; config.VisualStyle = visualStyle?.Key; config.LevelOfDetail = levelOfDetail?.Value ?? -1; if (rbModeShellMesh.Checked) { config.Mode = 2; } else if (rbModeShellElement.Checked) { config.Mode = 3; } else { config.Mode = 0; } _Config.Save(); #endregion var sw = Stopwatch.StartNew(); try { var setting = new ExportSetting(); setting.LevelOfDetail = config.LevelOfDetail; setting.OutputPath = config.LastTargetPath; setting.Mode = config.Mode; setting.Features = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList(); setting.SelectedElementIds = _ElementIds?.Where(x => x.Value).Select(x => x.Key).ToList(); setting.Site = siteInfo; setting.Oem = LicenseConfig.GetOemInfo(homePath); setting.PreExportSeedFeatures = InnerApp.GetPreExportSeedFeatures(@"3DTiles"); var hasSuccess = false; using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); #if !DEBUG //在有些 Revit 会遇到时不时无法转换的问题,循环多次重试, 应该可以成功 for (var i = 0; i < 5; i++) { try { StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken); hasSuccess = true; break; } catch (Autodesk.Revit.Exceptions.ExternalApplicationException) { Application.DoEvents(); } catch (IOException ex) { ShowMessageBox("文件保存失败: " + ex.Message); hasSuccess = true; break; } } #endif //如果之前多次重试仍然没有成功, 这里再试一次,如果再失败就会给出稍后重试的提示 if (hasSuccess == false) { StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken); } isCancelled = cancellationToken.IsCancellationRequested; } sw.Stop(); var ts = sw.Elapsed; ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分 Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration); if (isCancelled == false) { ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration)); } } catch (IOException ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message)); } catch (Autodesk.Revit.Exceptions.ExternalApplicationException) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(Strings.MessageOperationFailureAndTryLater); } catch (Exception ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(ex.ToString()); } } return(isCancelled == false); }
bool IExportControl.Run() { var filePath = txtTargetPath.Text; if (string.IsNullOrEmpty(filePath)) { ShowMessageBox(Strings.MessageSelectOutputPathFirst); return(false); } if (Autodesk.Navisworks.Api.Application.ActiveDocument.Models.Count == 0) { ShowMessageBox(Strings.SceneIsEmpty); return(false); } if (File.Exists(filePath) && ShowConfigBox(Strings.OutputFileExistedWarning) == false) { return(false); } var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo; if (visualStyle != null) { foreach (var p in visualStyle.Features) { _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value); } } // var autoOpenAppItem = cbAppList.SelectedItem as IconComboBoxItem; #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } //SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked); SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked); SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked); #endregion var isCancelled = false; using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, ParentForm); return(false); } #region 保存设置 var config = _LocalConfig; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = txtTargetPath.Text; config.VisualStyle = visualStyle?.Key; _Config.Save(); #endregion var sw = Stopwatch.StartNew(); try { var setting = new ExportSetting(); setting.OutputPath = config.LastTargetPath; setting.Features = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList(); setting.Site = SiteInfo.CreateDefault(); setting.Oem = LicenseConfig.GetOemInfo(App.GetHomePath()); using (var progress = new ProgressExHelper(ParentForm, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); StartExport(setting, progress.GetProgressCallback(), cancellationToken); isCancelled = cancellationToken.IsCancellationRequested; } sw.Stop(); var ts = sw.Elapsed; ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分 Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration); if (isCancelled == false) { if (config.AutoOpenAllow && config.AutoOpenAppName != null) { Process.Start(config.AutoOpenAppName, config.LastTargetPath); } else { ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration)); } } } catch (IOException ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message)); } catch (Exception ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(ex.ToString()); } } return(isCancelled == false); }
private void tsmiLicense_Click(object sender, EventArgs e) { LicenseConfig.ShowDialog(this); }
bool IExportControl.Run() { var filePath = txtTargetPath.Text; if (string.IsNullOrEmpty(filePath)) { ShowMessageBox(Strings.MessageSelectOutputPathFirst); return(false); } if (File.Exists(filePath) && ShowConfirmBox(Strings.OutputFileExistedWarning) == false) { return(false); } var homePath = InnerApp.GetHomePath(); if (InnerApp.CheckHomeFolder(homePath) == false && ShowConfirmBox(Strings.HomeFolderIsInvalid) == false) { return(false); } var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo; if (visualStyle != null) { foreach (var p in visualStyle.Features) { _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value); } } var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault; #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked); //SetFeature(FeatureType.GenerateElementData, cbGeneratePropDbJson.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.RegroupForLink, cbRegroupForLink.Checked); SetFeature(FeatureType.ExcludeProperties, cbExcludeElementProperties.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked && _HasSelectElements); #endregion var isCanncelled = false; using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, ParentForm); return(false); } #region 保存设置 var config = _LocalConfig; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = txtTargetPath.Text; config.AutoOpenAppName = string.Empty; config.VisualStyle = visualStyle?.Key; config.LevelOfDetail = levelOfDetail?.Value ?? -1; _Config.Save(); #endregion var sw = Stopwatch.StartNew(); try { var setting = new ExportSetting(); setting.LevelOfDetail = config.LevelOfDetail; setting.ExportType = ExportType.Zip; setting.OutputPath = config.LastTargetPath; setting.Features = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList(); //setting.Selected2DViewIds = rb2DViewCustom.Checked ? _ViewIds : null; setting.Oem = LicenseConfig.GetOemInfo(InnerApp.GetHomePath()); using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); try { StartExport(_View, setting, progress.GetProgressCallback(), cancellationToken); } catch (IOException ex) { ShowMessageBox("文件保存失败: " + ex.ToString()); } isCanncelled = cancellationToken.IsCancellationRequested; } sw.Stop(); var ts = sw.Elapsed; ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分 Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration); if (isCanncelled == false) { ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration)); } } catch (IOException ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.ToString())); } //catch (Autodesk.Revit.Exceptions.ExternalApplicationException) //{ // sw.Stop(); // Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); // ShowMessageBox(Strings.MessageOperationFailureAndTryLater); //} catch (Exception ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(ex.ToString()); } } return(isCanncelled == false); }
bool IExportControl.Run() { var siteInfo = GetSiteInfo(); if (siteInfo == null) { ShowMessageBox(Strings.SiteLocationInvalid); return(false); } var filePath = txtTargetPath.Text; if (string.IsNullOrEmpty(filePath)) { ShowMessageBox(Strings.MessageSelectOutputPathFirst); return(false); } if (File.Exists(filePath) && ShowConfirmBox(Strings.OutputFileExistedWarning) == false) { return(false); } var homePath = InnerApp.GetHomePath(); if (InnerApp.CheckHomeFolder(homePath) == false && ShowConfirmBox(Strings.HomeFolderIsInvalid) == false) { return(false); } var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo; if (visualStyle != null) { foreach (var p in visualStyle.Features) { _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value); } } var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault; #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } //SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked && _HasSelectElements); SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked); //SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked); SetFeature(FeatureType.EnableQuantizedAttributes, cbEnableQuantizedAttributes.Checked); SetFeature(FeatureType.EnableTextureWebP, cbEnableTextureWebP.Checked); SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked); SetFeature(FeatureType.EnableCesiumPrimitiveOutline, cbGenerateOutline.Checked); SetFeature(FeatureType.EnableUnlitMaterials, cbEnableUnlitMaterials.Checked); SetFeature(FeatureType.AutoAlignOriginToSiteCenter, cbAlignOriginToSiteCenter.Checked); SetFeature(FeatureType.EnableEmbedGeoreferencing, !rbGeoreferencingNone.Checked); #endregion var isCancelled = false; using (var session = LicenseConfig.Create()) { if (session.IsValid == false) { LicenseConfig.ShowDialog(session, ParentForm); return(false); } #region 保存设置 var config = _LocalConfig; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = txtTargetPath.Text; config.AutoOpenAppName = string.Empty; config.VisualStyle = visualStyle?.Key; config.LevelOfDetail = levelOfDetail?.Value ?? -1; config.GeoreferencingData = 1; config.GeoreferencingDetails = siteInfo.Clone(); if (rbGeoreferencingNone.Checked) { config.GeoreferencingData = 0; } else if (rbGeoreferencingCustom.Checked) { config.GeoreferencingData = 1; } if (rbModeShellMesh.Checked) { config.Mode = 2; } else if (rbModeShellElement.Checked) { config.Mode = 3; } else { config.Mode = 0; } _Config.Save(); #endregion var sw = Stopwatch.StartNew(); try { var setting = new ExportSetting(); setting.LevelOfDetail = config.LevelOfDetail; setting.OutputPath = config.LastTargetPath; setting.Mode = config.Mode; setting.Features = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList(); setting.Site = siteInfo; setting.Oem = LicenseConfig.GetOemInfo(InnerApp.GetHomePath()); setting.PreExportSeedFeatures = InnerApp.GetPreExportSeedFeatures(@"3DTiles"); using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); try { StartExport(_View, setting, progress.GetProgressCallback(), cancellationToken); } catch (IOException ex) { ShowMessageBox("文件保存失败: " + ex.ToString()); } isCancelled = cancellationToken.IsCancellationRequested; } sw.Stop(); var ts = sw.Elapsed; ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分 Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration); if (isCancelled == false) { ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration)); } } catch (IOException ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message)); } //catch (Autodesk.Dgn.Exceptions.ExternalApplicationException) //{ // sw.Stop(); // Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); // ShowMessageBox(Strings.MessageOperationFailureAndTryLater); //} catch (Exception ex) { sw.Stop(); Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed); ShowMessageBox(ex.ToString()); } } return(isCancelled == false); }