Hi all,
I use this code to check if the sheet contains a BOM
<p> Set swView = swDraw.GetFirstView</p><p> Set swTableAnn = swView.GetFirstTableAnnotation</p><p> On Error GoTo Label1</p><p> If swTableAnn.Type = swTableAnnotation_BillOfMaterials Then</p><p> Debug.Print "There is a BOM"</p><p> swBom = 1</p><p> Else</p><p>Label1:</p><p> Debug.Print "NO BOM"</p><p> swBom = 0</p><p> End If</p><p> </p>
But if there is no BOM,
<p>If swTableAnn.Type = swTableAnnotation_BillOfMaterials Then</p>
gives an error. (object variable or with block variable not set)
I tried to circumvent it with an 'on error goto label1' code... but that doesn't work when a drawing has more than 1 sheet.
***
I use this code to delete all BOMs, but I need it to do it only for the active sheet. (else it will also delete a bom on sheet 2 and then the code above thinks that that sheet never had a bom). It does need to delete all BOMs per sheet though because sometimes the engineers have multiple BOM's on a single sheet.
<p> While Not swFeat Is Nothing</p><p> If "BomFeat" = swFeat.GetTypeName Then</p><p> swFeat.Select2 True, -1</p><p> End If</p><p> Set swFeat = swFeat.GetNextFeature</p><p> Wend</p><p> swModel.Extension.DeleteSelection2 swDeleteSelectionOptions_e.swDelete_Absorbed</p>SolidworksApi macros
