From 43a38b60f3a3aa25b90ad5d36f614f8ef8d09e83 Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 17 Nov 2018 08:56:55 -0500 Subject: [PATCH] Hide all model sketches before saving to dxf. --- ExportDXF/Forms/MainForm.Designer.cs | 4 +-- ExportDXF/Forms/MainForm.cs | 44 +++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ExportDXF/Forms/MainForm.Designer.cs b/ExportDXF/Forms/MainForm.Designer.cs index 8511f30..51f3896 100644 --- a/ExportDXF/Forms/MainForm.Designer.cs +++ b/ExportDXF/Forms/MainForm.Designer.cs @@ -122,8 +122,7 @@ // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(618, 391); this.Controls.Add(this.comboBox1); this.Controls.Add(this.label3); @@ -137,6 +136,7 @@ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MaximizeBox = false; this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "ExportDXF"; this.ResumeLayout(false); this.PerformLayout(); diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index 5e0a316..7dd27b0 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -319,7 +319,10 @@ namespace ExportDXF.Forms foreach (var item in items) { if (worker.CancellationPending) - break; + { + Print("Canceled by user.\n", Color.Red); + return; + } var fileName = GetFileName(item); var savepath = Path.Combine(savePath, fileName + ".dxf"); @@ -434,6 +437,17 @@ namespace ExportDXF.Forms var drawingModel = templateDrawing as ModelDoc2; drawingModel.ViewZoomtofit2(); + + if (HideModelSketches(view)) + { + // delete the current view that has sketches shown + drawingModel.SelectByName(0, view.Name); + drawingModel.DeleteSelection(false); + + // recreate the flat pattern view + view = templateDrawing.CreateFlatPatternViewFromModelView3(partModel.GetPathName(), partConfiguration, 0, 0, 0, false, false); + view.ShowSheetMetalBendNotes = true; + } if (ShouldFlipView(view)) { @@ -458,6 +472,34 @@ namespace ExportDXF.Forms } } + private bool HideModelSketches(IView view) + { + var model = view.ReferencedDocument; + var activeConfig = ((Configuration)model.GetActiveConfiguration()).Name; + + var modelChanged = false; + var refConfig = view.ReferencedConfiguration; + model.ShowConfiguration(refConfig); + + var sketches = model.GetAllFeaturesByTypeName("ProfileFeature"); + + foreach (var sketch in sketches) + { + var visible = (swVisibilityState_e)sketch.Visible; + + if (visible == swVisibilityState_e.swVisibilityStateShown) + { + sketch.Select2(true, -1); + model.BlankSketch(); + modelChanged = true; + } + } + + model.ShowConfiguration(activeConfig); + + return modelChanged; + } + private void CreateBOMExcelFile(string filepath, IList items) { var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "BomTemplate.xlsx");