0 Replies Latest reply on Jul 15, 2014 5:15 AM by Yong Ning

    How to update the result of a sketchText statement?

    Yong Ning

      01.jpg

       

      use follow code, don't update result.

      **************************************************

      The need to open the sketch feature with manually, and then double-click the sketchtext,

      to obtain the sketchtext  required result.

       

      For example, the original text is HG20592, into HG20592-2009.

      Must double-click(open) the sketch in feature tree, and then double-click the HG20592, can be changed to HG20592-2009

       

      ****************************************************

          SwModel.ForceRebuild3 False→ don't refresh sketchtext → text

       

      ***************************

      Private Sub ll2()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

        Dim SwSelMgr As SelectionMgr, SwFeat As Feature

          Set SwApp = GetObject(, "SldWorks.Application")

          Set SwModel = SwApp.ActiveDoc

       

       

          Set SwSelMgr = SwModel.SelectionManager

          Set SwFeat = SwModel.FeatureByName("草图1")

        Dim SwSketch As Sketch

          Set SwSketch = SwFeat.GetSpecificFeature2

        Dim vSkSegArr

          vSkSegArr = SwSketch.GetSketchSegments

        Dim SwSkText As SketchText, TxtForm As TextFormat

          For ii = 0 To UBound(vSkSegArr)

            ''

            Select Case vSkSegArr(ii).GetType

                  Case swSketchLINE

                      Set swSkLine = vSkSegArr(ii)

                  Case swSketchARC

                      Set swSkArc = vSkSegArr(ii)

                  Case swSketchELLIPSE

                      Set swSkEllipse = vSkSegArr(ii)

                  Case swSketchSPLINE

                      Set swSkSpline = vSkSegArr(ii)

                  Case swSketchTEXT

       

                      Set SwSkText = vSkSegArr(ii)

                      With SwSkText

                         Set TxtForm = .GetTextFormat

                         .Text = "HG20592-2009 法兰BL200-25 RF 质量10.2kg 兰州宁先生编制"

                      End With

                      With TxtForm

       

       

                         .WidthFactor = 0.5

                      End With

                      SwSkText.SetTextFormat False, TxtForm

                  Case swSketchPARABOLA

                      Set swSkParabola = vSkSegArr(ii)

                  Case Default

                      Debug.Assert False

              End Select

          Next ii

          SwModel.ForceRebuild3 False

       

      End Sub