你好
我正在使用我找到的一个非常有用的lisp代码(稍加修改),它用日期和时间戳保存dwg文件。
有人能帮我把日期和时间显示在文件名之前吗?
例如,我希望文件读取“test 09-09-16\u 12.22'28.dwg”,而不是“09-09-16\u 12.22'28”test.dwg”
更重要的是,每个文件是否可以保存在自动创建的子文件夹中,该子文件夹与文件同名?因此,如果文件名为“test.dwg”,则会自动创建一个子文件夹,并将其命名为“test”,而无需用户进行任何输入,其中包含所有保存的文件。
提前谢谢你。
这是我正在使用的代码:
-
- ;; TED KRUSH 9/23/02
- ;;; Routine that was created @ Southern Maine Technical College.
- ;;; Saves Drawing an eariler version and then resaves as
- ;;; orginal version to maitain defualt save.
- ;; UPDATED 02/02/03 Added Date Sub-Routine
- ;; UPDATED 03/11/05 Revise version save 2002/R14 to 2004/2000 per upgrade to Autocad 2005 version
- ;; UPDATED 04/05/06 Adde StrPath Sub-Rountine, so as new file can be saved to folder.
- ;;;; *** Now We go to to Commerical Break for the Typical Legal Mumbo Jumbo ***
- ;;;; Permission to use, copy, modify, and distribute this software
- ;;;; for any purpose and without fee is hereby granted.
- ;;;;
- ;;;; I PROVIDE THIS PROGRAM "AS IS" AND WITH ALL FAULTS. I SPECIFICALLY DISCLAIM ANY
- ;;;; IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. I DO NOT
- ;;;; WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.
- (defun c:scon ()
- ;;Error Trap utilizing the TedError Function
- (command ".undo" "m")
- (setq old_error *error*)
- (setq *error* tederror)
- ;;Start of Date defun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- (defun TODAY (/ d yr mo day hr m s) ;define the function and declare all variabled local
- (setq d (rtos (getvar "CDATE") 2 6)
- ;get the date and time and convert to text
- yr (substr d 3 2) ;extract the year
- mo (substr d 5 2) ;extract the month
- day (substr d 7 2) ;extract the day
- hr (substr d 10 2) ;extract the hour
- m (substr d 12 2) ;extract the minute
- s (substr d 14 2) ;extract the second
- )
- (setq dates (strcat mo "-" day "-" yr "_" hr "." m "'" s"'' ")) ;string 'em together
- (princ)
- )
- ;;End of Date defun
- ;;Start of StrPath defun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- (defun StrPath ()
- (setq OldName (getvar "dwgname"))
- ;; Extracts the Drawing File Name
- (setq OldPath (getvar "dwgprefix"))
- ;; Extracts the Drawing Location
- (setq NewPath (vl-string-subst
- "\\Transfer-Outgoing\"
- "\\Drawings\"
- OldPath
- )
- )
- (setq OldFile (strcat OldPath OldName))
- ; Text String for Old File
- (setq NewFile (strcat NewPath dates Oldname))
- ; Text String for New File
- (princ)
- )
- ;;End of StrPath defun
- ;; Main Rountine
- (today)
- (StrPath)
- (vl-mkdir NewPath)
- (setvar "expert" 4)
- (command "saveas" "2004" NewFile) ;New file with date Prefix
- (command "saveas" "2004" OldFile) ;Saves back to the Orginal File.
- (setvar "expert" 0)
- (setq *error* old_error)
- (princ)
- )
|