bgator220 Posted October 11, 2010 Posted October 11, 2010 Hey, is there anyway to store a variable in autocad. So that the next time autocad is opened, the lisp program is loaded and it can call a variable from the previous time it was ran? Is there anyway to have cad pre-load your lisp program when autocad is opened. Just to save the step of loading applications. Also, is there a lisp command to output the date and time? Thanks for you help! Quote
Small Fish Posted October 12, 2010 Posted October 12, 2010 (edited) is there anyway to store a variable in autocad. So that the next time autocad is opened, the lisp program is loaded and it can call a variable from the previous time it was ran? Look in the help file for system variables: USERR1, USERR2 etc Is there anyway to have cad pre-load your lisp program when autocad is opened. Just to save the step of loading applications. You can add a macro to your custom CUI so that it loads automatically whether using a pulldown or toolbar etc. You can also use the Acaddoc.lsp file (which you will need to create)and the Startup Suite in the appload dialog box. Also, is there a lisp command to output the date and time? Try this... ;----------------- ;Get time and date ;----------------- ;Get Date (defun c:GetDateTime ( / ) (setq d (rtos (getvar "CDATE") 2 6) yr (substr d 3 2);extract the year mo (substr d 5 2);extract the month day (substr d 7 2);extract the day );setq ;Get Time (setq d (rtos (getvar "CDATE") 2 6);extract the hour hr (substr d 10 2) m (substr d 12 2);extract the minute );setq (alert (strcat "Date: "(strcat day "/" mo "/" yr) "\nTime: "(strcat hr ":" m ) );strcat );alert (princ) );defun Edited October 12, 2010 by Small Fish Quote
Grant Posted October 12, 2010 Posted October 12, 2010 With your second point: In a predefind autocad directory or make one yourself in 'options - Files - Support file search path' Start a notepad file with the name 'acaddoc.lsp' Put: (defun s:: startup () (command "ucs" "world") ) (defun c:mco () (load "mymacro")) This will make sure everytime you open Autocad the drawings UCS will be 'world' and if you type 'mco' in the command line mymacro will run You could also make this file 'acad.lsp' and in 'options - system' there is a 'load acad.lsp with every drawing' - check this and the same thing will happen. With your third point: try typing 'setvar' 'enter' '?' 'enter' 'enter' and most of the variables for autocad come up and you will be able to call these (and change some if needed) for the date and time. Another one I use is: (setq daytext (menucmd "m=$(edtime,$(getvar, date),dddd)")) (setq monthtext (menucmd "m=$(edtime,$(getvar, date),month)")) (setq yeartext (menucmd "m=$(edtime,$(getvar, date),yyyy)")) For your first point: Can't think of a good way of doing that one except writing a script file within your lisp routine to store that variable and look for that script file when the lisp routine is re-run Hope this helps Quote
Lee Mac Posted October 12, 2010 Posted October 12, 2010 For the date: (defun LM:FormatDate ( format ) (menucmd (strcat "m=$(edtime,$(getvar,DATE)," format ")")) ) Where format is of the form: D: day 4 DD: day with leading zero 04 DDD: day of week short Mon DDDD: day of week long Monday M: month 6 MO: month with leading zero 06 MON: month name short Jun MONTH: month name long June YY: year two places 89 YYYY: year four places 1989 H: hour 7 HH: hour with leading zero 07 MM: minutes 30 SS: seconds 30 MSEC: milliseconds 300 AM/PM: upper case AM or PM AM am/pm: lower case am or pm am A/P: upper case A or P A a/p: lower case a or p a Some Examples: (LM:FormatDate "DD.MO.YYYY HH:MM:SS") (LM:FormatDate "DDDD DD MONTH YYYY") (LM:FormatDate "H:MM AM/PM") (LM:FormatDate "DDDD DD/MO/YYYY HH:MM:SS:MSEC") 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.