D.S

adndevblog.typepad.com

Iterate Structured BOMView - Manufacturing DevBlog

Iterate Structured BOMView - Manufacturing DevBlog Manufacturing DevBlog The resource for software developers working with Design, Lifecycle and Simulation technologies from Autodesk. Home Subscribe Follow Useful Links Autodesk About this Blog « Get ItemNumber from a DrawingCurve | Main | Display range box of componenets in assembly context » 11/23/2013 Iterate Structured BOMView By  Adam Nagy Here is a sample VBA code that lists some information from the Structured BOMView of an assembly:  Public Sub IterateRows _ (oBOMRows As BOMRowsEnumerator, indent As Integer) Dim oBOMRow As BOMRow For Each oBOMRow In oBOMRows ' Let's only get the first definition ' It would only be more than one if rows were merged Dim oDef As ComponentDefinition Set oDef = oBOMRow.ComponentDefinitions(1) Dim partNumber As String partNumber = oDef.Document.PropertySets( _ "{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").value Debug.Print Tab(indent); oBOMRow.itemNumber + " " + partNumber If Not oBOMRow.ChildRows Is Nothing Then Call IterateRows(oBOMRow.ChildRows, indent + 1) End If Next End Sub Public Sub IterateThroughStructuredBOM() Dim oAsm As AssemblyDocument Set oAsm = ThisApplication.ActiveDocument Dim oBOM As BOM Set oBOM = oAsm.ComponentDefinition.BOM ' Make sure it's enabled oBOM.StructuredViewEnabled = True oBOM.StructuredViewFirstLevelOnly = False Dim oBOMView As BOMView Set oBOMView = oBOM.BOMViews("Structured") Call IterateRows(oBOMView.BOMRows, 1) End Sub It prints out something like this: 1 SubAsm1 1.1 Part11 1.2 Part12 2 SubAsm2 2.1 Part21 2.2 Part22 Posted at 05:40 AM in Adam Nagy , Inventor | Permalink | | | Comments Iterate Structured BOMView By  Adam Nagy Here is a sample VBA code that lists some information from the Structured BOMView of an assembly:  Public Sub IterateRows _ (oBOMRows As BOMRowsEnumerator, indent As Integer) Dim oBOMRow As BOMRow For Each oBOMRow In oBOMRows ' Let's only get the first definition ' It would only be more than one if rows were merged Dim oDef As ComponentDefinition Set oDef = oBOMRow.ComponentDefinitions(1) Dim partNumber As String partNumber = oDef.Document.PropertySets( _ "{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").value Debug.Print Tab(indent); oBOMRow.itemNumber + " " + partNumber If Not oBOMRow.ChildRows Is Nothing Then Call IterateRows(oBOMRow.ChildRows, indent + 1) End If Next End Sub Public Sub IterateThroughStructuredBOM() Dim oAsm As AssemblyDocument Set oAsm = ThisApplication.ActiveDocument Dim oBOM As BOM Set oBOM = oAsm.ComponentDefinition.BOM ' Make sure it's enabled oBOM.StructuredViewEnabled = True oBOM.StructuredViewFirstLevelOnly = False Dim oBOMView As BOMView Set oBOMView = oBOM.BOMViews("Structured") Call IterateRows(oBOMView.BOMRows, 1) End Sub It prints out something like this: 1 SubAsm1 1.1 Part11 1.2 Part12 2 SubAsm2 2.1 Part21 2.2 Part22 View the entire comment thread. Please enable JavaScript if you would like to comment on this blog. Search Submit Mfg DevBloggers Adam Nagy Augusto Goncalves Balaji Ramamoorthy Daniel Du Philippe Leefsma Vladimir Ananyev Wayne Brill Xiaodong Liang November 2016 Sun Mon Tue Wed Thu Fri Sat     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30       Autodesk Blogs ADN DevBlog - AEC Our DevBlog for Revit, Navisworks, AEC and BIM technology APIs. ADN DevBlog - AutoCAD Our DevBlog for AutoCAD and other platform technology APIs. ADN DevBlog - Cloud and Mobile Our DevBlog for Cloud and Mobile technologies. ADN DevBlog - Infrastructure Modeling Our DevBlog for Infrastructure Modeling technology APIs. ADN DevBlog - Manufacturing Our DevBlog for Design, Lifecycle and Simulation technologies. Around the Corner Cyrille Fauvel's Maya platform developer blog - Autodesk Media and Entertainment technology. Civilized Development Isaac Rodriguez's AutoCAD Civil 3D developer blog Dances with Elephants Jim Quanci's blog on partnering with large companies. It's All Just Ones and Zeros Doug Redmond's Vault developer blog Mod the Machine Brian Ekins' and Adam Nagy's Inventor developer blog The 360 View Mikako Harada's BIM 360 developer blog The 3D Web Coder Jeremy Tammik's web and mobile programming blog The Building Coder Jeremy Tammik's Revit developer blog Through the Interface Kean Walmsley's AutoCAD developer blog Yet more on autodesk.com ... Central blog list on autodesk.com Share Recent Posts iLogic: ActiveDocument.ComponentDefinition throws exception for specific document Fusion API: Usage of Table Control Introduction to Fusion 360 API Create Sketch Text on Face of Assembly Fusion API: Usage of Mouse Event Making your add-in callable from VBA Autodesk App Store Forge and Fusion 360 Hackathon September 1 - October 31 Fusion API: Toggle [Capture Design History] Check or UnCheck iProperties Date Created and Date Checked example Delete Objects with Fusion 360 API Archives November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 M