Issues with InsertModelAnnotations3 functionality in a macro

Here is my issue. I am attempting to automate the drawing process for one of my company's assemblies. So far, its gone swimmingly as far as creating the actual drawing and the needed views and sections. My issue arises when trying to implement InsertModelAnnotations3. Here's some things to know about the actual assembly being used:

  1. The assembly has x number of configurations, with machining and assembly steps at each different stage. I.e. configuration 1 has the features and components from configurations 2, 3, ...n suppressed; configuration 2 has the features and components from configs 3, 4, ...n
  2. The drawing also includes a view of the base component of the assembly as a component, not as another configuration. This is added after the attempt at adding model annotations.
  3. To make the views and section views for each configuration, a For loop is used, referencing the number of configurations for its run parameter.

Here is the vba code being run to create the views. Adding the model annotations is at the end of the section.

'Get sheet size

Dim cursheet As sheet

Dim sheetwidth As Double, sheetheight As Double

Dim sheetscale As Double

Dim sheetprops As Variant

Set cursheet = swDrawing.GetCurrentSheet

cursheet.GetSize sheetwidth, sheetheight

Dim view As view

Dim vOutline As Variant, vPosition As Variant

Dim viewWidth As Double, viewHeight As Double

Dim P1 As Object

Dim p2 As Object

Dim value As Boolean

Dim boolstatus As Boolean

Dim swSketchMgr As SldWorks.SketchManager

Dim swSketchSegment As SldWorks.SketchSegment

Dim excludedComponents As Variant

Dim swView As SldWorks.view

Dim swSectionView As SldWorks.DrSection

Dim swFeatMgr As SldWorks.FeatureManager

Dim varFeat  As Variant

Dim varCircFeat  As Variant

Dim numConfigs As Long

Dim ConfigNames As Variant

Dim i As Long

Dim suffix As String

Dim viewName As String

' calls the number and names of configurations in the rotor assembly

numConfigs = swModel.GetConfigurationCount

ConfigNames = swModel.GetConfigurationNames

viewName = "A"

For i = 0 To (numConfigs - 1)

    'create right views of each configuration

    boolstatus = swModel.ShowConfiguration2(ConfigNames(i))

    Set view = swDrawing.CreateDrawViewFromModelView3(filename, "*Front", sheetwidth, sheetheight, 0)

    ' Now get view size and move left and down to bring into sheet

    vOutline = view.GetOutline

    vPosition = view.Position

    viewWidth = vOutline(2) - vOutline(0)

    viewHeight = vOutline(3) - vOutline(1)

    vPosition(0) = sheetwidth * 0.25

    vPosition(1) = sheetheight * ((i + 2) / numConfigs) * 0.55

    view.Position = vPosition

    'get the sheet scale, cause it may have changed

    sheetprops = cursheet.GetProperties

    sheetscale = sheetprops(2) / sheetprops(3)

    boolstatus = swDrawing.ActivateView(view.Name)

   

    swModel.ClearSelection2 True

  

    Dim y As Double

   

    y = viewHeight * 2 'start and end point of vertical section line.

    'swDrawing.CreateLine2 0#, SecLinePt1, 0, 0#, SecLinePt2, 0

    swDrawing.CreateLine2 0, y, 0, 0, -y, 0 'top line

    'swDrawing.CreateLine2 0, 0, 0, 0, -y, 0 'bottom line

   

    Dim ViewPosW As Double, ViewPosH As Double

    ViewPosW = sheetwidth * 0.666

    ViewPosH = vPosition(1)

    'create section view

    Set swView = swDrawing.CreateSectionViewAt5(ViewPosW, ViewPosH, 0, viewName, 1, (excludedComponents), 0)

    suffix = i * 2

    boolstatus = swDrawing.ActivateView("DrawingView" & suffix)

   

   

    boolstatus = swModel.Extension.SelectByID2(swView.Name, "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

    viewName = Chr(Asc(viewName) + 1)

   

   

    swDrawing.InsertModelAnnotations3 3, 1212425, False, True, False, False

   

   

Next

swDrawing.ClearSelection2 True

swDrawing.InsertModelAnnotations3 3, 1212425, True, True, False, False

At any given attempt, either the instance of bolded text within the For loop or the instance outside of it is commented and inactive.

What's happening:

  1. The instance inside the For loop as written produces the best result. The flag for eliminating duplicate dimensions is set to True and the flag for applying the dimensions to 'All views' is set to False, but the dimensions are duplicated in each view. Is this due to the use of multiple configurations?
  2. If the duplicate flag is set to False, only the first section view receives the dimensions.
  3. If the 'All views' flag is set to True, only the first section view receives the dimensions.
  4. The instance outside of the For loop only applies the dimensions to the first section view, regardless of the options chosen.

I can upload the example assembly being used if needed. Not included in the copy/paste is the preliminary setup of the drawing size, model selection, etc, as that all seems to be working fine and is pretty standard.

Any help would be greatly appreciated!

SolidworksApi macros