IBomFeature Interface

news/2024/11/28 23:50:14/

Solidworks学习笔记-链接Solidworks

NameDescription备注
ConfigurationGets or sets the name of configuration for this BOM table.  获取或设置此 BOM 表的配置名称。
DetailedCutListGets or sets whether to show the detailed cut list in this BOM table.  获取或设置是否在此 BOM 表中显示详细的切割清单。
DisplayAsOneItemGets or sets whether all of the configurations appear with the same item number if the BOM table contains components that have multiple configurations.  获取或设置如果 BOM 表包含具有多个配置的组件,是否所有配置都显示为相同的项目编号。
FollowAssemblyOrder2Gets 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 设计树中出现的顺序。
KeepCurrentItemNumbersGets or sets whether item numbers are kept with their components when reordering rows of a BOM table.  获取或设置在对 BOM 表的行重新排序时是否将项目编号与其组件一起保留。
KeepMissingItemsGets and sets the Keep Missing Items option for this BOM feature.  获取和设置此 BOM 功能的保留缺失项选项。
KeepReplacedCompOptionGets or sets how to replace components when keeping missing items.  获取或设置在保留缺失项时如何替换组件。
NameGets the name of this BOM table feature.  获取此 BOM 表特征的名称。
NumberingTypeOnIndentedBOMGets and sets the type of numbering for this indented BOM table.  获取和设置此缩进 BOM 表的编号类型。
PartConfigurationGroupingGets and sets the part configuration grouping for this BOM table.  获取和设置此 BOM 表的零件配置分组。
RoutingComponentGroupingGets or sets the routing component grouping options for this BOM table in a drawing of an assembly containing routing components.  获取或设置包含步路零部件的装配体工程图中此 BOM 表的步路零部件分组选项。
SequenceStartNumberGets or sets the number with which to start the numbering for this BOM table.  获取或设置用于开始此 BOM 表编号的编号。
StrikeoutMissingItemsInserts a horizontal line through missing items in this BOM table (also called strike outs).  在此 BOM 表中的缺失项目(也称为删除线)之间插入一条水平线。
TableTypeGets and sets the type of table for the Bill of Materials.  获取和设置材料明细表的表格类型。
ZeroQuantityDisplayGets 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;}
}

NameDescription备注
GetConfigurationCountGets the number of configurations available to this BOM table or used in this BOM table.  获取可用于此 BOM 表或在此 BOM 表中使用的配置数。
GetConfigurationsGets the configurations available to this BOM table or used in this BOM table.  获取可用于此 BOM 表或在此 BOM 表中使用的配置。
GetFeatureGets the BOM table feature.  获取 BOM 表功能。
GetReferencedModelNameGets the name of the model referenced by this BOM feature.  获取此 BOM 特征引用的模型的名称。
GetTableAnnotationCountGets the number of BOM table annotations for this BOM table feature.  获取此 BOM 表功能的 BOM 表注释数量。
GetTableAnnotationsGets the BOM table annotations for this BOM table feature.  获取此 BOM 表特征的 BOM 表注释。
IGetConfigurationsGets the configurations available to this BOM table or used in this BOM table.  获取可用于此 BOM 表或在此 BOM 表中使用的配置。
IGetTableAnnotationsGets the BOM table annotations for this BOM table feature.  获取此 BOM 表特征的 BOM 表注释。
ISetConfigurationsSets the configurations used in this BOM table.  设置此 BOM 表中使用的配置。
SetConfigurationsSets 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;}
}


http://www.ppmy.cn/news/500665.html

相关文章

C++编译过程

How the C Compiler works? 文章目录 How the C Compiler works?compilingExamples总结欢迎关注公众号【三戒纪元】 通过编程&#xff0c;是的text程序编程可执行文件&#xff0c;基本上主要有2个操作发生&#xff1a; compiling 编译linking 链接 compiling C 编辑器要做的…

IComponent2 Interface 学习

Solidworks学习笔记-链接Solidworks 在此基础上学习 允许访问程序集中的组件。 属性 NameDescription备注ComponentReferenceGets or sets a component reference for this component. 获取或设置此组件的组件引用。IMaterialPropertyValuesGets or sets the material pro…

IDrawingComponent Interface 学习

Solidworks学习笔记-链接Solidworks 在此基础上学习 属性 NameDescription备注ComponentGets the referenced component for this drawing component. 获取此绘图组件的引用组件。LayerGets or sets the name of the layer on which the component resides in the view. 获…

C# SolidWorks二次开发-工程图-更换工程图图纸格式/模板

这两天有朋友提问&#xff0c;怎么更换工程图模板。 正好晚上还能挤点时间&#xff0c;就来写一篇文件解答一下。 首先&#xff0c;更换工程图模板&#xff0c;你需要知道手动怎么修改。 如下图&#xff0c;我这个没有模板&#xff0c;只有个纸张大小。 对着视图&#xff0c;右…

C# SolidWorks二次开发---工程图中心标记(Center Marks)

工程图的中心标记 作为一个不专业的制图人员&#xff0c;我就不解释中心标记是什么了。大家自己看Solidworks的官方帮助说明(好像不应该放英文的&#xff0c;大家都看不懂了 )。 就是这么个东东。 我自己画了一个非常复杂的图纸&#xff0c;创建主视图的时候好像就自动增加了…

PDM中的自定义属性映射

在PDM中需要在数据卡中反馈出文件的一些属性信息&#xff0c;使得用户在不打开文件的情况下可以快速了解此文件的属性信息&#xff0c;所以就需要实施的过程中在PDM后台做好属性映射&#xff0c;此文章主要讲述SOLIDWORKS文件、Excel文件、Word文档的属性映射。 SOLIDWORKS文件…

SOLIDWORKS 如何重用DWG格式图纸

经常有工程师咨询DWG图纸在SOLIDWORKS软件里如何使用&#xff0c;其实这涉及到DWG图纸在SOLIDWORKS软件里的重用问题&#xff0c;SOLIDWORKS支持对DWG图纸的重用&#xff0c;常用的有三种方法&#xff1a; 1、作为原始DWG图纸查看 作为原始DWG图纸查看是指使用SOLIDWORKS软件…

DATAKIT CrossManager 2022.4 Crack

CrossManager 是一款独立软件&#xff0c;可让您转换大多数 CAD 格式的文件。 使用 Cross Manager&#xff0c;您只需选择一个或多个 CAD 文件&#xff0c;即可将它们自动翻译成您想要的格式。 DATAKIT CrossManager是一款独立软件&#xff0c;可让您转换大多数 CAD 格式的文件…