TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dommy2Hotty on October 26, 2004, 01:34:33 PM

Title: Updating time on the status bar (modemacro command)
Post by: Dommy2Hotty on October 26, 2004, 01:34:33 PM
I wanted to put an updating time with the date in the status bar using the modemacro command.  I can get it to put the current date by using (getvar "cdate"), although I don't know how to format it.  How could I get it to update the time (if possible)?
Title: Updating time on the status bar (modemacro command)
Post by: daron on October 26, 2004, 01:36:30 PM
look into strcat.
Title: Updating time on the status bar (modemacro command)
Post by: Mark on October 26, 2004, 01:49:13 PM
Look up DIESEL.
Title: Updating time on the status bar (modemacro command)
Post by: whdjr on October 26, 2004, 01:54:43 PM
How about recursion with a timer?
Title: Updating time on the status bar (modemacro command)
Post by: daron on October 26, 2004, 01:55:35 PM
I wonder if that would begin to slow his computer down.
Title: Updating time on the status bar (modemacro command)
Post by: David Bethel on October 26, 2004, 01:58:20 PM
Here's some code from 1992-94.  I've used it faithfully for a long time.  I did however comment out the time date stuff as I thought a bit superfluous 'cause I have a clock on my desk.



Code: [Select]

;LDTOPS.LSP
;10/20/92  - Patrick Murphy, Applied Computing Services.
;12/08/94  - Corrected the date endings, finally.
;            Filename added to status line.
;Added C:RDA command as a bonus program, at bottom of file.

;Program to set MODEMACRO to show:
;the current Layer, DrawingName, Date, Time, Tablet, Ortho, Pspace and Snap.
;
;E.G.:  TEXT     C:\ACAD\DWGNAME Tue Oct 20th 7:35p   T Ortho P Snap
;
;I modified the MODE1.LSP file found in on page 120 and code on page 126
;of the AutoCAD R12 Customization Manual to arrive at this.
;
;Have this code loaded by the ACAD.LSP file and run with S::STARTUP.
;Once run, you can have it set to NIL later in S::STARTUP and free up
;a little memory.
;i.e. in your ACAD.LSP file:
;  (load "ldtops")     ;When ACAD.LSP loads, so would LDTOPS.LSP
;  ;if there isn't an S:STARTUP function already, you could use this:
;  (defun S::STARTUP ()
;   (ldtops)          ;this would run LDTOPS
;   (setq ldtops nil) ;this would free up a little memory -
;  )                  ;because MODEMACRO would already be set.
;

;----------------------------------------------------------------(ldtops)
(defun ldtops (/ daysfx dtst)
 (setvar "CMDECHO" 0)
 (setq daysfx (substr (rtos (getvar "CDATE") 2 4) 7 2)
  dtst daysfx
  daysfx      
 (cond
  ((= "11" daysfx) "th");determine the day suffix
  ((= "12" daysfx) "th")
  ((= "13" daysfx) "th")
  ((= "21" daysfx) "st")
  ((= "22" daysfx) "nd")
  ((= "23" daysfx) "rd")
  ((= "31" daysfx) "st")
  ((= "01" daysfx) "st")
  ((= "02" daysfx) "nd")
  ((= "03" daysfx) "rd")
  (T "th")))
  (setvar "modemacro"
   (strcat
   "$(substr,$(getvar,clayer),1,8)"
   "$(substr,        ,1,$(-,8,$(strlen,$(getvar,clayer)))) "
   "$(getvar,dwgname)"
 ;   "$(edtime,$(getvar,date), "
 ;  " "                         ;Had to call EDTIME twice because
 ;  "DDD MON D)"                ;I wanted the suffix for the day
 ;  daysfx                      ;(i.e. 'st') and if EDTIME was only
 ;  "$(edtime,$(getvar,date), " ;called once the suffix became one
 ;  "H:MMam/pm)"                ;of the EDTIME parameters, rather
   "  "                        ;than text on the status line.
 ;  "$(if,$(getvar,tabmode), T, )"
   "$(if,$(and,$(=,$(getvar,tilemode),0),$(=,$(getvar,cvport),1)), P, M)"
   "$(if,$(getvar,orthomode), Ortho, )"
   "$(if,$(getvar,snapmode), Snap)"
   " "
   "$(getvar,cmdnames)"
    " "))
 (setvar "CMDECHO" 0)
 (princ)
);defun LDTOPS




-David
Title: Updating time on the status bar (modemacro command)
Post by: whdjr on October 26, 2004, 01:58:42 PM
It would probably be like a memory leak.
 :twisted:
Title: Updating time on the status bar (modemacro command)
Post by: CAB on October 26, 2004, 03:12:42 PM
Observation
Code: [Select]
 ((= "11" daysfx) "th");determine the day suffix
  ((= "12" daysfx) "th")
  ((= "13" daysfx) "th")

Are not needed
Title: Updating time on the status bar (modemacro command)
Post by: Keith™ on October 26, 2004, 03:32:46 PM
You can readily do this in VBA if you would like I can post the entire code to do such a thing. I can also compile it into an executable that you run after you start AutoCAD and it will run in the background updating the time as needed... but it would be a lot more coding to make happen.
Title: Updating time on the status bar (modemacro command)
Post by: Dommy2Hotty on October 26, 2004, 03:48:18 PM
Thank you all for replies and suggestions...I think I'll just have it put our company name and the date...no time...I'll look up how to format the date and see if I can get it to work.  Thanks again! :twisted:
Title: Updating time on the status bar (modemacro command)
Post by: Keith™ on October 26, 2004, 04:10:26 PM
I have code to change the AutoCAD window name (not just the status bar) to whatever you want. You can put your company name there of you want.
Title: Updating time on the status bar (modemacro command)
Post by: Dommy2Hotty on October 26, 2004, 06:02:54 PM
Quote from: Keith
I have code to change the AutoCAD window name (not just the status bar) to whatever you want. You can put your company name there of you want.


Ooh...me like!...gimme! gimme! gimme! :twisted:
Title: Updating time on the status bar (modemacro command)
Post by: Keith™ on October 26, 2004, 08:23:53 PM
Ok ... this is a VBA app so ....
In a new module paste the following code
Code: [Select]

Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal HWND As Long, ByVal lpString As String) As Long

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, Interaction.InputBox("Please enter new name for AutoCAD application"))
End Sub


When you run the code it will request a new name which you can type in, then it will change the name to what you entered.

If you want to make it set to a preset value, simply remove this portion
Code: [Select]

Interaction.InputBox("Please enter new name for AutoCAD application")

and replace it with a string enclosed in quotes.. like so...
Code: [Select]

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, "Dommy2HottyCAD"))
End Sub
Title: Updating time on the status bar (modemacro command)
Post by: Dommy2Hotty on November 08, 2004, 06:03:43 PM
Thanks Keith...works like a charm!
Title: Updating time on the status bar (modemacro command)
Post by: Keith™ on November 09, 2004, 08:36:35 AM
Glad you like ... I also have one to change the Icon ...
Title: Updating time on the status bar (modemacro command)
Post by: ImaJayhawk on December 23, 2004, 10:36:21 AM
Quote from: Keith
Ok ... this is a VBA app so ....
In a new module paste the following code
Code: [Select]

Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal HWND As Long, ByVal lpString As String) As Long

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, Interaction.InputBox("Please enter new name for AutoCAD application"))
End Sub


When you run the code it will request a new name which you can type in, then it will change the name to what you entered.

If you want to make it set to a preset value, simply remove this portion
Code: [Select]

Interaction.InputBox("Please enter new name for AutoCAD application")

and replace it with a string enclosed in quotes.. like so...
Code: [Select]

Sub SetText()
 Dim RetVal As Long
 RetVal = SetWindowText(Application.HWND, "Dommy2HottyCAD"))
End Sub


What do I need to change to get this to work on ACAD 2002?  Thanks.



--ImaJayhawk