Macro to create Flat Pattern configurations in .SLDDRW

Hello All,

I am new and excited to learn about SolidWorks API and creating Macros.  I am currently working with a sheet metal part with bends and many configurations. The macro starts in .SLDPRT and a .SLDDRW template will appear. The part will be pulled from model view and flat pattern view is created along with a SM-Flat-Pattern for every configuration in part. After a few records and research in the forums, this is where I currently am. The DWG Template appears, but the part does not appear in the .SLDDRW.  Your help is much appericated.

Dim swApp               As SldWorks.SldWorks

Dim swModel             As SldWorks.ModelDoc2

Dim swDraw              As SldWorks.DrawingDoc

Dim swPart              As IDrawingDoc

Dim sConfigName         As String

Dim vConfs              As Variant

Dim i                   As Integer

Dim bView               As Boolean

Dim bRebuild            As Boolean

Sub Main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

Dim FilePath As String

Dim PathSize As Long

Dim PathNoExtension As String

Dim NewFilePath As String

FilePath = swModel.GetPathName()

PathSize = Strings.Len(FilePath)

PathNoExtension = Strings.Left(FilePath, PathSize - 6)

NewFilePath = PathNoExtension + sConfigName & ".DWG"

    Set swPart = swApp.NewDocument("Z:\Solidworks\Current\templates\CBC B SIZE.drwdot", 0, 0, 0)

    Set swView = swPart.CreateDrawViewFromModelView3(NewFilePath, "*Right", 0, 0, 0)

    bView = swPart.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

    bView = swPart.ActivateView("Drawing View1")

    bView = swPart.ActivateSheet("Sheet1")

    vConfs = swModel.GetConfigurationNames()

   

    For i = 0 To UBound(vConfs)

        sConfigName = vConfs(i)

       

        bView = swPart.ChangeRefConfigurationOfFlatPatternView(NewFilePath, sConfigName)

        bRebuild = swModel.ForceRebuild3(False)

    Next i

End Sub

SolidworksApi macros