From 9aafcde051759518c1038918e14598f6fd24534b Mon Sep 17 00:00:00 2001 From: AJ Date: Mon, 23 Apr 2018 14:51:21 -0400 Subject: [PATCH] Changed method of getting sheet metal data. --- ExportDXF/ExportDXF.csproj | 2 +- ExportDXF/Forms/MainForm.cs | 31 ++++++++++++++++--------------- ExportDXF/Helper.cs | 4 ++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ExportDXF/ExportDXF.csproj b/ExportDXF/ExportDXF.csproj index 2cb49b4..cf38eb4 100644 --- a/ExportDXF/ExportDXF.csproj +++ b/ExportDXF/ExportDXF.csproj @@ -22,7 +22,7 @@ false false true - 9 + 11 1.0.0.%2a false true diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index 5a81b7b..77a5540 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -232,7 +232,7 @@ namespace ExportDXF.Forms if (dir == null) { - Print("Cancelled\n", Color.Red); + Print("Canceled\n", Color.Red); return; } @@ -289,18 +289,12 @@ namespace ExportDXF.Forms var config = item.Component.ReferencedConfiguration; var sheetMetal = model.GetFeatureByTypeName("SheetMetal"); + var sheetMetalData = sheetMetal?.GetDefinition() as SheetMetalFeatureData; - if (sheetMetal != null) + if (sheetMetalData != null) { - var kfactor = sheetMetal.GetDimension("D2")?.GetValue2(config); - - if (kfactor.HasValue) - item.KFactor = kfactor.Value; - - var thickness = sheetMetal.GetDimension("Thickness")?.GetValue2(config); - - if (thickness.HasValue) - item.Thickness = thickness.Value; + item.Thickness = sheetMetalData.Thickness.FromSldWorks(); + item.KFactor = sheetMetalData.KFactor; } var db = string.Empty; @@ -314,8 +308,15 @@ namespace ExportDXF.Forms Application.DoEvents(); } - var bomFile = Path.Combine(savePath, "BOM.xlsx"); - CreateBOMExcelFile(bomFile, items.ToList()); + try + { + var bomFile = Path.Combine(savePath, "BOM.xlsx"); + CreateBOMExcelFile(bomFile, items.ToList()); + } + catch (Exception ex) + { + Print(ex.Message, Color.Red); + } } private string ChangePathExtension(string fullpath, string newExtension) @@ -503,8 +504,8 @@ namespace ExportDXF.Forms for (int rowIndex = 0; rowIndex < table.RowCount; rowIndex++) { - if (table.RowHidden[rowIndex] == true) - continue; + //if (table.RowHidden[rowIndex] == true) + // continue; var bomComponents = isBOMPartsOnly ? ((Array)bom.GetComponents2(rowIndex, bom.BomFeature.Configuration))?.Cast() : diff --git a/ExportDXF/Helper.cs b/ExportDXF/Helper.cs index 492d597..b570b73 100644 --- a/ExportDXF/Helper.cs +++ b/ExportDXF/Helper.cs @@ -172,12 +172,12 @@ namespace ExportDXF public static double ToSldWorks(this double d) { - return d * ScaleFactor; + return Math.Round(d * ScaleFactor, 8); } public static double FromSldWorks(this double d) { - return d / ScaleFactor; + return Math.Round(d / ScaleFactor, 8); } } }