I am currently writing a macro to extract component information (i.e. quantity, part number, etc.) from top-level only type BOMs, and I would like to use the GetComponents2 and GetComponentsCount2 methods to get information about the BOM line items in BOMs with more than one configuration.
I was playing around with these 2 methods using the example provided on the API help website, and I ran into some strange results:
When the drawing BOM was "Top-level only" type
- GetComponents2 always returns empty array
- GetComponentsCount2 always returns 0, but sets ItemNumber and PartNumber strings correctly
When the drawing BOM was "Parts only" type
- GetComponents2 returns correct array of components
- GetComponentsCount2 return correct quantity and sets ItemNumber and PartNumber strings correctly
Strangely enough, I noticed that the deprecated GetComponents and GetComponentsCount methods work correctly for both top-level only and parts only BOMs (but they do not have the capability of differentiating between BOM configurations).
Has anyone else had issues getting these 2 methods to work? If so, is there a way to make them work correctly on "top-level only" BOMs?
***Note: This issue only seems to appear in SW2016. The example referenced above worked fine in SW2015...... ****