Jump to content

Manual/automatic Changelog.txt!


Recommended Posts

Posted

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!

Posted

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.

Posted

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.

Posted

can anyone move this thread to the LISP forum?

Posted

Thx, for moving this thread.

 

I looked into LISP and I think I'm not cut out for this kind of stuff :cry:.

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???:lol:

Posted

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

Posted

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

-------------------------------------------

Posted

it also overwrites the previous log! when I start te lisp for the second time.

Posted

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)

Posted
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.

Posted

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!:D)

Posted

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)

Posted

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!

Posted

Enjoy your vacation mate, hope this works out for you :)

 

Lee

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...