Moved GetBomTables to SolidWorksExtensions
This commit is contained in:
@@ -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>();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user