Insert and Show BOM Table in Assembly Example (C#) - 2021
文章推薦指數: 80 %
This example shows how to insert and show a BOM table in an assembly document. ... Inserts a split-circle stacked balloon, which uses the // BOM table item ...
About
LearningResources
My.SolidWorks
SubscriptionServices
>
InsertandShowBOMTableinAssemblyExample(C#)
SOLIDWORKSAPIHelp
Otherversions:
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
|
Print
| Feedbackonthistopic
Welcome
GettingStarted
SOLIDWORKSAPIHelp
SOLIDWORKSElectricalAPIHelp
SOLIDWORKSPDMProfessionalAPIHelp
FeatureWorksAPIHelp
SOLIDWORKSCostingAPIHelp
SOLIDWORKSDocumentManagerAPIHelp
SOLIDWORKSRoutingAPIHelp
SOLIDWORKSSimulationAPIHelp
SOLIDWORKSSustainabilityAPIHelp
SOLIDWORKSToolboxAPIHelp
SOLIDWORKSUtilitiesAPIHelp
eDrawingsAPIHelp
DraftSightAPIHelp
LispProgrammingBasics
LispFunctionsOverview
LispFunctionsReference
VisualLispCompatibleFunctions
InsertandShowBOMTableinAssemblyExample(C#)
ThisexampleshowshowtoinsertandshowaBOMtableinanassembly
document.
//------------------------------------------------
// Preconditions:
//1.Verifythatthespecified file to open and template exist.
//2.OpentheImmediatewindow.
//
// Postconditions:
// 1. Insertsanindented BOM table.
// 2. Insertsasplit-circle stacked balloon, which uses the
// BOM table item number for its upper text,
// at the selected face.
// 3. Examine the BOM table, stacked balloon,andImmediate
//window.
//
// NOTE: Because this assembly document is usedelsewhere,
// do not save changes.
//-------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
namespace IBomFeatureInsertBomTable3CSharp.csproj
{
partial class SolidWorksMacro
{
public void Main()
{
ModelDoc2 swModel = default(ModelDoc2);
ModelDocExtension swModelDocExt = default(ModelDocExtension);
BomTableAnnotation swBOMAnnotation = default(BomTableAnnotation);
BomFeature swBOMFeature = default(BomFeature);
StackedBalloonOptions StackedBalloonParams = default(StackedBalloonOptions);
Note swNote = default(Note);
bool boolstatus = false;
int BomType = 0;
int nbrType = 0;
string Configuration = null;
string TemplateName = null;
int nErrors = 0;
int nWarnings = 0;
// Open assembly document
swModel = (ModelDoc2)swApp.OpenDoc6("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS2018\\samples\\tutorial\\api\\arm2.sldasm", (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref nErrors, ref nWarnings);
swModelDocExt = (ModelDocExtension)swModel.Extension;
// Insert BOM table
TemplateName = "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\lang\\english\\bom-standard.sldbomtbt";
BomType = (int)swBomType_e.swBomType_Indented;
Configuration = "Default";
nbrType = (int)swNumberingType_e.swNumberingType_Detailed;
swBOMAnnotation = (BomTableAnnotation)swModelDocExt.InsertBomTable3(TemplateName, 0, 0, BomType, Configuration, false, nbrType, true);
swBOMFeature = (BomFeature)swBOMAnnotation.BomFeature;
// Print the name of the configuration used for the BOM table
Debug.Print("Name of configuration used for BOM table: " + swBOMFeature.Configuration);
// Insert BOM balloon for the selected face
boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.091853347996107, -0.0104709589619745, 0.00174830255600256, false, 0, null, 0);
StackedBalloonParams = (StackedBalloonOptions)swModelDocExt.CreateStackedBalloonOptions();
StackedBalloonParams.BalloonsPerLine = 10;
StackedBalloonParams.StackDirection = (int)swStackedBalloonDirection_e.swStackedBalloonDir_Right;
StackedBalloonParams.Style = (int)swBalloonStyle_e.swBS_SplitCirc;
StackedBalloonParams.LowerTextContent = (int)swBalloonTextContent_e.swBalloonTextCustom;
StackedBalloonParams.LowerText = "Lower Text";
StackedBalloonParams.ShowQuantity = true;
StackedBalloonParams.Size = (int)swBalloonFit_e.swBF_Tightest;
StackedBalloonParams.QuantityPlacement = (int)swBalloonQuantityPlacement_e.swBalloonQuantityPlacement_Top;
StackedBalloonParams.QuantityDenotationText = "Denotation Text";
StackedBalloonParams.QuantityOverride = false;
StackedBalloonParams.ItemNumberStart = 1;
StackedBalloonParams.ItemNumberIncrement = 1;
StackedBalloonParams.ItemOrder = (int)swBalloonItemNumbersOrder_e.swBalloonItemNumbers_DoNotChangeItemNumbers;
swNote = (Note)swModelDocExt.InsertStackedBalloon2(StackedBalloonParams);
swModel.ViewZoomtofit2();
// Get whether balloon is a stacked balloon;
// if so, print the name of the balloon
if (swNote.IsStackedBalloon())
{
Debug.Print("Name of stacked balloon: " + swNote.GetName());
}
}
///
延伸文章資訊
- 1Draw a BOM table - PTC Support Portal
The Draw BOM dialog box allows you to add the current BOM information to your drawing. The inform...
- 2Linux CLI 對UTF-8 檔案增加BOM 怎麼做 - Tsung's Blog
相關網頁. utf 8 - Adding BOM to UTF-8 files - Stack Overflow. Share this ...
- 3How to Add Byte-Order-Mark BOM Codes to a STMF ... - IBM
CPYTOIMPF does not add BOM codes to a UTF-8 streamfile to clearly identify it as a UTF-8 file on ...
- 4Can't insert active version of BOM and route numbers
If the default site and warehouse are already defined for a selected product, you won't be prompt...
- 5Insert and Show BOM Table in Assembly Example (C#) - 2021
This example shows how to insert and show a BOM table in an assembly document. ... Inserts a spli...