2 Replies Latest reply on Oct 7, 2015 5:45 PM by Seth Ruhan

    check whether bom exists

    Mario Zahren

      Hello all,

       

      is there any way to check whether bom exists in a drawing or not? I can not find any snippets...

       

      Any help would be appreciated.

      Mario

        • Re: check whether bom exists
          Simon Turner

          Loop through all the views in the drawing.

          Use IView::GetFirstTableAnnotation and ITableAnnotation.GetNext

          followed by checking ITableAnnotation.Type = swTableAnnotation_BillOfMaterials

          • Re: check whether bom exists
            Seth Ruhan

            Snippets

             

            Public Shared Sub CheckDrawing(ByVal swModel As ModelDoc2)

                    Try

                        If swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then

                            Exit Sub

                        End If

             

             

                        Dim DwgDoc As DrawingDoc = swModel

                        Dim swFeat As IFeature = DwgDoc.FirstFeature

                        Dim swBomFeat As IBomFeature

             

             

                        Do While Not swFeat Is Nothing

                            If "BomFeat" = swFeat.GetTypeName Then

                                swBomFeat = swFeat.GetSpecificFeature2

                                ProcessBomFeature(DwgDoc, swBomFeat)

                            End If

                            If "WeldmentTableFeat" = swFeat.GetTypeName Then

                                ProcessWeldmentBOM(swFeat)

                            End If

                            swFeat = swFeat.GetNextFeature

                        Loop

                    Catch ex As System.Exception          

                    End Try

                End Sub

             

             

                Private Shared Sub ProcessBomFeature(DwgDoc As DrawingDoc, swBomFeat As BomFeature)

                    Dim swFeat As IFeature

                    Dim vTableArr As Object

                    Dim vTable As Object

                    Dim vConfigArray As Object

                    Dim vConfig As Object

                    Dim ConfigName As String

                    Dim swTable As ITableAnnotation

             

                    swFeat = swBomFeat.GetFeature

                    vTableArr = swBomFeat.GetTableAnnotations

             

             

                    For Each vTable In vTableArr

                        swTable = vTable

                        vConfigArray = swBomFeat.GetConfigurations(True, True)

                        For Each vConfig In vConfigArray

                            ConfigName = vConfig

                            ProcessTableAnn(swBomFeat, swTable, ConfigName)

                        Next vConfig

                    Next vTable

                End Sub

            Shared Sub ProcessTableAnn(swBomFeat As BomFeature, swTableAnn As ITableAnnotation, ConfigName As String)

            'Do stuff here

            end sub

            Shared Sub ProcessWeldmentBOM(Feat As IFeature)

                    Try

                        Dim CutListFeat As IWeldmentCutListFeature = Feat.GetSpecificFeature2

                        Dim swTableAnn As ITableAnnotation = CutListFeat.IGetTableAnnotations(CutListFeat.GetTableAnnotationCount)

                        Dim CutListAnnotation As IWeldmentCutListAnnotation = CutListFeat.IGetTableAnnotations(CutListFeat.GetTableAnnotationCount)

                        If swTableAnn.Type = swTableAnnotationType_e.swTableAnnotation_WeldmentCutList Then

             

                                'Do stuff here

                          

                        End If

                    Catch ex As System.Exception      

                    End Try

                End Sub