10 Replies Latest reply on Oct 30, 2009 8:05 AM by Patrice Herold

    BOM API

    Patrice Herold

      Hi folks,



      I've a question about the BOM Example found here: http://files.solidworks.com/swexpress/API_Tips/SWX070709_APItip.html

       

      I created a function with this example in it, and I can use and debug it. But my edmBOMView is always empty.

      Not really empty though, in the VB.Net debugger I can see the Value "{EdmLib.EdmBomViewClass}", that's all.

       

      How can I get the rows and columns out of the edmBOMView?

       


      Any help is appreciated, thx alot!

        • Re: BOM API
          Joy Garon

          Hi Patrice -

           

          Look in this thread and you will see an API sample provided by Lee Young that might help.

          https://forum.solidworks.com/message/84528#84528

           

           

          Regards,

          Joy

          • Re: BOM API
            See the IEdmBomView.GetRows() and IEdmBomView.GetColumns() methods.
              • Re: BOM API
                Patrice Herold

                Hi Lee,

                 

                I tried these methods with this:

                 

                Dim edmBOMRow() As Array

                 

                edmBOMRow = edmBOMView.GetRow()

                 

                I get the error:

                 

                "Argument not specified for parameter 'ppoRows' of 'Public Sub GetRows(ByRef ppoRows As System.Array)'."

                 

                Then I tried:

                 

                edmBOMView.GetRows(edmBOMRow)

                 

                But edmBOMRow stays empty. FYI, your example works, I can see the BOM and the content. I think I do something wrong with the parameter of the GetRow() function.

                 

                I saw in your C# example that there is the operation "out" to get the content of the pointer referenced to the variable, do I have to do something similiar here?

                 

                Thx for you help guys!


                  • Re: BOM API

                    Try:

                     

                    Dim edmBOMRow As Array = Array.CreateInstance(GetType(IEdmBomCell), 0)
                    edmBOMView.GetRows(edmBOMRow)

                      • Re: BOM API
                        Patrice Herold

                        Hi Lee,

                         

                        I'm getting "Array bounds cannot appear in type specifiers." for the GetType(IEdmBomCell).

                         

                        I remember that I tried

                        Dim edmBOMRow As IEdmBomCell

                        which didn't create any error, but it stayed empty too.

                         

                        But I think your solution is close .. something with Array and IEdmBomCell.

                          • Re: BOM API
                            Patrice Herold

                            Ahh, I'm stupid, I forgot the "Array =" part.

                             

                            So, now I have something inside "edmBomRow" .. 65 entries. But they are all "System.__ComObject" and inside is another empty "System.__ComObject", nothing else.

                            There should be the names of the entries, right? How do I get the names?

                              • Re: BOM API

                                Try:

                                 

                                Dim cell As IEdmBomCell
                                For Each cell In edmBomRow
                                    'Work with cell, for example
                                    'cell.GetItemID.ToString
                                    'cell.GetPathName
                                    'cell.GetTreeLevel.ToString
                                    'cell.IsLocked.ToString
                                Next

                                  • Re: BOM API
                                    Patrice Herold

                                    Thx, that's how it works.

                                     

                                    Now I'll do the same with the columns and then do some loops to get the content out of cell.GetVar() <- this one looks a little bit more complicated, but I'll see.

                                     

                                    Anyway, I think the code you provided is really missing in the example from the Solidworks newsletter. Cause to have just edmBOMView is not enough. You need these arrays and loops to get to the real content. They should've added this.

                        • Re: BOM API
                          Roland Schwarz

                          http://www.esoxrepublic.com/freeware

                           

                          Download and dissect the BOM to Clipboard macro.  You will see how to find a BOM and how to move through rows and columns.