Guys,
Are any of you any good with both AutoCAD and Excel ? I suppose one step at a time though wanting to have a csv files contents to be added. I have a routine that logs files being opened and closed. I am trying to get it to log the edittime rather just the time opened and closed. This seems to be an unsuccessful task at present though sure it will get there.
Not sure what the best way is to get the objective though or how to do it and asking for a kind person to assist if and where they could.
Is it possible to have the routine upon going to write to the log file check the csv file for a row containing that logs file name ? If so could we have the routine add the existing figure with the new one ?
Or do we write the new log on the folowing line and then have the csv file add file hours with the common names ?
Below is both the working open closed log and the current, not finished routine to write the edittime:
Code:
(vl-load-com)
(defun DoThisOnClose (Caller CmdSet)
(WriteLog "CLOSED")
(princ)
)
(setq MyReactor1
(vlr-dwg-reactor
nil
'((:vlr-beginClose . DoThisOnClose)
)
)
)
(defun WriteLog (Event / Draftername Job file line2write)
(if (/= (getvar "dwgname") "Drawing1.dwg")
(progn
(setq Draftername (getvar "loginname"))
(setq Job (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq file
(open (strcat "S:\\DSA CAD\\USERLOG FILE\\UserLog-"
(getvar "loginname")
"-"
(menucmd "M=$(edtime,$(getvar,date),YYYY-MO)")
".csv"
)
"a"
)
)
(setq line2write
(strcat
Draftername
","
Event
","
(menucmd
"M=$(edtime,$(getvar,date),YYYY/MO/D - HH:MM AM/PM)"
)
","
Job
)
)
(write-line line2write file)
(close file)
)
)
(princ)
)
(WriteLog "OPENED")
(vl-load-com)
(defun DoThisOnClose (Caller CmdSet)
(setvar "USERS1"
(rtos (acet-getvar '("BNS_EDITTIME_TOTAL")) 2 10)
) ;_end setvar
(WriteLog "CLOSED")
(princ)
) ;_end defun
(setq MyReactor1
(vlr-dwg-reactor
nil
'((:vlr-beginClose . DoThisOnClose)
)
)
) ;_end setq
(defun WriteLog (Event / Draftername Job file line2write)
(if (/= (getvar "dwgname") "Drawing1.dwg")
(progn
(setq Draftername (getvar "loginname"))
(setq Job (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq file
(open (strcat "S:\\DSA CAD\\USERLOG FILE\\UserLog-"
(getvar "loginname")
"-"
(menucmd "M=$(edtime,$(getvar,date),YYYY-MO)")
".csv"
) ;_end strcat
"a"
) ;_end open
) ;_end setq
(setq line2write
(strcat
Draftername
","
Event
","
(menucmd "M=$(edtime,$(getvar,date),YYYY/MO/D)")
(if (= Event "CLOSED")
(progn
","
(menucmd "M=$(edtime,$(index,0,$(getvar,users1)),HH:MM:SS)"
)
) ;_end progn
) ;_end if
","
Job
) ;_end strcat
) ;_end setq
(write-line line2write file)
(close file)
) ;_end progn
) ;_end if
(princ)
) ;_end defun
(WriteLog "OPENED")
Any assistance would be grately appreciated.
Stephen