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());
}
}
///
延伸文章資訊
- 1Insert BOM Table Example (VB.NET) - SolidWorks Web Help
Inserts a BOM at the anchor point, if the ' drawing view does not already contain a BOM. ' 2. Exa...
- 2How 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 ...
- 3Adding BOM to UTF-8 files - Stack Overflow
The easiest way I found for this is #!/usr/bin/env bash #Add BOM to the new file printf '\xEF\xBB...
- 4Insert BOM - Onshape
Insert BOM tool icon Insert BOM ... This functionality is currently available only on browser. .....
- 5UTF-8 BOM Tool - Microsoft Store
This tool can add or remove BOM for UTF-8 files.