Moved GetBomTables to SolidWorksExtensions

This commit is contained in:
AJ
2019-11-24 19:58:35 -05:00
parent b207d4c319
commit 0762049b8e
2 changed files with 13 additions and 13 deletions

View File

@@ -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<Item>();
@@ -677,16 +676,6 @@ namespace ExportDXF.Forms
1) as DrawingDoc;
}
private List<BomTableAnnotation> 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<BomTableAnnotation>().FirstOrDefault())
.ToList();
}
private List<Item> GetItems(BomTableAnnotation bom)
{
var items = new List<Item>();

View File

@@ -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<BomTableAnnotation> 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<BomTableAnnotation>().FirstOrDefault())
.ToList();
}
}
}