Solidworks学习笔记-链接Solidworks
Name | Description | 备注 |
Configuration | Gets or sets the name of configuration for this BOM table. | 获取或设置此 BOM 表的配置名称。 |
DetailedCutList | Gets or sets whether to show the detailed cut list in this BOM table. | 获取或设置是否在此 BOM 表中显示详细的切割清单。 |
DisplayAsOneItem | Gets or sets whether all of the configurations appear with the same item number if the BOM table contains components that have multiple configurations. | 获取或设置如果 BOM 表包含具有多个配置的组件,是否所有配置都显示为相同的项目编号。 |
FollowAssemblyOrder2 | Gets or sets whether the order of the item numbers in the BOM follows the order in which the assembly appears in the FeatureManager design tree. | 获取或设置 BOM 中项目编号的顺序是否遵循装配体在 FeatureManager 设计树中出现的顺序。 |
KeepCurrentItemNumbers | Gets or sets whether item numbers are kept with their components when reordering rows of a BOM table. | 获取或设置在对 BOM 表的行重新排序时是否将项目编号与其组件一起保留。 |
KeepMissingItems | Gets and sets the Keep Missing Items option for this BOM feature. | 获取和设置此 BOM 功能的保留缺失项选项。 |
KeepReplacedCompOption | Gets or sets how to replace components when keeping missing items. | 获取或设置在保留缺失项时如何替换组件。 |
Name | Gets the name of this BOM table feature. | 获取此 BOM 表特征的名称。 |
NumberingTypeOnIndentedBOM | Gets and sets the type of numbering for this indented BOM table. | 获取和设置此缩进 BOM 表的编号类型。 |
PartConfigurationGrouping | Gets and sets the part configuration grouping for this BOM table. | 获取和设置此 BOM 表的零件配置分组。 |
RoutingComponentGrouping | Gets or sets the routing component grouping options for this BOM table in a drawing of an assembly containing routing components. | 获取或设置包含步路零部件的装配体工程图中此 BOM 表的步路零部件分组选项。 |
SequenceStartNumber | Gets or sets the number with which to start the numbering for this BOM table. | 获取或设置用于开始此 BOM 表编号的编号。 |
StrikeoutMissingItems | Inserts a horizontal line through missing items in this BOM table (also called strike outs). | 在此 BOM 表中的缺失项目(也称为删除线)之间插入一条水平线。 |
TableType | Gets and sets the type of table for the Bill of Materials. | 获取和设置材料明细表的表格类型。 |
ZeroQuantityDisplay | Gets or sets the character or value to display when a value is 0 in this BOM table. | 获取或设置当此 BOM 表中的值为 0 时要显示的字符或值。 |
This example shows how to export a BOM's second column to a BOM Table Area of a SOLIDWORKS MBD 3D PDF.//----------------------------------------------------------------------------
// Preconditions:
// 1. Verify that:
// * specified assembly,
// * specified SOLIDWORKS MBD 3D PDF theme, and
// * c:\temp exist.
// 2. Open an Immediate window.
//
// Postconditions:
// 1. Inserts an indented BOM table in the assembly.
// 2. Gets the title of the second column in the BOM table
// to export that column to the SOLIDWORKS MBD 3D PDF.
// 3. Gets the name of the BOM to map to the SOLIDWORKS
// MBD 3D PDF.
// 4. Gets the SOLIDWORKS MBD 3D PDF data object.
// a. Sets to display the SOLIDWORKS MBD 3D PDF after
// publishing it.
// b. Sets the path for the SOLIDWORKS MBD 3D PDF.
// c. Sets the SOLIDWORKS MBD 3D PDF theme.
// d. Sets the standard views for the SOLIDWORKS MBD 3D PDF.
// e. Maps the BOM and exports its second column to a BOM
// Table Area in the SOLIDWORKS MBD 3D PDF.
// f. Publishes and displays the SOLIDWORKS MBD 3D PDF.
// 5. Examine c:\temp\MBDAssembly1.PDF and the Immediate window.
//
// NOTE: Because the assembly is used elsewhere, do not save changes.
//---------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace Macro1CSharp.csproj
{public partial class SolidWorksMacro{ public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);BomTableAnnotation swBOMAnnotation = default(BomTableAnnotation);TableAnnotation swTableAnnotation = default(TableAnnotation);BomFeature swBOMFeature = default(BomFeature);MBD3DPdfData swMBDPdfData = default(MBD3DPdfData);string fileName = null;int errors = 0;int warnings = 0;int bomType = 0;string tableTemplate = null;string[] columnNames = new string[1];object columns = null;string BOMTableName = null;object standardViews = null;int[] viewIDs = new int[3];int nbrBOMTableAreas = 0;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\bladed shaft.sldasm";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = (ModelDocExtension)swModel.Extension;// Insert indented BOM table in assemblybomType = (int)swBomType_e.swBomType_Indented;tableTemplate = "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\lang\\english\\bom-standard.sldbomtbt";swBOMAnnotation = (BomTableAnnotation)swModelDocExt.InsertBomTable3(tableTemplate, 0, 1, bomType, "Default", false, (int)swNumberingType_e.swNumberingType_Detailed, true);// Get title of second column in BOM table to export to SOLIDWORKS MBD 3D PDFswTableAnnotation = (TableAnnotation)swBOMAnnotation;columnNames[0] = swTableAnnotation.GetColumnTitle(1);Debug.Print("Title of second column to export to SOLIDWORKS MBD 3D PDF: " + columnNames[0]);columns = (object)columnNames;// Get name of BOM to map to SOLIDWORKS MBD 3D PDFswBOMFeature = (BomFeature)swBOMAnnotation.BomFeature;BOMTableName = swBOMFeature.Name;Debug.Print("Name of BOM to map to SOLIDWORKS MBD 3D PDF: " + BOMTableName);// Get MBD3PdfData objectswMBDPdfData = (MBD3DPdfData)swModelDocExt.GetMBD3DPdfData();// Set to display SOLIDWORKS MBD 3D PDF swMBDPdfData.ViewPdfAfterSaving = true;// Set path for SOLIDWORKS MBD 3D PDFswMBDPdfData.FilePath = "c:\\temp\\MBDAssembly1.PDF";// Set SOLIDWORKS MBD 3D PDF themeswMBDPdfData.ThemeName = "c:\\program files\\solidworks corp\\solidworks\\data\\themes\\simple assembly (a4, landscape)\\theme.xml";// Set standard views for SOLIDWORKS MBD 3D PDFviewIDs[0] = (int)swStandardViews_e.swFrontView;viewIDs[1] = (int)swStandardViews_e.swTopView;viewIDs[2] = (int)swStandardViews_e.swDimetricView;standardViews = (object)viewIDs;swMBDPdfData.SetStandardViews(standardViews);// Map BOM and export its second column to BOM Table Area nbrBOMTableAreas = swMBDPdfData.GetBomAreaCount();if (nbrBOMTableAreas > 0){swMBDPdfData.SetBomTable(0, BOMTableName, columns);}// Publish SOLIDWORKS MBD 3D PDFswModelDocExt.PublishTo3DPDF(swMBDPdfData);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
This example shows how to get and set the routing component grouping options for this BOM table in a drawing of an assembly containing routing components.//----------------------------------------------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\api\AutoRouteThroughSketchEntities.sldddrw.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Selects the Bill of Materials1 feature.
// 2. Examine the Immediate window.
//
// NOTE: Because the drawing is used elsewhere, do not save changes.
//---------------------------------------------------------------------------------using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;namespace Macro1CSharp.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);SelectionMgr swSelMgr = default(SelectionMgr);BomFeature swBomFeature = default(BomFeature);bool status = false;int options = 0;swModel = (ModelDoc2)swApp.ActiveDoc;swModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("Bill of Materials1", "BOMFEATURE", 0, 0, 0, false, 0, null, 0);swSelMgr = (SelectionMgr)swModel.SelectionManager;swBomFeature = (BomFeature)swSelMgr.GetSelectedObject6(1, -1);Debug.Print("Name of configuration used for BOM table: " + swBomFeature.Configuration);//Get current routing component grouping optionsDebug.Print("Current routing component grouping options: " + swBomFeature.RoutingComponentGrouping);//Set new routing component grouping optionsoptions = (int)swRoutingComponentGroupingOption_e.swShowOnlyRoutingComponentsInBOM + (int)swRoutingComponentGroupingOption_e.swDisplayUnitsInBOM;swBomFeature.RoutingComponentGrouping = options;Debug.Print("Modified routing component grouping options: " + swBomFeature.RoutingComponentGrouping);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
Name | Description | 备注 |
GetConfigurationCount | Gets the number of configurations available to this BOM table or used in this BOM table. | 获取可用于此 BOM 表或在此 BOM 表中使用的配置数。 |
GetConfigurations | Gets the configurations available to this BOM table or used in this BOM table. | 获取可用于此 BOM 表或在此 BOM 表中使用的配置。 |
GetFeature | Gets the BOM table feature. | 获取 BOM 表功能。 |
GetReferencedModelName | Gets the name of the model referenced by this BOM feature. | 获取此 BOM 特征引用的模型的名称。 |
GetTableAnnotationCount | Gets the number of BOM table annotations for this BOM table feature. | 获取此 BOM 表功能的 BOM 表注释数量。 |
GetTableAnnotations | Gets the BOM table annotations for this BOM table feature. | 获取此 BOM 表特征的 BOM 表注释。 |
IGetConfigurations | Gets the configurations available to this BOM table or used in this BOM table. | 获取可用于此 BOM 表或在此 BOM 表中使用的配置。 |
IGetTableAnnotations | Gets the BOM table annotations for this BOM table feature. | 获取此 BOM 表特征的 BOM 表注释。 |
ISetConfigurations | Sets the configurations used in this BOM table. | 设置此 BOM 表中使用的配置。 |
SetConfigurations | Sets the configurations used in this BOM table. | 设置此 BOM 表中使用的配置。 |
SOLIDWORKS manages Bills of Materials (BOM) and controls the information within them. You can extract this information for use in downstream systems such as ERP or other business systems.In SOLIDWORKS 2004 and later, BOMs are now features and appear during a traversal of the FeatureManager design tree. This example shows how to get to each BOM in a drawing document and save the BOM information to an XML file. You can transform this XML file using XSL or transfer the file to other systems.//----------------------------------------------------------------------
// Preconditions:
// 1. Open a drawing document with at least on BOM.
// 2. Add a reference to Microsoft Scripting Runtime (right-click
// the name of the project in the Project Explorer and click Add Reference >
// the Browse tab > C:\windows\system32\scrrun.dll > OK.
//
// Postconditions:
// 1. Saves an XML file to the folder where the drawing document resides,
// overwriting any existing file of the same name.
// 2. Examine the folder where the drawing document resides.
//
// NOTES:
// * XML tags are based on BOM column headings.
// * Invalid characters must be removed from the
// column headings.
// * XML schema is:
// <BOMS>
// <SHEET>
// <NAME>Sheet1</NAME>
// <BOM>
// <NAME>Bill Of Materials1</NAME>
// <TABLE>
// <ROW>
// <ITEM_NO>1</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>2</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>2</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>3</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>4</ITEM_NO>
// <PART_NUMBER>bead7</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// </BOM>
// </SHEET>
// <SHEET>
// <NAME>Sheet2</NAME>
// <BOM>
// <NAME>Bill Of Materials2</NAME>
// <TABLE>
// <ROW>
// <ITEM_NO>1</ITEM_NO>
// <PART_NUMBER>Assem3</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO></ITEM_NO>
// <PART_NUMBER> cylinder</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO></ITEM_NO>
// <PART_NUMBER> cylinder</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO></ITEM_NO>
// <PART_NUMBER> SimpleCube_A</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO></ITEM_NO>
// <PART_NUMBER> JoinedCyl</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// </BOM>
// <BOM>
// <NAME>Bill Of Materials3</NAME>
// <TABLE>
// <ROW>
// <ITEM_NO>8</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>2</QTY>
// </ROW>
// </TABLE>
// <TABLE>
// <ROW>
// <ITEM_NO>9</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>10</ITEM_NO>
// <PART_NUMBER>2004_Part</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// <TABLE>
// <ROW>
// <ITEM_NO>11</ITEM_NO>
// <PART_NUMBER>bead7</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// </BOM>
// <BOM>
// <NAME>Bill Of Materials4</NAME>
// <TABLE>
// <TITLE>BOM Table 2</TITLE>
// <ROW>
// <ITEM_NO>1</ITEM_NO>
// <PART_NUMBER>cylinder</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>2</ITEM_NO>
// <PART_NUMBER>cylinder</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// <TABLE>
// <TITLE>BOM Table 2</TITLE>
// <ROW>
// <ITEM_NO>3</ITEM_NO>
// <PART_NUMBER>SimpleCube_A</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// <ROW>
// <ITEM_NO>4</ITEM_NO>
// <PART_NUMBER>JoinedCyl</PART_NUMBER>
// <DESCRIPTION></DESCRIPTION>
// <QTY>1</QTY>
// </ROW>
// </TABLE>
// </BOM>
// </SHEET>
// </BOMS>
//----------------------------------------------------------------------using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using Scripting;
using System.Diagnostics;namespace XMLCsharp.csproj
{public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDraw = default(DrawingDoc);Feature swFeat = default(Feature);BomFeature swBomFeat = default(BomFeature);string sPathName = null;bool bIsFirstSheet = false;Scripting.FileSystemObject fso = default(Scripting.FileSystemObject);Scripting.TextStream XMLfile = default(Scripting.TextStream);swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;bIsFirstSheet = true;// Strip off SOLIDWORKS file extension (slddrw)// and add XML extension (xml)sPathName = swModel.GetPathName();//sPathName = Strings.Left(sPathName, Strings.Len(sPathName) - 6);sPathName = sPathName.Substring(0, sPathName.Length - 6);sPathName = sPathName + "xml";//fso = Interaction.CreateObject("Scripting.FileSystemObject");fso = new Scripting.FileSystemObject();XMLfile = fso.CreateTextFile(sPathName, true, true);XMLfile.WriteLine("<BOMS>");swFeat = (Feature)swModel.FirstFeature();while ((swFeat != null)){if ("DrSheet" == swFeat.GetTypeName()){XMLfile.WriteLine(" <SHEET>");XMLfile.WriteLine(" <NAME>" + swFeat.Name + "</NAME>");bIsFirstSheet = false;}if ("BomFeat" == swFeat.GetTypeName()){swBomFeat = (BomFeature)swFeat.GetSpecificFeature2();ProcessBomFeature(swApp, swModel, swBomFeat, XMLfile);}swFeat = (Feature)swFeat.GetNextFeature();if ((swFeat != null)){if ("DrSheet" == swFeat.GetTypeName() & !bIsFirstSheet){XMLfile.WriteLine(" </SHEET>");}}}XMLfile.WriteLine(" </SHEET>");XMLfile.WriteLine("</BOMS>");XMLfile.Close();}public void ProcessTableAnn(SldWorks swApp, ModelDoc2 swModel, TableAnnotation swTableAnn, Scripting.TextStream XMLfile){int nNumRow = 0;int nNumCol = 0;int nNumHeader = 0;string[] sHeaderText = null;int j = 0;int k = 0;int nIndex = 0;int nCount = 0;int nStart = 0;int nEnd = 0;int nSplitDir = 0;nNumHeader = swTableAnn.GetHeaderCount();Debug.Assert(nNumHeader >= 1);nSplitDir = swTableAnn.GetSplitInformation(ref nIndex, ref nCount, ref nStart, ref nEnd);if ((int)swTableSplitDirection_e.swTableSplit_None == nSplitDir){Debug.Assert(0 == nIndex);Debug.Assert(0 == nCount);Debug.Assert(0 == nStart);Debug.Assert(0 == nEnd);nNumRow = swTableAnn.RowCount;nNumCol = swTableAnn.ColumnCount;nStart = nNumHeader;nEnd = nNumRow - 1;}else{Debug.Assert((int)swTableSplitDirection_e.swTableSplit_Horizontal == nSplitDir);Debug.Assert(nIndex >= 0);Debug.Assert(nCount >= 0);Debug.Assert(nStart >= 0);Debug.Assert(nEnd >= nStart);nNumCol = swTableAnn.ColumnCount;if (1 == nIndex){// Add header offset for first portion of tablenStart = nStart + nNumHeader;}}XMLfile.WriteLine(" <TABLE>");if (swTableAnn.TitleVisible){XMLfile.WriteLine(" <TITLE>" + swTableAnn.Title + "</TITLE>");}sHeaderText = new string[nNumCol];for (j = 0; j <= nNumCol - 1; j++){sHeaderText[j] = (string)swTableAnn.GetColumnTitle2(j, true);// Replace invalid characters for XML tagssHeaderText[j] = sHeaderText[j].Replace(".", "");sHeaderText[j] = sHeaderText[j].Replace(" ", "_");}for (j = nStart; j <= nEnd; j++){XMLfile.WriteLine(" <ROW>");for (k = 0; k <= nNumCol - 1; k++){XMLfile.WriteLine(" " + "<" + sHeaderText[k] + ">" + swTableAnn.get_Text2(j, k, true) + "</" + sHeaderText[k] + ">");}XMLfile.WriteLine(" </ROW>");}XMLfile.WriteLine(" </TABLE>");}public void ProcessBomFeature(SldWorks swApp, ModelDoc2 swModel, BomFeature swBomFeat, Scripting.TextStream XMLfile){Feature swFeat = default(Feature);object[] vTableArr = null;object vTable = null;TableAnnotation swTable = default(TableAnnotation);swFeat = (Feature)swBomFeat.GetFeature();XMLfile.WriteLine(" <BOM>");XMLfile.WriteLine(" <NAME>" + swFeat.Name + "</NAME>");vTableArr = (object[])swBomFeat.GetTableAnnotations();foreach (object vTable_loopVariable in vTableArr){vTable = vTable_loopVariable;swTable = (TableAnnotation)vTable;ProcessTableAnn(swApp, swModel, swTable, XMLfile);}XMLfile.WriteLine(" </BOM>");}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;}
}
This example shows how to get the components in each row of a BOM table annotation.//-----------------------------------------------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\assemblyvisualize\food_processor.sldasm.
// 2. Make a drawing from the assembly.
// 3. Click Insert > Tables > Bill of Materials.
// 4. Ensure that Parts only in Bom Type is selected.
// 5. Ensure that Display configurations of the same part separate items
// in Part Configuration Grouping is selected.
// 6. Click OK.
// 7. Click anywhere in the drawing to insert the BOM table.
//
// Postconditions:
// 1. Gets the Bill of Materials1 feature.
// 2. Gets the Default configuration.
// 3. Processes the BOM table for the Default configuration.
// 4. Examine the Immediate window.
//
// NOTE: Because the assembly is used elsewhere, do not save changes.
//-----------------------------------------------------------------------------
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
namespace Macro1CSharp.csproj
{partial class SolidWorksMacro{ public void ProcessTableAnn(SldWorks swApp, ModelDoc2 swModel, TableAnnotation swTableAnn, string ConfigName){int nNumRow = 0;int J = 0;int I = 0;string ItemNumber = null;string PartNumber = null;bool RowLocked;double RowHeight;Debug.Print(" Table Title: " + swTableAnn.Title);nNumRow = swTableAnn.RowCount;BomTableAnnotation swBOMTableAnn = default(BomTableAnnotation);swBOMTableAnn = (BomTableAnnotation)swTableAnn;for (J = 0; J <= nNumRow - 1; J++){RowLocked = swTableAnn.GetLockRowHeight(J);RowHeight = swTableAnn.GetRowHeight(J);Debug.Print(" Row Number " + J + " (height = " + RowHeight + "; height locked = " + RowLocked + ")");Debug.Print(" Component Count: " + swBOMTableAnn.GetComponentsCount2(J, ConfigName, out ItemNumber, out PartNumber));Debug.Print(" Item Number: " + ItemNumber);Debug.Print(" Part Number: " + PartNumber);object[] vPtArr = null;Component2 swComp = null;object pt = null;vPtArr = (object[])swBOMTableAnn.GetComponents2(J, ConfigName);if (((vPtArr != null))){for (I = 0; I <= vPtArr.GetUpperBound(0); I++){pt = vPtArr[I];swComp = (Component2)pt;if ((swComp != null)){Debug.Print(" Component Name: " + swComp.Name2);Debug.Print(" Configuration Name: " + swComp.ReferencedConfiguration);Debug.Print(" Component Path: " + swComp.GetPathName());}else{Debug.Print(" Could not get component.");}}}}}public void ProcessBomFeature(SldWorks swApp, ModelDoc2 swModel, BomFeature swBomFeat){Feature swFeat = default(Feature);object[] vTableArr = null;object vTable = null;string[] vConfigArray = null;object vConfig = null;string ConfigName = null;TableAnnotation swTable = default(TableAnnotation);object visibility = null;swFeat = swBomFeat.GetFeature();vTableArr = (object[])swBomFeat.GetTableAnnotations();foreach (TableAnnotation vTable_loopVariable in vTableArr){vTable = vTable_loopVariable;swTable = (TableAnnotation)vTable;vConfigArray = (string[])swBomFeat.GetConfigurations(true, ref visibility);foreach (object vConfig_loopVariable in vConfigArray){vConfig = vConfig_loopVariable;ConfigName = (string)vConfig;Debug.Print(" Component for Configuration: " + ConfigName);ProcessTableAnn(swApp, swModel, swTable, ConfigName);}}}public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDraw = default(DrawingDoc);Feature swFeat = default(Feature);BomFeature swBomFeat = default(BomFeature);swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;swFeat = (Feature)swModel.FirstFeature();while ((swFeat != null)){if ("BomFeat" == swFeat.GetTypeName()){Debug.Print("Feature Name: " + swFeat.Name);swBomFeat = (BomFeature)swFeat.GetSpecificFeature2();ProcessBomFeature(swApp, swModel, swBomFeat);}swFeat = (Feature)swFeat.GetNextFeature();}}public SldWorks swApp;}
}