AnsweredAssumed Answered

circularpattern3 works in vba but not in vb6

Question asked by James Townzen on May 11, 2017
Latest reply on May 12, 2017 by Ivana Kolin

I have an SolidWorks assembly with 3 components:

     a ball bearing

     an inner ring

     an outer ring

What I want is to add a circular pattern within the bearing assembly:

 

I recorded a vba macro that works when ran within the open assembly, through the vba macro editor

but does not work within vb6.

 

I have other code that opens SolidWorks, open the parts (components), opens the bearing assembly

and changes some dimensions. These work but I can't get the circular pattern to build from vb6.

There are no error messages but nothing happens when I run the code below.

 

This is a list of declarations I tried.

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swSelMgr As SldWorks.SelectionMgr

Dim swPart As SldWorks.PartDoc

Dim swAssm As SldWorks.AssemblyDoc

Dim swConfg As SldWorks.Configuration

Dim swDraw As SldWorks.DrawingDoc

Dim swAnnotations As SldWorks.Annotation

Dim swConfigMgr As SldWorks.ConfigurationManager

Dim swConf As SldWorks.Configuration

Dim swDim As SldWorks.Dimension

Dim swFeat As SldWorks.Feature

Dim swFillPat As FillPatternFeatureData

Dim boolstatus As Boolean

Dim longstatus As Long

Dim longwarnings As Long

 

Code Body:

Private Sub Command6_Click()

Set swAssm = swApp.ActivateDoc("BearingAssembly")

     boolstatus = swPart.Extension.SelectByID2("Ball-1@BearingAssembly", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0)

     boolstatus = swPart.Extension.SelectByID2("Axis1", "AXIS", 0, 0, 0, True, 0, Nothing, 0)

swPart.ClearSelection2 True

     boolstatus = swPart.Extension.SelectByID2("Ball-1@BearingAssembly", "COMPONENT", 0, 0, 0, False, 1, Nothing, 0)

     boolstatus = swPart.Extension.SelectByID2("Axis1", "AXIS", 0, 0, 0, True, 2, Nothing, 0)

 

Set swFeat = swPart.FeatureManager.FeatureCircularPattern3(21, 0.299199300341886, False, "NULL", True, False)

     swPart.ClearSelection2 True

     swPart.ForceRebuild

End Sub

Code:\

 

Thanks for any suggestions

 

Jim Townzen

 

PS: I have Visual Basic 6 Pro Edition, SolidWorks 2016, Windows 7 64

The reason I'm using VB6 is to make a simple stand-a-lone program.

Outcomes