6 Replies Latest reply on Sep 29, 2016 9:00 PM by Duncan M.

    ModifyDefinition not making changes

    Duncan M.

      I am try to modify the thickness of a lofted bend.

      For my example macro, I first select the lofted bend, and then run it.

       

      I get the definition of the feature, change the thickness value, and then call ModifyDefinition.

       

      Nothing changes in the part, and when I call getDefinition again I can see that nothing has changed in code either.

       

      Option Explicit

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swModelDocExt As SldWorks.ModelDocExtension

      Dim swSelMgr As SldWorks.SelectionMgr

      Dim swFeat As SldWorks.Feature

      Dim featName As String, featType As String

       

      Sub main()

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

      Set swSelMgr = swModel.SelectionManager

      Set swModelDocExt = swModel.Extension

       

      ' Get the selected feature

      Set swFeat = swSelMgr.GetSelectedObject6(1, -1)

      Dim lbfd As SldWorks.LoftedBendsFeatureData

      Set lbfd = swFeat.GetDefinition

       

      Debug.Print "Thickness: " & lbfd.Thickness

      lbfd.Thickness = 0.01

      Dim bRet As Boolean

      bRet = swFeat.ModifyDefinition(lbfd, swModel, Nothing): Debug.Assert bRet

       

      ' Debug messages follow:

      ' This is my changed thickness:

      Debug.Print "Thickness: " & lbfd.Thickness

       

      '  See what the feature sees as the thickness:

      Set lbfd = swFeat.GetDefinition

      ' It shows the original thickness therefore modifydefinition did not work.

      Debug.Print "Thickness: " & lbfd.Thickness

       

      End Sub