Moved GetBomTables to SolidWorksExtensions
This commit is contained in:
@@ -241,7 +241,7 @@ namespace ExportDXF.Forms
|
|||||||
private void ExportToDXF(DrawingDoc drawing)
|
private void ExportToDXF(DrawingDoc drawing)
|
||||||
{
|
{
|
||||||
Print("Finding BOM tables...");
|
Print("Finding BOM tables...");
|
||||||
var bomTables = GetBomTables(drawing);
|
var bomTables = drawing.GetBomTables();
|
||||||
|
|
||||||
if (bomTables.Count == 0)
|
if (bomTables.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -249,8 +249,7 @@ namespace ExportDXF.Forms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Print($"Found {bomTables.Count} BOM table(s)");
|
Print($"Found {bomTables.Count} BOM table(s)\n");
|
||||||
Print("");
|
|
||||||
|
|
||||||
var items = new List<Item>();
|
var items = new List<Item>();
|
||||||
|
|
||||||
@@ -677,16 +676,6 @@ namespace ExportDXF.Forms
|
|||||||
1) as DrawingDoc;
|
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)
|
private List<Item> GetItems(BomTableAnnotation bom)
|
||||||
{
|
{
|
||||||
var items = new List<Item>();
|
var items = new List<Item>();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using SolidWorks.Interop.swconst;
|
using SolidWorks.Interop.swconst;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ExportDXF
|
namespace ExportDXF
|
||||||
{
|
{
|
||||||
@@ -127,5 +128,15 @@ namespace ExportDXF
|
|||||||
return feature?.Parameter(dimName) as Dimension;
|
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