Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim swApp As Object
- Sub main()
- Dim swApp As SldWorks.SldWorks
- Dim swModel As SldWorks.ModelDoc2
- Dim swDrw As DrawingDoc
- Dim swSheet As SldWorks.Sheet
- Dim swView As View
- Dim swoNote As Note
- Dim swAnn As Annotation
- Dim swAnns As Variant
- Dim sSheetName() As String
- Dim swEnt As SldWorks.Entity
- Dim swComp As SldWorks.Component
- Dim i, j, ix As Long
- Dim BalloonArray() As Variant
- Set swApp = Application.SldWorks
- Set swModel = swApp.ActiveDoc
- If swModel.GetType = swDocDRAWING Then
- Set swDrw = swModel
- Else
- MsgBox "Open a drawing doc, please", vbOKOnly + vbInformation
- Exit Sub
- End If
- sSheetName = swDrw.GetSheetNames
- ix = 0
- For i = 0 To UBound(sSheetName)
- swDrw.ActivateSheet sSheetName(i)
- Set swSheet = swDrw.GetCurrentSheet
- ' Debug.Print sSheetName(i)
- Set swView = swDrw.GetFirstView
- Do
- swAnns = swView.GetAnnotations
- If Not IsEmpty(swAnns) Then
- For j = 0 To UBound(swAnns)
- Set swAnn = swAnns(j)
- If swAnn.GetType = swNote Then
- Set swoNote = swAnn.GetSpecificAnnotation
- If swoNote.IsBomBalloon Then
- ReDim Preserve BalloonArray(ix)
- BalloonArray(ix) = Array(swoNote.GetText, i + 1, swSheet.GetDrawingZone(swoNote.GetBalloonInfo(0), swoNote.GetBalloonInfo(1)))
- ix = ix + 1
- Debug.Print (swoNote.GetText & ": " & i + 1 & ", " & swSheet.GetDrawingZone(swoNote.GetBalloonInfo(0), swoNote.GetBalloonInfo(1)))
- End If
- End If
- Next j
- End If
- Set swView = swView.GetNextView
- Loop While Not (swView Is Nothing)
- Next i
- ''Added BOM Intigration
- Dim swDraw As SldWorks.DrawingDoc
- Dim swFeat As SldWorks.Feature
- Dim BOMName As String
- Dim swFileName As String
- Dim swBomFeat As SldWorks.BomFeature
- Dim vBomTableAnn As Variant
- Dim swBomTableAnn As SldWorks.BomTableAnnotation
- Dim swTableAnn As SldWorks.TableAnnotation
- Dim iRow As Integer
- Dim iCol As Integer
- Set swApp = Application.SldWorks
- Set swModel = swApp.ActiveDoc
- Set swDrawingsDoc = swApp.ActiveDoc
- Set swFeat = swModel.FirstFeature
- While Not swFeat Is Nothing
- BOMName = swFeat.Name
- If "BomFeat" = swFeat.GetTypeName Then
- 'swFeat.Select True
- Set swBomFeat = swFeat.GetSpecificFeature2
- vBomTableAnn = swBomFeat.GetTableAnnotations
- Set swBomTableAnn = vBomTableAnn(0)
- Set swTableAnn = swBomTableAnn
- ' For iRow = 0 To swTableAnn.TotalRowCount - 1
- ' For iCol = 0 To swTableAnn.TotalColumnCount - 1
- ' Debug.Print swTableAnn.Text(iRow, iCol)
- ' Next
- ' Next
- If swTableAnn.DisplayedText(0, swTableAnn.ColumnCount - 1) <> "ZONE" Then
- swTableAnn.InsertColumn2 swTableItemInsertPosition_Last, 0, "ZONE", swInsertColumn_DefaultWidth
- swTableAnn.SetColumnType swTableAnn.ColumnCount - 1, 0
- Else
- Debug.Print ("already has zone")
- End If
- For iRow = 0 To swTableAnn.TotalRowCount - 1
- For ix = 0 To UBound(BalloonArray)
- If BalloonArray(ix)(0) = swTableAnn.Text(iRow, 0) Then
- 'Debug.Print BalloonArray(ix)(0) & ": " & BalloonArray(ix)(1) & ", " & BalloonArray(ix)(2) & "::: " & swTableAnn.Text(iRow, 0)
- swTableAnn.Text(iRow, swTableAnn.ColumnCount - 1) = swTableAnn.Text(iRow, swTableAnn.ColumnCount - 1) & "(" & BalloonArray(ix)(1) & "/" & BalloonArray(ix)(2) & ")" & vbLf
- End If
- Next
- 'Debug.Print swTableAnn.Text(iRow, 0)
- Next
- End If
- Set swFeat = swFeat.GetNextFeature
- Wend
- ''Added BOM Intigration
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement