Reading bills of materials

Hi all!

I've been trying for months to make a macro read a nomenclature on a plan.

I'm not a VBA expert at all unfortunately, so I use AI to try a lot of things. But I notice that no matter how many macros are generated, it is obviously impossible to read a BOM placed on a plane via Insertion>Table>Nomenclature.

So I would like to appeal to VBA fans of this forum, to find out if anyone has managed to do it or if it is really impossible.

In order to understand my need a little better, here is my final goal:

image

In this image, we can see a bill of materials for an assembly of parts. I would like to be able to retrieve the data from the REP and QTY columns in order to send them as custom ownership of certain parts.

image

Currently, in our BOM template, we have two hidden columns that we fill in by hand so that the properties named MARK and QTE are created/filled in the properties of the part(s) concerned. I will spare you the conditions for whether or not these properties are met.

image

The goal will then be to be able to retrieve them via a specific basemap for our workpieces.

So, do you think a macro can do this?

Thank you in advance for your answers.

Hello

A macro knows how to read the contents of a bill of materials perfectly.
For my part, I use this piece of code to read the content and retrieve all the columns.

            Set swAnnTable = swAnn.GetSpecificAnnotation
            nNumCol = swAnnTable.ColumnCount
            nNumRow = swAnnTable.RowCount
            For idx = 1 To nNumRow - 1
                For j = 1 To nNumCol - 1
                    sTableText = swAnnTable.DisplayedText2(idx, j, True)
                Next j
            Next idx

So to retrieve a particular column (if fixed, otherwise you have to identify the column title and retrieve its column number as for the Excel VBA) the snippet of code is:

swAnnTable.DisplayedText2(numéro de ligne, numéro de colonne, true)
3 Likes

Hello;

Another example of a macro to retrieve information from a BOM:

and to write the properties in the components:

But be careful with this type of manipulation, don't be fooled with the wrong quantities if you work with configurations or in sub-assemblies...

1 Like