MikeP Posted June 3, 2009 Posted June 3, 2009 Is there a way to access a variable that can easily change the color of the command line. what I am trying do is create a timer. this timer will help me track the amount of time on a given job. when the timer is active, I want the command line to be green or maybe white. but when the timer is off, I want the command line to become red. this way, I wont forget to turn on or off the timer. (defun c:toff (/ time)(command "time" "off" "") (princ) ) (defun c:ton (/ time) (command "time" "on" "") (princ) ) (defun c:tres (/ time) (command "time" "reset" "") (princ) ) Quote
David Bethel Posted June 3, 2009 Posted June 3, 2009 I'd look into MODEMACRO for a way to show the timer on/off status display. Hopefully it hasn' been changed much or discontinued over the years. -David Quote
MikeP Posted June 3, 2009 Author Posted June 3, 2009 I'd look into MODEMACRO for a way to show the timer on/off status display. Hopefully it hasn' been changed much or discontinued over the years. -David I use mode macro now. its used to show my name on the bottom of the screen lol. but how do you make it change the color of the command line Quote
Lee Mac Posted June 3, 2009 Posted June 3, 2009 (edited) Give this a shot: Call with r,g,b colours ;; Command Line Colour Change by Lee Mac (defun CmdCol (r g b) (vl-load-com) (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b)))) ;; Test Function (defun c:test () (cmdcol 0 255 0) (princ)) Edited July 3, 2019 by Lee Mac Quote
MikeP Posted June 3, 2009 Author Posted June 3, 2009 Give this a shot: Call with r,g,b colours [i];; Command Line Colour Change by Lee McDonnell[/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] CmdCol [b][color=RED]([/color][/b]r g b[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-TextWinBackgrndColor[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Display[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Preferences[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] r [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]256[/color][/b] g[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]65536[/color][/b] b[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [i];; Test Function[/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cmdcol [b][color=#009900]0[/color][/b] [b][color=#009900]255[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] you never fail to help me out:D. now how can i set it so that every new drawing opens as default of time off (red) Quote
Lee Mac Posted June 3, 2009 Posted June 3, 2009 (edited) You could chuck this in your ACADDOC.lsp - I have made it into a toggle ;; Command Line Colour Change by Lee Mac (defun CmdCol (r g b) (vl-load-com) (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b)))) (CmdCol 255 127 127) (defun c:Timer () (vl-load-com) (cond ((not *TimeFlag*) (vl-cmdf "_.time" "_R" "_ON" "") (CmdCol 191 255 127) (setq *TimeFlag* T)) (t (vl-cmdf "_.time" "_OFF" "") (CmdCol 255 127 127) (setq *TimeFlag* nil))) (princ)) Edited July 3, 2019 by Lee Mac Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 awsome works great. I now have it so the F12 button toggles it. I cant figure what I need to add to make it display the "Elapsed timer" time in the command line when I toggle it on or off. You could chuck this in your ACADDOC.lsp - I have made it into a toggle ;; Command Line Colour Change by Lee McDonnell (defun CmdCol (r g b) (vl-load-com) (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b)))) (CmdCol 255 127 127) (defun c:Timer () (vl-load-com) (cond ((not *TimeFlag*) (vl-cmdf "_.time" "_R" "_ON" "") (CmdCol 191 255 127) (setq *TimeFlag* T)) (t (vl-cmdf "_.time" "_OFF" "") (CmdCol 255 127 127) (setq *TimeFlag* nil))) (princ)) Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 Can you help me out. Id like to lean more into lisp. I sort of understand what you are doing with this code, but I have no clue when it comes down what is happening line by line. Like what is this " (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b))))" Could you give me a line by line explanation, of what is going on here. Sorry to be a pain in the ass:oops:. You could chuck this in your ACADDOC.lsp - I have made it into a toggle ;; Command Line Colour Change by Lee McDonnell (defun CmdCol (r g b) (vl-load-com) (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b)))) (CmdCol 255 127 127) (defun c:Timer () (vl-load-com) (cond ((not *TimeFlag*) (vl-cmdf "_.time" "_R" "_ON" "") (CmdCol 191 255 127) (setq *TimeFlag* T)) (t (vl-cmdf "_.time" "_OFF" "") (CmdCol 255 127 127) (setq *TimeFlag* nil))) (princ)) Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 Hey Lee, I have another challenge for you. How can this be made so that the timer turns off if don't use any commands after a given amount of time. I don't think it can see windows idle status, like how a screen saver works. but it should be able to know if Ive used a command in the last 30 seconds or not. Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 Hey Lee, I have another challenge for you. How can this be made so that the timer turns off if don't use any commands after a given amount of time. I don't think it can see windows idle status, like how a screen saver works. but it should be able to know if Ive used a command in the last 30 seconds or not. You don't ask for much Mike.... Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 You don't ask for much Mike.... lol. Lee your the man! If I knew lisp well enough to do everything my imagination can come up with, I wouldn't show up to work anymore, because Id write a lisp to create all my drawings for me. lol Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 (edited) Mike, you'll have fun with this one ; Timer Reactor LISP by Lee Mac -- 04.06.2009 (vl-load-com) (defun c:TRON () (if (not save:reactor) (setq save:reactor (vlr-dwg-reactor "Save Complete" '((:vlr-savecomplete . timer))))) (setq *time:flag* (getvar "MILLISECS")) (princ "\n<< TIMER INITIATED >>") (CmdCol 191 255 127)) ;; Command Line Colour Change by Lee Mac (defun CmdCol (r g b) (vl-load-com) (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) (+ r (* 256 g) (* 65536 b)))) (defun timer (reac args / secs mins) (if *time:flag* (progn (setq secs (/ (- (getvar "MILLISECS") *time:flag*) 1000.) mins (fix (/ secs 60.)) secs (rem secs 60.)) (setvar "MODEMACRO" (strcat "Elapsed Time: " (rtos mins 2 0) " mins " (rtos secs 2 0) " secs."))))) (defun c:TROFF () (princ (strcat "\n<< TIMER DEACTIVATED >>\n" (getvar "MODEMACRO"))) (setvar "MODEMACRO" ".") (CmdCol 255 255 255) (if save:reactor (progn (vlr-remove save:reactor) (setq save:reactor nil))) (if *time:flag* (setq *time:flag* nil)) (princ)) Type TRON to turn it on and TROFF to turn it off. Edited July 3, 2019 by Lee Mac Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 How long do I have to wait before it turns off, it looks like 60 seconds? Will this only work if loaded in the acad2009doc.lsp? where does it display the time? I dont see it on the bottom left corner where the mode macro is. It just removes what i already had there which was my name. Mike, you'll have fun with this one [i][color=#990099]; Timer Reactor LISP by Lee McDonnell -- 04.06.2009[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:TRON [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] save:reactor[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] save:reactor [b][color=RED]([/color][/b][b][color=BLUE]vlr-dwg-reactor[/color][/b] [b][color=#ff00ff]"Save Complete"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b]:vlr-savecomplete . timer[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *time:flag* [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"MILLISECS"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<< TIMER INITIATED >>"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]CmdCol [b][color=#009900]191[/color][/b] [b][color=#009900]255[/color][/b] [b][color=#009900]127[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Command Line Colour Change by Lee McDonnell[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] CmdCol [b][color=RED]([/color][/b]r g b[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-TextWinBackgrndColor[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Display[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Preferences[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] r [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]256[/color][/b] g[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]65536[/color][/b] b[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] timer [b][color=RED]([/color][/b]reac args [b][color=BLUE]/[/color][/b] secs mins[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] *time:flag* [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] secs [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"MILLISECS"[/color][/b][b][color=RED])[/color][/b] *time:flag*[b][color=RED])[/color][/b] [b][color=#009999]1000.[/color][/b][b][color=RED])[/color][/b] mins [b][color=RED]([/color][/b][b][color=BLUE]fix[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] secs [b][color=#009999]60.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] secs [b][color=RED]([/color][/b][b][color=BLUE]rem[/color][/b] secs [b][color=#009999]60.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"MODEMACRO"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"Elapsed Time: "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] mins [b][color=#009900]2[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]" mins "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] secs [b][color=#009900]2[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]" secs."[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:TROFF [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n<< TIMER DEACTIVATED >>\n"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"MODEMACRO"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"MODEMACRO"[/color][/b] [b][color=#ff00ff]"."[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]CmdCol [b][color=#009900]255[/color][/b] [b][color=#009900]255[/color][/b] [b][color=#009900]255[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] save:reactor [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlr-remove[/color][/b] save:reactor[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] save:reactor [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] *time:flag* [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *time:flag* [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Type TRON to turn it on and TROFF to turn it off (duh...) Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 Sorry, I shoud've explained a bit more TRON will turn on a reactor that will react to the "save" command. Elapsed time will be displayed at MODEMACRO. TROFF will switch off the reactor and display the total elapsed time. Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 Sorry, I shoud've explained a bit more TRON will turn on a reactor that will react to the "save" command. Elapsed time will be displayed at MODEMACRO. TROFF will switch off the reactor and display the total elapsed time. ok now i get it. But you seemed to create an additional timer to what acad has. It would be great if it could work with my toggled F12 (timer on/off) I think I like the toggled one better though. I have the F12 working great. But if the modemacro can be incorporated with it, that would be awsome. that would be just fine for me. I just want it displaying the time when F12 turns the timer off. Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 ok now i get it. But you seemed to create an additional timer to what acad has. It would be great if it could work with my toggled F12 (timer on/off) I think I like the toggled one better though. I have the F12 working great. But if the modemacro can be incorporated with it, that would be awsome. that would be just fine for me. I just want it displaying the time when F12 turns the timer off. I just get a bit carried away with reactors I'll see what I can do with the timer toggle Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 I notice earlier in the thread that you wanted an explanation of the code - I'll try my best to explain: (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) <colour>) I am getting hold of the entry that holds the colour for the command line background and I need to give it a color. (+ r (* 256 g) (* 65536 b))) The colour that needs to be supplied to the variable is an OLE_COLOR, and is a 32-bit entry, so I need to convert the RBG colour in order to input it. Hope this helps, Lee Quote
Lee Mac Posted June 4, 2009 Posted June 4, 2009 Mike, when using the toggle, surely the Elapsed time appears on the command line (or when you hit F2)? Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 I notice earlier in the thread that you wanted an explanation of the code - I'll try my best to explain: (vla-put-TextWinBackgrndColor (vla-get-Display (vla-get-Preferences (vlax-get-acad-object))) <colour>) I am getting hold of the entry that holds the colour for the command line background and I need to give it a color. (+ r (* 256 g) (* 65536 b))) The colour that needs to be supplied to the variable is an OLE_COLOR, and is a 32-bit entry, so I need to convert the RBG colour in order to input it. Hope this helps, Lee that makes perfect sense. I wouldn't be able to create it myself, but it definitely understand it. Quote
MikeP Posted June 4, 2009 Author Posted June 4, 2009 Mike, when using the toggle, surely the Elapsed time appears on the command line (or when you hit F2)? all I get when I hit f12 is "_timer" if I hit F2, it just opens up the new window command line with no additional info. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.