I'm trying to use the following line of code to create aTopLevelOnly BOM. All it does is create a header without populatingany rows with the part data. Is there something wrong with thecode?
I've noticed a couple of posts hinting that SW API does not havethe capability to do this and that the term'swBomType_TopLevelOnly' is faulty. Is this correct? I am runningSW2007.
Set swBOMTable = View.InsertBomTable2(True, 0, 0,swBOMConfigurationAnchor_BottomRight, swBomType_TopLevelOnly,View.ReferencedConfiguration, BomDir)
Is there any other way to do this? Can I first create an indentedBOM (which does work) and then change it to a Top Level BOM in mycode somehow?
Cheers,
BevanSolidworksApi macros
I've noticed a couple of posts hinting that SW API does not havethe capability to do this and that the term'swBomType_TopLevelOnly' is faulty. Is this correct? I am runningSW2007.
Set swBOMTable = View.InsertBomTable2(True, 0, 0,swBOMConfigurationAnchor_BottomRight, swBomType_TopLevelOnly,View.ReferencedConfiguration, BomDir)
Is there any other way to do this? Can I first create an indentedBOM (which does work) and then change it to a Top Level BOM in mycode somehow?
Cheers,
BevanSolidworksApi macros

Set BomFeat = BomTable.BomFeature
BomFeat.DisplayAsOneItem = True
Names = BomFeat.GetConfigurations(False, Visible)
For j = 0 To UBound(Names)
If Names(j) = View.ReferencedConfiguration Then
Visible(j) = True
Else
Visible(j) = False
End If
Next j
bool = BomFeat.SetConfigurations(False, Visible, Names)
BomFeat.FollowAssemblyOrder2 = True
The For/Next loop ensures that only one configuration is visibleand sets the BOM to that configuration only. It is kind of strangeas you see the BOM inserted first and then it is populated afterthe configurations are set. Anyway, this has worked for meconsistently.
I have this same problem. Why can't I just do this::
Set swBOMTable = swBOMview.InsertBomTable3(True, 0.01328, 0.01043, 3, 2, "Default", strBOMtemplate, False
Set swBOMFeature = swBOMTable.BomFeature
intConfigCount = swBOMFeature.GetConfigurationCount(False)
swBOMFeature.DisplayAsOneItem = True
swBOMFeature.SetConfigurations False, True, "Default"
intConfigCount = 1. This is the "Default" configuration. For some reason no matter what I try my top level only BOM won't populate!
SetConfigurations works only when I input arrays for the Configuration names and their Visibility.