Jump to content
Baber62

Filename, revision & date

Recommended Posts

Baber62

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.

Share this post


Link to post
Share on other sites
MSasu

You can redefine the SAVE command to act in that way.

Share this post


Link to post
Share on other sites
Baber62

Hi Mircea, any advice on how to do this would be appreciated.:huh:

Share this post


Link to post
Share on other sites
MSasu

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.

Share this post


Link to post
Share on other sites
marko_ribar

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.

Share this post


Link to post
Share on other sites
Baber62

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?

Share this post


Link to post
Share on other sites
MSasu

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.

Share this post


Link to post
Share on other sites
Baber62

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.

Share this post


Link to post
Share on other sites
MSasu
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?

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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