Attila The Gel Posted July 29, 2009 Posted July 29, 2009 Hello how is everyone here? its been a while for me sinds I posted here so it was about time to ask something/ ;-) I would like to keep a simple change log for my drawings. and I was thinking to do it in a .txt file for each drawing. a small description of the editing made after I'm done with it. not a huge problem to do it manualy... But is it possible to make the .txt file pop up when I hit save after I close a drawing. Lets say I'm working on xyz.dwg and I'm done with it for today and close save. auto cad automatically opens/creates xyz.txt in the same folder so I can type in what I changed in a short description with the date etc... I know auto cad keeps log files of your commands so I was wondering maybe it can do this to. perhaps with a lisp or so? hope I explained good! Quote
Lee Mac Posted July 29, 2009 Posted July 29, 2009 I think this would get a better response in the LISP forum. But yes, I believe this can be done with a reactor based LISP. Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 Thx, Good to hear that it could be possible to do this. Not good because I don't know how to work with LISP. Is there any way someone could help me out? I don't have any idea if its easy or hard to write a lisp for this. Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 can anyone move this thread to the LISP forum? Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 Thx, for moving this thread. I looked into LISP and I think I'm not cut out for this kind of stuff . Maybe if someone could push me into the right direction? Should the first step be to make autocad: 1- open the .txt together with the drawing or to create the .txt file if it doesn't exist yet. this way I can update the log file while I draw. 2- make/create a .txt file after I hit close. I think the first one is going to be the easiest to write and to work with. and if possible could the lisp automatically add a dashed line and 2 or 3 empty paragraphs on each side when the .txt file opens? (the last edit should be in the beginning of the file.)(and maybe the date and editing time) I feel like I'm asking to much here??? Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Hey Attila, Try this for starters: (defun c:LogON () (vl-load-com) (if (setq *log# (getfiled "Select Log File" (if *log# *log# "") "txt" 9)) (if (not *r#log) (progn (setq *r#log (vlr-command-reactor nil (list (cons :vlr-CommandWillStart 'logCom)))) (princ "\n<<- Reactor Initiated ->>"))) (princ "\n*Cancel*")) (princ)) (defun logCom (Call rArg / file) (cond ((not (wcmatch (car rArg) "*SAVE*")) (setq file (open *log# "a")) (write-line (car rArg) file) (close file)) (t (startapp "notepad" *log#))) (princ)) (defun c:LogOFF () (if *r#log (progn (vlr-remove *r#log) (setq *r#log nil) (princ "\n<<- Reactor Deactivated ->>"))) (princ)) Instructions for running: type LogON to start the reactor, and select a txt file, or create a new one. Try some commands, draw stuff. hit save. Type LogOFF to deactivate the reactor. Lee Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 Thats a nice start indeed! the .txt pops up. Its not necessary for me to save the commands. something like this is enough for me! [i](manually write a small description after date time and separation line automatically inserted)[/i] Made changes to parts 1-3-4-12: due to client request! holes where 6mm diameter now they are 8mm. 30/07/09[i] (automatically add date)[/i] 00.15 [i](automatically add edit time)[/i] -------------------------------------------[i] (automatically add line)[/i] Made part 14 thicker by 1mm to provide better stability. 29/07/09 00.10 ------------------------------------------- Older description of editing older date older edit time ------------------------------------------- Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Ahh, I see I have done too much I will edit my code Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 it also overwrites the previous log! when I start te lisp for the second time. Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 How about: (defun c:LogON () (vl-load-com) (if (setq *log# (getfiled "Select Log File" (if *log# *log# "") "txt" 41)) (if (not *r#log) (progn (setq *r#log (vlr-command-reactor nil (list (cons :vlr-CommandWillStart 'logCom)))) (princ "\n<<- Reactor Initiated ->>"))) (princ "\n*Cancel*")) (princ)) (defun logCom (Call rArg / file) (cond ((wcmatch (car rArg) "*SAVE*") (setq file (open *log# "a")) (write-line (pad "" 45 45) file) (close file) (startapp "notepad" *log#))) (princ)) (defun c:LogOFF () (if *r#log (progn (vlr-remove *r#log) (setq *r#log nil) (princ "\n<<- Reactor Deactivated ->>"))) (princ)) (defun Pad (Str Chc Len) (while (< (strlen Str) Len) (setq Str (strcat Str (chr Chc)))) Str) Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 it also overwrites the previous log! when I start te lisp for the second time. You needn't start the lisp each time, it is a reactor, just one run per session. And it should overwrite the file - it opens it to append. Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 Where getting closer Lee! it works fine with just one small problem or 3 Is it possible to add: 1 empty line on both side separation. and I would like to keep the last edit in the begin of the file so when I have 100 log days, day 1 would be way down in the file and day 100 in the first log in the file. thx so far LEE (I find you very genially!) Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Ok. I have added the extra lines between the revisions. Now, as the for reversing. Write-line cannot write the lines backwards, so I have had to read the whole file, add the extras, and re-write the file. This means that when you start for the first time, the file must have something in it to start with. Lee (defun c:LogON () (vl-load-com) (if (setq *log# (getfiled "Select Log File" (if *log# *log# "") "txt" 41)) (if (not *r#log) (progn (setq *r#log (vlr-command-reactor nil (list (cons :vlr-CommandWillStart 'logCom)))) (princ "\n<<- Reactor Initiated ->>"))) (princ "\n*Cancel*")) (princ)) (defun logCom (Call rArg / file nl lst) (setq lst '()) (cond ((wcmatch (car rArg) "*SAVE*") (setq file (open *log# "r")) (while (setq nl (read-line file)) (setq lst (cons nl lst))) (close file) (setq lst (append (list "" "" (pad "" 45 45) "") (reverse lst))) (setq file (open *log# "w")) (mapcar (function (lambda (x) (write-line x file))) lst) (close file) (startapp "notepad" *log#))) (princ)) (defun c:LogOFF () (if *r#log (progn (vlr-remove *r#log) (setq *r#log nil) (princ "\n<<- Reactor Deactivated ->>"))) (princ)) (defun Pad (Str Chc Len) (while (< (strlen Str) Len) (setq Str (strcat Str (chr Chc)))) Str) Quote
Attila The Gel Posted July 30, 2009 Author Posted July 30, 2009 Ill give this a try at home! your help is much apriciated Lee! I'm going on vacation for 3 weeks! so its possible you won't here from me for awile! thx again and see you tomorrow or in 3weeks! Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Enjoy your vacation mate, hope this works out for you Lee 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.