BOM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All, I read a lot of past post about Mechanical BOM extraction and so on, but most of them are written in C# or VB.NET or are related to past product dated 2012,and older. I have Autocad Mechanical 2018, and I found a way to access to part reference object and related BOM typical of Mechanical version. But my issue is related how to insert a new part reference inside my modelspace and attach to a specific object or geometry trough VBA code. Here below I tried a simple code to retrive part reference properties:
Sub Bill() 'Managers to extract/parse AutoCAD drawing information Dim symBB As McadSymbolBBMgr Dim bomMGR As McadBOMMgr Dim BOM As McadBOM Dim bomITEM As McadBOMItem Dim name As String Dim BOMbit As String Dim data As Variant 'Defines the bill of materials managers for extraction Set symBB = ThisDrawing.Application.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr") Set bomMGR = symBB.bomMGR 'Tests for BOM with the name "MAIN" in drawing, "MAIN" is default when no title border is selected If bomMGR.BOMTableExists(ThisDrawing.ModelSpace) Then Set BOM = bomMGR.GetBOMTable(ThisDrawing.ModelSpace, "MAIN") Else ThisDrawing.Utility.Prompt "No Usable Parts List" End End If For Each bomITEM In BOM.Items data = bomITEM.data For i = LBound(data) To UBound(data) 'data(i, 0) is the what the general name of column 'data(i, 1) is the value in the cell If data(i, 0) = "MATERIAL" Then data(i, 1) = "CHANGE THIS VALUE" End If Next Next End Sub
Above code working fine, but it's retrive already defined part reference, but I'm not able to find a way to insert a new part reference in a specific point, and as second issue, I'm not able to find coordinates of part reference found. Is there somewhere documentation about BOM and VBA ? Thank you for help