(defun c:FileHistory (/)
;Get time and date
;Afralisp
(setq d (rtos (getvar "CDATE") 2 6)
yr (substr d 1 4) ;extract the year
mo (substr d 5 2) ;extract the month
dy (substr d 7 2) ;extract the day
hr (substr d 10 2);extract the hour
m (substr d 12 2);extract the minute
Sdate (strcat "Save Date: "(strcat dy "/" mo "/" yr))
Stime (strcat " Time: "(strcat hr ":" m ))
SUser (strcat " User: "(getvar "loginname"))
SStr (strcat Sdate Stime SUser)
)
(if ()
(progn
(setq Tpt )
(maketext SStr Tpt 4000)
)
(Progn
(alert (strcat "Pick a point to Insert file history"))
(setq Tpt (getpoint))
(maketext SStr Tpt 4000)
)))
(defun maketext (str pt ht )
(entmakex (list (cons 0 "TEXT") ;***
(cons 1 str) ;* (the string itself)
(cons 6 "BYLAYER") ; Linetype name
(cons 7 (getvar "TEXTSTYLE")) ;* Text style name, defaults to STANDARD, current
(cons 8 (getvar "CLAYER")) ; layer
(cons 10 pt) ;* First alignment point (in OCS)
(cons 11 pt) ;* Second alignment point (in OCS)
(cons 39 0.0) ; Thickness (optional; default = 0)
(cons 40 ht) ;* Text height
(cons 41 0.8) ; Relative X scale factor, Width Factor, defaults to 1.0
(cons 51 0.0) ; Oblique angle
(cons 62 256) ; color
(cons 71 0) ; Text generation flags
(cons 72 0) ; Horizontal text justification type
(cons 73 1) ; Vertical text justification type
(cons 210 (list 0.0 0.0 1.0))
) ))
(defun c:FileHistory (/)
;Get time and date
;Afralisp
(setq d (rtos (getvar "CDATE") 2 6))
(setq yr (substr d 1 4)) ;extract the year
(setq mo (substr d 5 2)) ;extract the month
(setq dy (substr d 7 2)) ;extract the day
(setq hr (substr d 10 2)) ;extract the hour
(setq m (substr d 12 2)) ;extract the minute
(setq Sdate (strcat "Save Date: " (strcat dy "/" mo "/" yr)))
(setq Stime (strcat " Time: " (strcat hr ":" m)))
(setq SUser (strcat " User: " (getvar "loginname")))
(setq SStr (strcat Sdate Stime SUser))
(setq sset (ssget "_X" '((0 . "Text") (1 . "Save Date:*"))))
(setq ss (ssname sset 0))
(setq dxfdata (entget ss))
(setq old-dxf (assoc 10 dxfdata))
(setq y1 (nth 2 old-dxf))
(if (> (sslength sset) 0)
(progn
(repeat (setq inc (sslength sset))
(setq ss (ssname sset (setq inc (1- inc))))
(setq dxfdata (entget ss))
(setq old-dxf (assoc 10 dxfdata))
(setq x (nth 1 old-dxf))
(setq y (nth 2 old-dxf))
(if (> y1 y)
(setq y2 y) ;T
(setq y2 y1) ;not
)
)
(setq Tpt (list x y))
(maketext SStr Tpt 4000)
)
(Progn
(alert (strcat "Pick a point to Insert file history"))
(setq Tpt (getpoint))
(maketext SStr Tpt 4000)
)
)
)
Code: [Select]
(if (???????????)
(progn
(setq Tpt ??????? )
(maketext SStr Tpt 4000)
)
Questions:
Q1: How to run this lisp when close the file?
(defun c:FileHistory (/ d yr mo dy hr m
sdate stime suser sstr sset ss dxfdata
dxf y1 old-dxf dxfdata x
y y1 y2
)
(and
;Get time and date
;Afralisp
(setq d (rtos (getvar "CDATE") 2 6))
(setq yr (substr d 1 4)) ;extract the year
(setq mo (substr d 5 2)) ;extract the month
(setq dy (substr d 7 2)) ;extract the day
(setq hr (substr d 10 2)) ;extract the hour
(setq m (substr d 12 2)) ;extract the minute
(setq Sdate (strcat "Save Date: " (strcat dy "/" mo "/" yr)))
(setq Stime (strcat " Time: " (strcat hr ":" m)))
(setq SUser (strcat " User: " (getvar "loginname")))
(setq SStr (strcat Sdate Stime SUser))
(setq ssetL (ssget "_X" '((0 . "Text") (1 . "Save Date:*"))))
(setq sset (if ssetl
(sslength ssetL)
(setq sset 0)
)
)
)
(if (> sset 0)
(progn
(setq ss (ssname ssetL 0))
(setq dxfdata (entget ss))
(setq dxf (assoc 10 dxfdata))
(setq y1 (nth 2 dxf))
)
)
;OK
(if (> sset 0)
(progn
(repeat (setq inc sset)
(setq ss (ssname ssetL (setq inc (1- inc))))
(setq dxfdata1 (entget ss))
(setq old-dxf (assoc 10 dxfdata1))
(setq x (nth 1 old-dxf))
(setq y (nth 2 old-dxf))
(if (> y1 y)
(setq y2 y) ;T
(setq y2 y1) ;not
)
)
(setq Tpt (list x (- y 6000)))
(maketext SStr Tpt 4000)
)
(Progn
(alert (strcat "Pick a point to Insert file history"))
(setq Tpt (getpoint))
(maketext SStr Tpt 4000)
)
)
) ;defun
(defun maketext (str pt ht)
(entmakex (list (cons 0 "TEXT") ;***
(cons 1 str) ;* (the string itself)
(cons 6 "BYLAYER") ; Linetype name
(cons 7 (getvar "TEXTSTYLE"))
;* Text style name, defaults to STANDARD, current
(cons 8 (getvar "CLAYER")) ; layer
(cons 10 pt) ;* First alignment point (in OCS)
(cons 11 pt) ;* Second alignment point (in OCS)
(cons 39 0.0) ; Thickness (optional; default = 0)
(cons 40 ht) ;* Text height
(cons 41 0.8) ; Relative X scale factor, Width Factor, defaults to 1.0
(cons 51 0.0) ; Oblique angle
(cons 62 256) ; color
(cons 71 0) ; Text generation flags
(cons 72 0) ; Horizontal text justification type
(cons 73 1) ; Vertical text justification type
(cons 210 (list 0.0 0.0 1.0))
)
)
)
I guess the best way to do that is via reactorHow is this?
Thanks pBe I'll study yoursI guess the best way to do that is via reactorHow is this?
I do not know whats reactor.
Glad to help, though I fear we've led you to the dark side. If you think you've made errors before, wait till you've made an error in reactors :lmao: ... they're DANGEROUS beyond belief!
Glad to help, though I fear we've led you to the dark side. If you think you've made errors before, wait till you've made an error in reactors :lmao: ... they're DANGEROUS beyond belief!
Glad to help, though I fear we've led you to the dark side. If you think you've made errors before, wait till you've made an error in reactors :lmao: ... they're DANGEROUS beyond belief!
So true.. Dangerous reactor is.
@hasanCAD/kruuger
Think about this. what are the conditions as when to trigger the lisp routine? Every time the user invoke a save* command? in the event the user saves the file and continues working on the file?
after a while the user click save again, then that will be two Filehistory lines. You may need to use a counter within the lisp code to determine that it ran at least once, then it should the repalce the string rather than writing a new line.
_close reator is indeed the way to go
i'm using this reactor to save info about user who modify the file.Glad to help, though I fear we've led you to the dark side. If you think you've made errors before, wait till you've made an error in reactors :lmao: ... they're DANGEROUS beyond belief!
So true.. Dangerous reactor is.
@hasanCAD/kruuger
Think about this. what are the conditions as when to trigger the lisp routine? Every time the user invoke a save* command? in the event the user saves the file and continues working on the file?
after a while the user click save again, then that will be two Filehistory lines. You may need to use a counter within the lisp code to determine that it ran at least once, then it should the repalce the string rather than writing a new line.
_close reator is indeed the way to go
Why not include command CLOSE at the bottom of the routine and exclude using reactors .... :pissed:and how to run program to save history on close without reactor ?
You could undefine the close command, then your defun would be named c:close and inside it you call "._CLOSE" to run the "undefined" command.probably should work. i don't know how close reactor but save works very well. i;m working with this routine over 2 years with 40 people.
Or use the vla-Close on the current document rather. Also you might then have to implement some sort of "Do you want to save changes" dialog. Personally I agree with this idea more, there's less to go wrong, and you've got more control over what's happening.
and how to run program to save history on close without reactor ?
kruuger
...YES this is what I want
this is what you want HasanCAD ?
kruuger
after few days of work i have nice history in DICTIONARY
kruuger
Thanks pBe I'll study yoursI guess the best way to do that is via reactorHow is this?
I do not know whats reactor.Code - Auto/Visual Lisp: [Select]i'm using this when someone save the drawing. works very well.
easy to modify to CLOSE.
kruuger
i store user info only in drawing:
after few days of work i have nice history in DICTIONARY
kruuger
Nice idea,
Will that be separate Dictionary for each drawing file on an external file? does it keep a record on the drawing itself?
please find attached files and make a test....YES this is what I want
this is what you want HasanCAD ?
kruuger
...
A few extra goodies are included, free of charge. LoL :kewl:
...YES it is
the coding is TERRIBLE. maybe it is time to rewrite this mess :|
...
http://docs.autodesk.com/ACD/2011/ENU/filesALG/WS73099cc142f4875516d84be10ebc87a53f-7c34.htmand
and
http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-67b0.htm
Also from the same website you used for reference on you code:
http://www.afralisp.net/visual-lisp/tutorials/reactors-part-1.php
...That perfect
please find attached files and make a test.
...
if one person is working on file, there is only one line per day. each save replace only time....That perfect
please find attached files and make a test.
...
but when open, save and close the file gives me one line in history
What is to prevent the user from opening the drawing, and doing nothing for several hours and saving the drawing (effectively producing nothing). Won't their time still be logged?program is not used for monitoring work. purpose is to easy track person who modify the drawing.
Perhaps it would be prudent to incorporate a Sysvar Reactor that monitors Cmdactive, and when commands are not active, the timer is prgramatically stopped. Just a thought, as this thread somewhat reminds me an AUGI thread about CadTempo.
program is not used for monitoring work. purpose is to easy track person who modify the drawing.
kruuger
program is not used for monitoring work. purpose is to easy track person who modify the drawing.
kruuger
I would argue that one is dependent on the other.
Without the context of knowing what modification(s) have occurred, one cannot possibly know which user(s) is(are) responsible.
Again, were a user to open a drawing, draw a line, delete the line just drawn, then save the drawing (effectively doing nothing)... That user would be logged.
A long time ago, I was in the same boat. The piping lead asked me to print off a stack of drawings. A few days later he comes back and asks "Why was this changed?" "This shouldn't look like this" and so on, pointing to my name on an automated datestamp on the prints. I had to repeated point out to him that the log (datestamp on drawing in this case) was only changed when the drawing was printed and I had *never* worked on the drawings.it's a better have more people on log list rather then none.
The moral of the story: tracking logs don't always say what you think they are saying.
Again, were a user to open a drawing, draw a line, delete the line just drawn, then save the drawing (effectively doing nothing)... That user would be logged.I can't remember, does the SysVar reactor catch changes in the CmdActive sysvar? If so perhaps just save a running total of how many commands the user's used during his/her editing time. E.g. if they've had the DWG open for several hours, but only 10 commands were issued, they probably only had it open as a reference to another drawing (i.e. for something like Copy-n-Paste).
There's no perfect answer
I can't remember, does the SysVar reactor catch changes in the CmdActive sysvar?
Another alternative could be to count the number of objects inside the drawing at open, and then save the difference at Save. That way you can see how much extra work / erases were made.
There's no perfect answer, especially since any user could have multiple DWGs open at the same time. But it's near impossible to work on more than 1 at any one instant. Also what about those using RefEdit? They're inside one DWG, but actually modifying another.
How to reset the LOG?
In some cased ( specially in details drawings) we copy and rename an old file to use in a new projects.
So we need to reset the file history.
...How did you do the yellow circle which moved with the mouse?
rewritten AUTOR.LSP to LOG.LSP (new shortcut LOG)
...
kruuger
...How did you do the yellow circle which moved with the mouse?
rewritten AUTOR.LSP to LOG.LSP (new shortcut LOG)
...
kruuger