Hide all model sketches before saving to dxf.

This commit is contained in:
AJ
2018-11-17 08:56:55 -05:00
parent b1d7540924
commit 43a38b60f3
2 changed files with 45 additions and 3 deletions

View File

@@ -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();

View File

@@ -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<Item> items)
{
var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", "BomTemplate.xlsx");