Insert and Show BOM Table in Assembly Example (C#) - 2021

文章推薦指數: 80 %
投票人數:10人

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());             }         }         /// 

        /// The SldWorks swApp variable is pre-assigned for you.         ///          public SldWorks swApp;     } } Search'InsertandShowBOMTableinAssemblyExample(C#)'intheSOLIDWORKSKnowledgeBase. Providefeedbackonthistopic SOLIDWORKSwelcomesyourfeedbackconcerningthepresentation,accuracy,andthoroughnessofthedocumentation.Usetheformbelowtosendyourcommentsandsuggestionsaboutthistopicdirectlytoourdocumentationteam.Thedocumentationteamcannotanswertechnicalsupportquestions.Clickhereforinformationabouttechnicalsupport. *Required   *Email:   Subject:   FeedbackonHelpTopics Page:   InsertandShowBOMTableinAssemblyExample(C#) *Comment:   *   IacknowledgeIhavereadandIherebyaccepttheprivacypolicyunderwhichmyPersonalDatawillbeusedbyDassaultSystèmes Cancel Thankyouforyourcomments.Wewillcontactyouifwehavequestionsregardingyourfeedback.Sincerely,TheSOLIDWORKSDocumentationTeam PrintTopic Selectthescopeofcontenttoprint: ThistopicandalltopicslinkedfromthistopicJustthistopicThistopicandonlyimmediatetopicsunderitThisselectedtopicandallsubtopics Cancel x WehavedetectedyouareusingabrowserversionolderthanInternetExplorer7.Foroptimizeddisplay,wesuggestupgradingyourbrowsertoInternetExplorer7ornewer.  Nevershowthismessageagain x WebHelpContentVersion:APIHelp(Englishonly)2021SP05 TodisableWebhelpfromwithinSOLIDWORKSanduselocalhelpinstead,clickHelp>UseSOLIDWORKSWebHelp. ToreportproblemsencounteredwiththeWebhelpinterfaceandsearch,contactyourlocalsupportrepresentative.Toprovidefeedbackonindividualhelptopics,usethe“Feedbackonthistopic”linkontheindividualtopicpage. 0.20.25 TermsofUse  | PrivacyPolicy  | PersonalizeCookieChoices  | GetaProductDemo  | ContactSales  | GetaQuote &nbsp©1995-2022 DassaultSystèmes.Allrightsreserved.



請為這篇文章評分?