Jump to content

Filename, revision & date


Baber62

Recommended Posts

Hi, I need a lisp routine to do the following if a new file has not been saved save it as [Filename - Rev 000 - Date - Time] where the user is prompted for a filename. Then after having worked on the drawing subsequently to increment the Rev by 1 and add new date and time. The time should be in the "hh-mm" format.

 

Also when the drawing is being saved it should be saved in two locations one in a superseded folder and one in the current folder.

 

I have managed to create a macro using vba which can do this for an excel spreadsheet just wondering if something similar could be created in lisp for AutoCAD drawings.

Link to comment
Share on other sites

A starter:

(vl-load-com)
(command "_UNDEFINE" "_QSAVE")

(defun c:QSave( / stringDate fileName )
(setq stringDate (rtos (getvar "CDATE") 2 6))

(if (eq (getvar "DWGTITLED") 0)   ;test if drawing was saved
 (if (setq fileName (getfiled "Save drawing" (getvar "DWGPREFIX") "DWG" 1))
  (command "_.SAVE" (strcat (vl-filename-directory fileName) "\\"
                            (vl-filename-base fileName)
                            "-Rev000-" 
                            (substr stringDate 1  
                            "-"
                            (substr stringDate 10 4)
                            (vl-filename-extension fileName)))
 )
)

(princ)
)

;(command "_REDEFINE" "_QSAVE")   ;to get ride later of this change

 

The above function definition should be placed in an auto-loader to be available in all drawings.

Link to comment
Share on other sites

VL-FILENAME-BASE

VL-FILENAME-DIRECTORY

VL-FILENAME-EXTENSION

VL-FILENAME-MKTEMP

 

are (VL-LOAD-COM) independent functions, so you don't need (vl-load-com) line at start of code...

 

M.R.

Link to comment
Share on other sites

Hi Mircea,

 

Have added the lisp routine to my autocad2011doc.lsp file so it loads up whenever AutoCAD opens up. When I type in the qsave command nothing happpens?

Link to comment
Share on other sites

Please consider the use of acaddoc.lsp auto-loader; the one you used is reserved for system purposes and isn't recomended to be edited by user.

 

Also, don't miss that my example is for new (not-saved) drawings only and was intended to serve as a starter for your own code.

Link to comment
Share on other sites

Hi Mircea ... that's where the problem lies, I am not experienced in lisp therefore would appreciate some additional help as to getting this to work.

Link to comment
Share on other sites

should be saved in two locations one in a superseded folder and one in the current folder.

Can you post, please, the path of that backup folder?

Link to comment
Share on other sites

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