Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private pi As Double Private firstDraw As Boolean Private hourHand As Line2D Private minuteHand As Line2D Private secondHand As Line2D Sub MyTimer() Dim myView As DrawingView Set myView = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.ActiveView firstDraw = True pi = 4 * Atn(1) Dim interval As Double interval = TimeValue("0:00:01") / 2 Dim startTime As Date startTime = Now DrawFace myView, 50 Do If CDate(Now - startTime) > interval Then Debug.Print GetHourFraction(Now) DrawWatch myView, 50 startTime = Now End If Sleep 20 DoEvents Loop While True End Sub Sub DrawFace(myView As DrawingView, r As Double) Dim fact2D As Factory2D Set fact2D = myView.Factory2D Dim i As Long Dim coords() fact2D.CreateClosedCircle 0, 0, r * 1.1 fact2D.CreateClosedCircle 0, 0, r * 1.15 For i = 1 To 12 coords = Array(r * 0.9 * Cos(360 / 12 * i * pi / 180), r * 0.9 * Sin(360 / 12 * i * pi / 180)) fact2D.CreateClosedCircle coords(0), coords(1), 2 Next Dim digits() digits = Array("3", "6", "9", "12") ' digits = Array("III", "XI", "IX", "XII") Dim angledigits As Double ' get drawing text collection Dim drwTexts As DrawingTexts Set drwTexts = myView.Texts For i = 1 To 4 angledigits = pi / 2 - 360 / 4 * i * pi / 180 coords = Array(r * 0.7 * Cos(angledigits), -r * 0.7 * Sin(angledigits)) ' create letter Dim digit As DrawingText Set digit = drwTexts.Add(CStr(digits(i - 1)), coords(0), -coords(1)) ' get DrawingTextProperties object of a letter Dim textProp As DrawingTextProperties Set textProp = digit.TextProperties ' set text properties of a letter With textProp ' set letter mirror mode, do not let CATIA to perform auto flip of text .AnchorPoint = catMiddleCenter .Bold = True .FontName = "Monospac821 BT" .FontSize = 7 ' update text properties .Update End With Next End Sub Function GetHourFraction(t As Date) As Double ' 12 hours boundary Const BOUNDARY As Double = 0.5 Dim fraction As Double fraction = CDbl(t) - Int(t) If fraction <= BOUNDARY Then GetHourFraction = fraction / BOUNDARY Else GetHourFraction = (fraction - BOUNDARY) / BOUNDARY End If End Function Sub DrawWatch(myView As DrawingView, r As Double) Dim currTime As Date currTime = Now Dim currSecond As Long currSecond = Second(currTime) Dim currMinute As Long currMinute = Minute(currTime) Dim currHour As Long currHour = Hour(currTime) Dim angleSecond As Double angleSecond = pi / 2 - 360 / 60 * currSecond * pi / 180 Dim angleMinute As Double angleMinute = pi / 2 - 360 / 60 * currMinute * pi / 180 Dim angleHour As Double angleHour = pi / 2 - 360 * GetHourFraction(currTime) * pi / 180 Dim coordsSecond() coordsSecond = Array(r * Cos(angleSecond), r * Sin(angleSecond)) Dim coordsMinute() coordsMinute = Array(r * 0.8 * Cos(angleMinute), r * 0.8 * Sin(angleMinute)) Dim coordsHour() coordsHour = Array(r * 0.6 * Cos(angleHour), r * 0.6 * Sin(angleHour)) Dim fact2D As Factory2D Set fact2D = myView.Factory2D If secondHand Is Nothing Then Set secondHand = fact2D.CreateLine(0, 0, coordsSecond(0), coordsSecond(1)) Set minuteHand = fact2D.CreateLine(0, 0, coordsMinute(0), coordsMinute(1)) Set hourHand = fact2D.CreateLine(0, 0, coordsHour(0), coordsHour(1)) Else secondHand.SetData 0, 0, coordsSecond(0), coordsSecond(1) minuteHand.SetData 0, 0, coordsMinute(0), coordsMinute(1) hourHand.SetData 0, 0, coordsHour(0), coordsHour(1) End If If firstDraw Then ' get drawing doc selection Dim sel As Selection Set sel = CATIA.ActiveDocument.Selection ' Set sel = myView.Parent.Parent.Parent.Parent.Selection ' clear the selection sel.Clear sel.Add minuteHand ' change the visible width to the required value Dim visProp As VisPropertySet Set visProp = sel.VisProperties visProp.SetVisibleWidth 4, 0 sel.Clear sel.Add hourHand Set visProp = sel.VisProperties visProp.SetVisibleWidth 8, 0 sel.Clear End If firstDraw = False End Sub