AnsweredAssumed Answered

How to create a macro that inserts the current date (format:07SEP18) as a note in a drawing file?

Question asked by Kenneth Coutinho on Sep 7, 2018
Latest reply on Sep 7, 2018 by Kenneth Coutinho

Hey guys,

 

I'm just beginning to use macros to simplify my work.

A note needs to be added on some prototype drawings which mentions the current date.

I tried creating a macro by recording it and then trying to edit it but it was unsuccessful.

Kindly advise.

 

Sub main()

 

 

Set swApp = Application.SldWorks

 

 

Set Part = swApp.ActiveDoc

boolstatus = Part.ActivateView("Drawing View3")

boolstatus = Part.ActivateSheet("Sheet1")

Part.FONTBOLD True

Part.FontPoints 22

 

 

Dim myNote As Object

Dim myAnnotation As Object

Dim myTextFormat As Object

 

 

Set myNote = Part.InsertNote("<FONT color=0x000000ff><FONT size=22PTS style=B>FOR PROTO BUILD ONLY" + Chr(13) + Chr(10) + _

        "07SEP18")

If Not myNote Is Nothing Then

   myNote.LockPosition = False

   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.308895790590732, 0.339959288537549, 0)

 

 

      Set myTextFormat = Part.GetUserPreferenceTextFormat(0)

      myTextFormat.Italic = False

      myTextFormat.Underline = False

      myTextFormat.Strikeout = False

      myTextFormat.Bold = True

      myTextFormat.Escapement = 0

      myTextFormat.LineSpacing = 0.001

      myTextFormat.CharHeightInPts = True

      myTextFormat.TypeFaceName = "Arial Narrow"

      myTextFormat.WidthFactor = 1

      myTextFormat.ObliqueAngle = 0

      myTextFormat.LineLength = 0

      myTextFormat.Vertical = False

      myTextFormat.BackWards = False

      myTextFormat.UpsideDown = False

      myTextFormat.CharSpacingFactor = 1

      boolstatus = myAnnotation.SetTextFormat(0, False, myTextFormat)

   End If

End If

Part.ClearSelection2 True

Part.WindowRedraw

End Sub

Outcomes