I have a top view from which I make a section view from. Looking at the help files and sources online I made a macro that adds in a weldment table and autoballoons the section view. The problem I'm having is that the autoballoons are not being created in my section view. As a test, I tried creating the autoballoons in the top view "Drawing View1" and it worked. I've also included the drawing file and part file if needed.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swFeat As SldWorks.Feature
Dim swView As SldWorks.View
Dim swComp As SldWorks.Component2
Dim swConfig As SldWorks.Configuration
Dim swWeldmentTbl As SldWorks.WeldmentCutListAnnotation
Dim autoballoonParams As SldWorks.AutoBalloonOptions
Dim vComps As Variant
Dim vComp As Variant
Dim confignames As Variant
Dim vNotes As Variant
Dim swViewCenterPt() As Double
Dim boolstatus As Boolean
Const WeldmentTableTemplate As String = "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\lang\\english\\cut list.sldwldtbt"
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
'get the view that is a section view
If swView.Type = swDrawingViewTypes_e.swDrawingSectionView Then
vComps = swView.GetVisibleComponents
For Each vComp In vComps
Set swComp = vComp
Next vComp
Set swModel = swComp.GetModelDoc2
Set swConfig = swModel.GetActiveConfiguration
Set swModel = swApp.ActiveDoc
swViewCenterPt = swView.Position
'insert weldment cut list table
Set swWeldmentTbl = swView.InsertWeldmentTable(False, 0, 0, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, swConfig.Name, WeldmentTableTemplate)
Set autoballoonParams = swDraw.CreateAutoBalloonOptions()
autoballoonParams.Layout = swDetailingBalloonLayout_Circle
autoballoonParams.ReverseDirection = False
autoballoonParams.IgnoreMultiple = True
autoballoonParams.InsertMagneticLine = True
autoballoonParams.LeaderAttachmentToFaces = True
autoballoonParams.Style = swBS_Circular
autoballoonParams.Size = swBF_5Chars
autoballoonParams.UpperText = swBalloonTextItemNumber
autoballoonParams.Layername = "-None-"
autoballoonParams.ItemNumberStart = 1
autoballoonParams.ItemNumberIncrement = 1
autoballoonParams.ItemOrder = swBalloonItemNumbersOrder_e.swBalloonItemNumbers_DoNotChangeItemNumbers
autoballoonParams.EditBalloons = True
autoballoonParams.EditBalloonOption = swEditBalloonOption_Resequence
'boolstatus = swDraw.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = swDraw.Extension.SelectByID2(swView.Name, swSelectType_e.swSelDRAWINGVIEWS, 0, 0, 0, False, 0, Nothing, 0)
boolstatus = swDraw.ActivateView(swView.Name)
vNotes = swDraw.AutoBalloon5(autoballoonParams)
End If
Set swView = swView.GetNextView
Wend
End Sub
Your section view doesn't have faces, so when you set the option:
autoballoonParams.LeaderAttachmentToFaces = True
the call to AutoBalloon5 will fail.
I changed it to false but AutoBalloon5 still doesn't place them. I even unchecked "Slice section" in the section view options so the faces would show but that didn't work either. The Auto Balloon tool works when I select the tool in the GUI.
I just noticed another thing while debugging. While stepping through the code I noticed that the line of code I'm using to select the section view is actually selecting the weldment table. I can see in the GUI the table getting selected.
Your SelectByID call is incorrect. Change it to
boolstatus = swDraw.Extension.SelectByID2(swView.Name, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Also, you do not need the call to ActivateView.