Look at this code, please

Discussion in 'AutoCAD' started by DeFuN, Dec 25, 2003.

  1. DeFuN

    DeFuN Guest

    (defun ACADtime ( )
    (setq ti
    (menucmd "M=$(edtime,$(getvar,DATE),HH:MM:SS)"))
    (setq dt (menucmd "M=$(edtime,$(getvar,DATE),DD/MO/YY)"))
    (setvar "modemacro" (strcat ti dt ))
    )
    (ACADtime)

    The code to show current time at status bar. But only the time when the code loaded displayed.
    How to display real-time ?
     
    DeFuN, Dec 25, 2003
    #1
  2. DeFuN

    mataeux Guest

    (setvar "MODEMACRO" "$(edtime,$(getvar,DATE),DD/MO/YY)")

    review your online documentation
     
    mataeux, Dec 26, 2003
    #2
  3. DeFuN

    ECCAD Guest

    For real time, you need to repeatedly execute. You could try using the On Timer (VB), and rebuild the ACADtime function in VB.
    Bob
     
    ECCAD, Dec 27, 2003
    #3
  4. DeFuN

    DeFuN Guest

    Sory for not clear question. I mean : Show a clock on acad status bar (like the clock in windows tray).
    In oder to I can view CURRENT time when acad is in "Clean Screen mode".

    Here is my last code:
    (defun clock ( )
    (setvar "modemacro"
    (strcat
    "$(substr,$(getvar,CDATE),10,2)" ":" "$(substr,$(getvar,CDATE),12,2)" " "
    "$(substr,$(getvar,CDATE),7,2)" "/" "$(substr,$(getvar,CDATE),5,2)" "/" "$(substr,$(getvar,CDATE),1,4 )" " "
    )
    )
    )
    (clock)

    ;==============

    It only update the current time when I do anything in acad screen ( ex : select object ...)
    How the time update automaticallly ?
     
    DeFuN, Dec 27, 2003
    #4
  5. DeFuN

    ECCAD Guest

    I think I understand - you want a 'ticking' clock shown in the Status bar. But, executing the function (once) just shows present time. You will need to call this function (over and over), in order to simulate a real clock. So, you need to have a (program) running inside AutoCAD, that keeps on re-running itself. In Visual Basic, you can set a Timer to time out, display the data, then start to time again for the next cycle.
    I hope this makes sense.
    Lisp function just runs (once), unless you manuall call it again or load it again.
    Bob
     
    ECCAD, Dec 27, 2003
    #5
  6. DeFuN

    DeFuN Guest

    Thanks Bob, you know exactly what I want.
    But I only know LISP language.
    Could you so kind give me the VB routine to do that.
    Hope your gift.
    Happy holliday :)
     
    DeFuN, Dec 27, 2003
    #6
  7. You can't use the status bar to create a clock, or at least
    one that is going to tick like a clock. The status line is not
    updated on a regular basis, only after input is supplied or
    other user actions performed.

    Hence, your clock isn't going to "tick".

    What's wrong with showing the time in the task tray?
     
    Tony Tanzillo, Dec 27, 2003
    #7
  8. DeFuN

    ECCAD Guest

    Public Sub Do_Time()
    Dim PauseTime, Start
    On Error Resume Next
    PauseTime = 1 ' Set duration.
    Start = Timer ' Set start time.
    Do While Timer < Start + PauseTime
    DoEvents ' Yield to other processes.
    Call Update_Time
    Loop
    End Sub


    Public Sub Update_Time()
    Dim MyTime
    Dim sysVarName As String
    Dim sysVarData As Variant

    MyTime = Str(Time)
    sysVarName = "MODEMACRO"
    sysVarData = MyTime
    ThisDrawing.SetVariable sysVarName, sysVarData

    Call Do_Time ' recursive

    End Sub
     
    ECCAD, Dec 27, 2003
    #8
  9. DeFuN

    ECCAD Guest

    I agree with Toni, probably better to use the Task Tray Timer.
    Bob
     
    ECCAD, Dec 27, 2003
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.