rlx Posted April 13, 2018 Posted April 13, 2018 (edited) adding a getstring to ask for filename is not rocket science.... (defun c:foo (/ _dir F NF P SF SH dwg) (defun _dir (msg path / sh folder out) (or (vl-file-directory-p path) (setq path (getvar 'dwgprefix))) (cond ((and (setq sh (vlax-get-or-create-object "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 msg "&H2000" path)) ) (setq out (vlax-get-property (vlax-get-property folder 'self) 'path)) (setq out (strcat (vl-string-right-trim "\\" out) "\\")) ) ) (and sh (vlax-release-object sh)) out ) (setq dwg (strcat (getvar 'dwgprefix) (getvar 'dwgname))) (if (and (setq p (_dir "Pick a directory yo!" "E:\\Autocad Files\\SSC\\North Region\\SNE\\")) (setq f (getstring "\nEnter file name for drawing : "))) ; *** added ask for new drawing name here *** (progn (setq sf "Plans" nf (strcat p sf "\\" f ".dwg")) (cond ((cond ((findfile nf) (prompt "File exists...") nil) ((vl-file-directory-p (strcat p sf)) (vl-file-copy dwg nf) t) ((vl-mkdir (strcat p sf)) (vl-file-copy dwg nf) t) ) (setq sh (vlax-get-or-create-object "Shell.Application")) (vlax-invoke-method sh 'open nf) (vlax-release-object sh) ) ) ) ) (princ) ) (vl-load-com) Edited April 14, 2018 by rlx Quote
acad1985 Posted April 14, 2018 Author Posted April 14, 2018 Hello RLX Actually I'm very newbie for LISP,just i'm learning these things. and very for disturbing again. I have Tested your code, it is asking the file name but it will not save the file. it is just created the Plans folder. Thanks Quote
rlx Posted April 14, 2018 Posted April 14, 2018 (edited) Hello RLXActually I'm very newbie for LISP,just i'm learning these things. and very for disturbing again. I have Tested your code, it is asking the file name but it will not save the file. it is just created the Plans folder. Thanks you're absolutely right , my mistake , updated code above ... shouldn't have typed it directly in browser without testing (and I did it again cause I still haven't tested it...) to make your life a little easier , this version has default option (enter to keep the same drawing name) (defun c:foo (/ _dir F NF P SF SH dwg) (vl-load-com) (setq dwg (strcat (getvar 'dwgprefix)(getvar 'dwgname))) (defun _dir (msg path / sh folder out) (or (vl-file-directory-p path) (setq path (getvar 'dwgprefix))) (cond ((and (setq sh (vlax-get-or-create-object "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 msg "&H2000" path))) (setq out (vlax-get-property (vlax-get-property folder 'self) 'path)) (setq out (strcat (vl-string-right-trim "\\" out) "\\")) ) ) (and sh (vlax-release-object sh)) out ) (if (setq p (_dir "Pick a directory yo!" "E:\\Autocad Files\\SSC\\North Region\\SNE\\")) (progn (if (eq "" (setq f (getstring (strcat "\nEnter drawing name <" (vl-filename-base dwg) "> : ")))) (setq f (vl-filename-base dwg))) (setq sf "Plans" nf (strcat p sf "\\" f ".dwg")) (cond ((cond ((findfile nf) (prompt "File exists...") nil) ((vl-file-directory-p (strcat p sf)) (vl-file-copy dwg nf) t) ((vl-mkdir (strcat p sf)) (vl-file-copy dwg nf) t)) (setq sh (vlax-get-or-create-object "Shell.Application")) (vlax-invoke-method sh 'open nf) (vlax-release-object sh) ) ) ) ) (princ) ) Edited April 14, 2018 by rlx Quote
acad1985 Posted April 15, 2018 Author Posted April 15, 2018 Thank you so much RLX. Both the codes is working perfectly as what i want. Thanks again. Quote
rlx Posted April 15, 2018 Posted April 15, 2018 Thank you so much RLX.Both the codes is working perfectly as what i want. Thanks again. you're welcome although most of the credit goes of cource to ronjonp...; Quote
acad1985 Posted April 15, 2018 Author Posted April 15, 2018 Of course, I am obliged to thank Ronjonp.. Quote
ronjonp Posted April 16, 2018 Posted April 16, 2018 you're welcome although most of the credit goes of cource to ronjonp...; Thank you for taking care of this. Quote
ronjonp Posted April 16, 2018 Posted April 16, 2018 Of course, I am obliged to thank Ronjonp.. Glad the problem got sorted Quote
Recommended Posts
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.