0 Replies Latest reply on May 22, 2014 5:20 PM by Kevin Dean

    Unable to update a SketchText entity's "backwards" property

    Kevin Dean

      I have the following code to dynamically change the text within a sketch based on a spreadsheet value. This spreadsheet also drives whether that text should read forward or backwards. The SetTextFormat calls seem to do something -- you can see the text go from dark blue to light blue -- but the direction doesn't change. I've confirmed that the Backwards property has an initial value of False, so setting it to True should do the correct thing; nonetheless, I did try setting it to False instead, and that didn't have any effect either.


      What's also very strange is that when I record a macro of me changing the text direction within the GUI, the saved macro completely lacks any steps for that action...


      If it's any help, this text is an extruded boss.


      Thanks in advance for any insights you may have!



      Sub setEmbossedTxt(ByVal inpOrder As Order)


          Dim swFeature       As SldWorks.feature

          Dim swSketch        As SldWorks.sketch

          Dim textSegments    As Variant


          'Get the selected feature of the sketch text

          gTempModelDoc.Extension.SelectByID2 "Sketch176", "SKETCH", 0, 0, 0, False, 0, Nothing, 0

          Set swFeature = gTempModelDoc.SelectionManager.GetSelectedObject6(1, 0)

          Set swSketch = swFeature.GetSpecificFeature2


          'NB: You can  only put the sketch in edit mode after you have retrieved its object because EditSketch clears SolidWorks' selection list.



          textSegments = swSketch.GetSketchTextSegments


          textSegments(0).Text = inpOrder.EmbossedTxt

          textSegments(1).Text = inpOrder.Id


          If (inpOrder.Side = Left) Then

              Dim txtFormat As SldWorks.textFormat


              Set txtFormat = textSegments(0).GetTextFormat()

              txtFormat.BackWards = True

              textSegments(0).SetTextFormat False, txtFormat


              Set txtFormat = textSegments(1).GetTextFormat()

              txtFormat.BackWards = True

              textSegments(1).SetTextFormat False, txtFormat

          End If


          'Save the sketch

          gTempModelDoc.InsertSketch2 True



      End Sub