diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index 6b1c19e..b7deaf8 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -300,9 +300,10 @@ namespace ExportDXF.Forms { item.Thickness = sheetMetalData.Thickness.FromSldWorks(); item.KFactor = sheetMetalData.KFactor; - } + item.BendRadius = sheetMetalData.BendRadius.FromSldWorks(); + } - if (item.Description == null) + if (item.Description == null) item.Description = model.Extension.CustomPropertyManager[config].Get("Description"); if (item.Description == null) @@ -312,7 +313,7 @@ namespace ExportDXF.Forms item.Material = part.GetMaterialPropertyName2(config, out db); - if (part == null) + if (part == null) continue; SavePartToDXF(part, config, savepath); @@ -426,8 +427,13 @@ namespace ExportDXF.Forms if (item.KFactor > 0) partsSheet.Cells[row, 7].Value = item.KFactor; + + if (item.BendRadius > 0) + partsSheet.Cells[row, 8].Value = item.BendRadius; } + partsSheet.Column(1).AutoFit(); + workbook.Calculate(); pkg.Save(); } diff --git a/ExportDXF/Helper.cs b/ExportDXF/Helper.cs index b570b73..c00bee2 100644 --- a/ExportDXF/Helper.cs +++ b/ExportDXF/Helper.cs @@ -2,7 +2,9 @@ using SolidWorks.Interop.swconst; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; +using System.Linq; using System.Text; using System.Windows.Forms; @@ -32,7 +34,9 @@ namespace ExportDXF while (feature != null) { - if (feature.GetTypeName() == featureName) + var name = feature.GetTypeName(); + + if (name == featureName) list.Add(feature); feature = feature.GetNextFeature() as Feature; @@ -41,7 +45,24 @@ namespace ExportDXF return list; } - public static bool HasFlatPattern(this ModelDoc2 model) + public static List GetAllSubFeaturesByTypeName(this Feature feature, string subFeatureName) + { + var subFeature = feature.GetFirstSubFeature() as Feature; + var list = new List(); + + while (subFeature != null) + { + Debug.WriteLine(subFeature.GetTypeName2()); + if (subFeature.GetTypeName() == subFeatureName) + list.Add(subFeature); + + subFeature = subFeature.GetNextSubFeature() as Feature; + } + + return list; + } + + public static bool HasFlatPattern(this ModelDoc2 model) { return model.GetBendState() != (int)swSMBendState_e.swSMBendStateNone; } @@ -161,6 +182,33 @@ namespace ExportDXF { return feature?.Parameter(dimName) as Dimension; } + + public static string PunctuateList(this IEnumerable stringList) + { + var list = stringList.ToList(); + + switch (list.Count) + { + case 0: + return string.Empty; + + case 1: + return list[0]; + + case 2: + return string.Format("{0} and {1}", list[0], list[1]); + + default: + var s = string.Empty; + + for (int i = 0; i < list.Count - 1; i++) + s += list[i] + ", "; + + s += "and " + list.Last(); + + return s; + } + } } public static class Units diff --git a/ExportDXF/Item.cs b/ExportDXF/Item.cs index 590e31a..df9ab21 100644 --- a/ExportDXF/Item.cs +++ b/ExportDXF/Item.cs @@ -16,6 +16,8 @@ namespace ExportDXF public double KFactor { get; set; } + public double BendRadius { get; set; } + public string Material { get; set; } public Component2 Component { get; set; } diff --git a/ExportDXF/Templates/BomTemplate.xlsx b/ExportDXF/Templates/BomTemplate.xlsx index df54f75..c37ad5c 100644 Binary files a/ExportDXF/Templates/BomTemplate.xlsx and b/ExportDXF/Templates/BomTemplate.xlsx differ