Check BOM on sheet
Check BOM on sheet
(OP)
How can i check on what sheet a bom is.
I have several sheets and several boms, only 1 on a pge offcourse.
please fill in the blanks ..
Sub checkbom()
Dim bom_aanwezig As SldWorks.Feature
Dim swBomFeat As SldWorks.BomFeature
Dim vTableArr As Variant
Dim swTable As SldWorks.TableAnnotation
Set swApp = Application.SldWorks
Set actDOC = swApp.ActiveDoc
Set bom_aanwezig = actDOC.FirstFeature
Do While Not bom_aanwezig Is Nothing
Dim tsoort
tsoort = bom_aanwezig.GetTypeName
If tsoort = "BomFeat" Then
Set swBomFeat = bom_aanwezig.GetSpecificFeature2
vTableArr = swBomFeat.GetTableAnnotations
Set swTable = vTableArr(0)
Dim aantalrijen
aantalrijen = swTable.RowCount
For i = 1 To aantalrijen
hoogteverstelling = hoogteverstelling + 0.0045
Next i
'End If
Set bom_aanwezig = bom_aanwezig.GetNextFeature
Else
Set bom_aanwezig = bom_aanwezig.GetNextFeature()
End If
Loop
End Sub
I have several sheets and several boms, only 1 on a pge offcourse.
please fill in the blanks ..
Sub checkbom()
Dim bom_aanwezig As SldWorks.Feature
Dim swBomFeat As SldWorks.BomFeature
Dim vTableArr As Variant
Dim swTable As SldWorks.TableAnnotation
Set swApp = Application.SldWorks
Set actDOC = swApp.ActiveDoc
Set bom_aanwezig = actDOC.FirstFeature
Do While Not bom_aanwezig Is Nothing
Dim tsoort
tsoort = bom_aanwezig.GetTypeName
If tsoort = "BomFeat" Then
Set swBomFeat = bom_aanwezig.GetSpecificFeature2
vTableArr = swBomFeat.GetTableAnnotations
Set swTable = vTableArr(0)
Dim aantalrijen
aantalrijen = swTable.RowCount
For i = 1 To aantalrijen
hoogteverstelling = hoogteverstelling + 0.0045
Next i
'End If
Set bom_aanwezig = bom_aanwezig.GetNextFeature
Else
Set bom_aanwezig = bom_aanwezig.GetNextFeature()
End If
Loop
End Sub






RE: Check BOM on sheet
I do not know if you can find that out from the way you are doing it; I have never tried it. I did a semi-quick look through API help but could not find any straightforward method. In the past, I wrote a macro that cycled through each sheet, got the tableannotation object associated with that sheet and then got the BOMFeature object to get the BOM name.
Regards,
Regg