public void Export() { if (!GeneralCommandArguments()) { return; } using (var session = App.CreateLicenseSession()) { if (session.IsValid == false) { new License().ShowDialog(this); return; } _Config.Save(); bool isCanncelled; using (var progress = new ProgressHelper(this, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); StartExport(_Config.Local, progress.GetProgressCallback(), cancellationToken); isCanncelled = cancellationToken.IsCancellationRequested; } if (isCanncelled == false) { UploadFile(); Enabled = false; } } }
public void Export() { #if !R2014 if (CustomExporter.IsRenderingSupported() == false) { var message = @"检测到当前 Revit 实例对数据导出的支持存在问题, 原因可能是材质库未正确安装。 本次操作可能无法成功执行, 确定要继续吗?"; if (MessageBox.Show(this, message, Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.OK) { return; } } #endif 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.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 = App.CreateSession(Application.licenseKey)) { if (session.IsValid == false) { new Plugin_manage().ShowDialog(); return; } #region 保存设置 var config = _Config.Local; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = Path.Combine(TempPath, modelName + ".svfzip"); config.VisualStyle = visualStyle?.Key; config.LevelOfDetail = levelOfDetail?.Value ?? -1; _Config.Save(); #endregion var features = _Features.Where(x => x.Selected && x.Enabled).ToDictionary(x => x.Type, x => true); using (var progress = new ProgressHelper(this, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); StartExport(_UIDocument, _View, config, ExportType.Zip, null, features, false, progress.GetProgressCallback(), cancellationToken); isCanncelled = cancellationToken.IsCancellationRequested; } if (isCanncelled == false) { var t = new Thread(UploadFile); t.IsBackground = false; t.Start(); Enabled = false; progressBar1.Value = 50; } } }
public void Export() { if (Autodesk.Navisworks.Api.Application.ActiveDocument.Models.Count == 0) { var message = @"未打开任何模型, 确定要继续吗?"; if (MessageBox.Show(this, message, Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.OK) { return; } return; } 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); } } #region 更新界面选项到 _Features void SetFeature(FeatureType featureType, bool selected) { _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected); } SetFeature(FeatureType.ExportHyperlink, cbHyperlink.Checked); SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked); SetFeature(FeatureType.GenerateElementData, cbGeneratePropDbJson.Checked); SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked); SetFeature(FeatureType.ExcludeProperties, cbExcludeElementProperties.Checked); SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked); SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked); SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked); #endregion var isCanncelled = false; using (var session = App.CreateSession()) { if (session.IsValid == false) { new License().ShowDialog(this); return; } var config = _Config.Local; config.Features = _Features.Where(x => x.Selected).Select(x => x.Type).ToList(); config.LastTargetPath = TempPath + ModelName + ".svfzip"; config.VisualStyle = visualStyle?.Key; _Config.Save(); var features = _Features.Where(x => x.Selected && x.Enabled).ToDictionary(x => x.Type, x => true); using (var progress = new ProgressHelper(this, Strings.MessageExporting)) { var cancellationToken = progress.GetCancellationToken(); StartExport(config, ExportType.Zip, null, features, false, progress.GetProgressCallback(), cancellationToken); isCanncelled = cancellationToken.IsCancellationRequested; } if (isCanncelled == false) { UploadFile(); Enabled = false; } } }