1 Reply Latest reply on Sep 15, 2011 2:30 PM by Deepak Gupta

    Adding text to a drawing

    Rob Jensen

      I'm in the need of a macro that will insert text into a drawing.


      The macro below works(copyied from the forum), but I need to change the font and make it bold.  I also need the user to pick the insertion point (which i can't figure out) I tried the getinsertionpoint, but for whatever reason it doesn't work.


      I have to believe that someone out there has a macro that you pick a spot on a drawing, and it inserts the text.  That's all I need.


      Appreciate any help....Thanks...Rob


      Sub main()

      Dim swApp As SldWorks.SldWorks

      Dim Part As ModelDoc2

      Dim Annotation As Annotation

      Dim Note As Note

      Dim boolstatus As Boolean

      Dim longstatus As Long

      Dim myNote As Object
      Dim myAnnotation As Object
      Dim myTextFormat As Object

      Set swApp = CreateObject("SldWorks.Application")

      Set Part = swApp.ActiveDoc

      Set myNote = Part.InsertNote("ITAR") ' Add note annotation and link it to custom property "Test"
      If Not myNote Is Nothing Then
         myNote.Angle = 0
         boolstatus = myNote.SetBalloon(0, 0)
         Set myAnnotation = myNote.GetAnnotation()
         If Not myAnnotation Is Nothing Then
            longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swNO_LEADER, 0, True, False, False, False)
            boolstatus = myAnnotation.SetPosition(0#, 0#, 0#) ' Set the position of note to 0, 0, 0
            boolstatus = myAnnotation.SetTextFormat(0, False, myTextFormat)

         End If
      End If
      Part.ClearSelection2 True
      End Sub