6 Replies Latest reply on May 4, 2017 10:50 AM by Liang Sun

    undo and rebuild

    Liang Sun

      Hi,

       

      I am using the solidworks api for VB.NET.

      I want to change a dimension of a model and then change it back to the original value.

       

       

      I try to use the undo mark but it doesn't seem to work.

      Whenever a dimension is changed, the model needs to be rebuilt to validate the change.

      However, it looks like to me that the rebuild operation will clear the undo list.

       

      Does anyone know whether my understanding is right and is there any solution to this?

      Thanks.

        • Re: undo and rebuild
          Deepak Gupta

          You can keep the value of the dimension in a string and then apply back the same value

            • Re: undo and rebuild
              Liang Sun

              Hi Deepak,

               

              Thanks for your reply.

              I know how to directly set the value back to the original one.

              I want to know if it is possible to do it using the undo mark because i think that will be efficient.

                • Re: undo and rebuild
                  Deepak Gupta

                  Well tried using Undo after rebuild and it worked as expected.

                    • Re: undo and rebuild
                      Liang Sun

                      Thanks for your effort, Deepak.

                       

                      I am working in an assembly environment (solidworks 2014).

                      Your reply reminds me to have a test in the part environment.

                      After the test, it seems to me that it works in the part environment but not in the assembly.

                      I am using the following code with swModel being partdoc or assmeblydoc.

                      Could you please  have a test in the assembly?

                      Cheers.

                        

                              Dim features As Object = swModel.FeatureManager.GetFeatures(False)

                              Dim swDispDim As DisplayDimension = Nothing

                              Dim swDim As Dimension = Nothing

                              Dim swFeat As Feature = Nothing

                       

                       

                              For j = 0 To UBound(features)

                                  swFeat = features(j)

                                  swDispDim = swFeat.GetFirstDisplayDimension()

                                  While Not swDispDim Is Nothing

                                      Exit For

                                  End While

                              Next

                       

                       

                              Echo(swFeat.Name)

                       

                       

                              swDim = swDispDim.GetDimension

                              Echo(swDim.GetValue2(""))

                       

                       

                              swDim.SetValue2(swDim.GetValue2("") + 5, 1)

                              swModel.EditRebuild3()

                       

                       

                              swModel.EditUndo2(1)

                              Echo(swDim.GetValue2(""))