diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index 36e771a..cb42dca 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -241,7 +241,7 @@ namespace ExportDXF.Forms private void ExportToDXF(DrawingDoc drawing) { Print("Finding BOM tables..."); - var bomTables = GetBomTables(drawing); + var bomTables = drawing.GetBomTables(); if (bomTables.Count == 0) { @@ -249,8 +249,7 @@ namespace ExportDXF.Forms return; } - Print($"Found {bomTables.Count} BOM table(s)"); - Print(""); + Print($"Found {bomTables.Count} BOM table(s)\n"); var items = new List(); @@ -677,16 +676,6 @@ namespace ExportDXF.Forms 1) as DrawingDoc; } - private List GetBomTables(DrawingDoc drawing) - { - var model = drawing as ModelDoc2; - - return model.GetAllFeaturesByTypeName("BomFeat") - .Select(f => f.GetSpecificFeature2() as BomFeature) - .Select(f => (f.GetTableAnnotations() as Array)?.Cast().FirstOrDefault()) - .ToList(); - } - private List GetItems(BomTableAnnotation bom) { var items = new List(); diff --git a/ExportDXF/SolidWorksExtensions.cs b/ExportDXF/SolidWorksExtensions.cs index 8c9cc41..89e3b09 100644 --- a/ExportDXF/SolidWorksExtensions.cs +++ b/ExportDXF/SolidWorksExtensions.cs @@ -2,6 +2,7 @@ using SolidWorks.Interop.swconst; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; namespace ExportDXF { @@ -127,5 +128,15 @@ namespace ExportDXF return feature?.Parameter(dimName) as Dimension; } + public static List GetBomTables(this DrawingDoc drawing) + { + var model = drawing as ModelDoc2; + + return model.GetAllFeaturesByTypeName("BomFeat") + .Select(f => f.GetSpecificFeature2() as BomFeature) + .Select(f => (f.GetTableAnnotations() as Array)?.Cast().FirstOrDefault()) + .ToList(); + } + } } \ No newline at end of file