I was reading through the methods on these posts:
This reactor was pretty slick by Jurg Menzi:
http://www.theswamp.org/index.php?topic=5446.0I'm trying to write my log dynamically to the folder the current file is open in.
The problem is I am using the mdiTab17.arx application for multiple document tabs.
If I try to reference DWGPREFIX it only recognizes the path of the default Drawing1.dwg which is of course %UserProfile%\My Documents folder if it isn't saved from when cad first opened its default template file.
Whatever the first drawing of the AutoCAD session is opened from, that becomes the default for DWGPREFIX for all other files opened in that session. Here is the snippet I added to the reactor Jurg Menzi posted
; - Write to log function
(defun MeWriteToLog ()
(setq FormatDate (rtos (getvar "CDATE") 2 6)
Year (substr FormatDate 3 2)
Month (substr FormatDate 5 2)
Day (substr FormatDate 7 2)
Hour (substr FormatDate 10 2)
Minutes (substr FormatDate 12 2)
)
(setq DirPath (getvar "DWGPREFIX"))
(if (setq LogPath (strcat DirPath "Z_User_Drawing.log"))
(progn
(setq FILEDESC (open LogPath "a"))
(write-line
(strcat Month "/" Day "/" Year " - " Hour ":" Minutes " " " [ User ID: " (getvar "LOGINNAME") " ] => " (getvar "DWGNAME")
)
FILEDESC
)
(close FILEDESC)
(setq FILEDESC nil)
)
)
(alert (strcat
"Drawing name:\t\t" Me:DwgNme
"\nTotal command time:\t" (MeCalcTime Me:CmdTim)
"\nTotal commands called:\t" (itoa Me:CmdCnt)
"\nLog File Path:\t\t " LogPath
)
)
(setq DirPath nil)
(princ)
)
With the reactor I wasn't sure how else to get the path of the current files folder of the open files being closed?
Any hints would be appreciated