6 Replies Latest reply on May 23, 2016 3:40 PM by Danny Bradford

    Linear Pattern Variable InsertVaryInstanceOverride is not taking

    Danny Bradford

      Greetings all,

      I am attempting to create a Linear Pattern and override a few of the spacings but no matter what I do it does not take. Can anyone point me in the correct direction?

       

      Solidworks 2015 SP02

       

      The boolstatus in the message box comes back True but it still does not alter the linear pattern.

       

      Code:

      swApp = GetObject(, "SldWorks.Application")

              swModel = swApp.ActiveDoc

              swAssembly = swModel

              swModel = swApp.ActiveDoc

              swAssembly = swModel

       

              swFeatureManager = swModel.FeatureManager

       

              boolstatus = swModel.Extension.SelectByID2("Axis1@" & orig_pin.Name2 _

                                                         & "@" & Assemblyname, "AXIS", 0, 0, 0, False, 2, Nothing, swSelectOption_e.swSelectOptionDefault)

              boolstatus = swModel.Extension.SelectByID2(orig_pin.Name2 & "@" & Assemblyname, "COMPONENT", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

       

              boolstatus = swFeatureManager.InsertVaryInstanceIncrement("Space Increment", 2, 2, 0, 0.0125)

       

              boolstatus = swFeatureManager.InsertVaryInstanceOverride("Space Increment", 2, 2, 0, 1, 1, 0.0549)

       

              MsgBox(boolstatus)

       

              swFeature = swFeatureManager.FeatureLinearPattern3(3, 0.0253, 0, 0, flip, False, "NULL", "NULL", False, True)

       

              errors = swModel.EditRebuild3()

        • Re: Linear Pattern Variable InsertVaryInstanceOverride is not taking
          Artem Taturevych

          Hi Danny,

           

          InsertVaryInstanceIncrement and InsertVaryInstanceOverride methods expect full name of the dimension as first parameter. So it should be something like Space Increment@Sketch1@Model.SLDPRT instead of Space Increment

           

          You may use macro recorder and select the dimension to see its full name.

           

          Thanks,

          Artem

          • Re: Linear Pattern Variable InsertVaryInstanceOverride is not taking
            Danny Bradford

            After several weeks of work off and on, I have reworked the code so that I am patterning a hole within a part instead of an assembly pattern. However I am still having a problem with the InsertVaryInstanceOverride option.

             

            Without this the pattern works no problem. I would like to force the values of each pattern instance instead of a continuous value.

             

            Also, the InsertVaryInstanceIncrement works! Unfortunately all this does it increases each distance for each instance by the given value so I must have the Override option operational to do what I want.

             

            Code thus far. I commented out the Increment option in the code, but it does work when uncommented.

             

                    Dim Part As ModelDoc2

                    Dim assy_name As String = Nothing

                    Dim feat_type As String = Nothing

                    Dim boolstatus As Boolean

                    Dim swFeature As IFeature

                    Dim the_hole As IEntity = orig_hole

                    Dim edge1 As Entity = l_edge

                    Dim i As Integer = 0

                    Dim k As Integer = 0

                    Dim swFeatureManager As FeatureManager

             

                    Part = swApp.ActiveDoc

             

                    boolstatus = Part.Extension.SelectByID2(select_string, "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

             

                    Part.ActivateSelectedFeature()

                    'MsgBox(boolstatus)

                    Part.ClearSelection2(True)

             

                    boolstatus = edge1.Select2(False, 1)

                    swFeatureManager = Part.FeatureManager

             

                    assy_name = orig_hole.Name & "@" & select_string

             

                    boolstatus = Part.Extension.SelectByID2(assy_name, "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

             

                    Try

             

                        'boolstatus = swFeatureManager.InsertVaryInstanceIncrement("Space Increment", 2, 2, 0, 0.08)

                        boolstatus = swFeatureManager.InsertVaryInstanceOverride("Space Increment", 2, 2, 0, 1, 1, 0.06)

             

                        swFeature = swFeatureManager.FeatureLinearPattern3(6, 0.02, 1, 0, True, False, "NULL", "NULL", False, True)

                    Catch ex As Exception

                        MsgBox(ex)

                    End Try

             

            Your time is most appreciated.