TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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)?
-
look into strcat.
-
Look up DIESEL.
-
How about recursion with a timer?
-
I wonder if that would begin to slow his computer down.
-
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.
;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
-
It would probably be like a memory leak.
:twisted:
-
Observation
((= "11" daysfx) "th");determine the day suffix
((= "12" daysfx) "th")
((= "13" daysfx) "th")
Are not needed
-
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.
-
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:
-
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.
-
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:
-
Ok ... this is a VBA app so ....
In a new module paste the following code
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
Interaction.InputBox("Please enter new name for AutoCAD application")
and replace it with a string enclosed in quotes.. like so...
Sub SetText()
Dim RetVal As Long
RetVal = SetWindowText(Application.HWND, "Dommy2HottyCAD"))
End Sub
-
Thanks Keith...works like a charm!
-
Glad you like ... I also have one to change the Icon ...
-
Ok ... this is a VBA app so ....
In a new module paste the following code
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
Interaction.InputBox("Please enter new name for AutoCAD application")
and replace it with a string enclosed in quotes.. like so...
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