Jump to content

Lisp to Save dwg file to specific folder with date


Recommended Posts

Posted

Hi Everyone

I have a folder on (E:\Orders 22-Aug-2017) this path.This folder will be created daily for respective date by Excel.

Need lisp to automatically find the folder with today date on that path and saved it automatically.

Anyone help me to this.

Thanks in advance.

Posted

You can get the DATE via lisp so can not see any real problems in finding E:\Orders date etc. Search DATE for various output dd/mm/yy etc.

Posted

Hi Bigal

Thanks for your reply..but i can't understand.. Please can you create the lisp for that...:?

Posted (edited)
(defun c:SaveToDateFolder ( / doc fld fnm)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (setq fld
   (strcat
     "E:\\Orders "
     ;; Change DD to D for 'E:\Orders 1-Aug-2017' instead of 'E:\Orders 01-Aug-2017'.
     (menucmd (strcat "M=$(edtime,$(getvar,date),DD-MON-YYYY)"))
     "\\"
   )
 )
 (cond
   ((not (findfile fld))
     (prompt (strcat "\nError: Date folder '" fld "' not found "))
   )
   (
     (and
       (= 1 (getvar 'dwgtitled))
       (= (strcase fld) (strcase (getvar 'dwgprefix)))
     )
     (vla-save doc)
   )
   ((setq fnm (getfiled "Save as" fld "dwg" 1))
     (vla-saveas doc fnm)
   )
 )
 (princ)
)

Edited by Roy_043
Posted

Hi Roy

Thanks for your code. I have checked your code. Unfortunately i got error while running the lisp as shown below.

 

Error: Date folder 'E:\22-Aug-2017\ ' not found

 

But i have created the Orders 22-Aug-2017 folder in E drive before run the lisp.

 

Please give me the suggestion to solve the Error.

 

Thanks in Advance.

Posted

I forgot to add 'Orders ' to the folder name. I have fixed this in my previous post.

Posted

Hi Roy

Thanks for your modification. but i got same error again..:?

Posted
Thanks for your modification. but i got same error again..:?
That is not possible. Try copying the code again.
Posted

Hi Roy..

Sorry for my previous post, i have checked again it's working good.

Thank you so much for your code.:):D

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