jonathann3891 Posted November 12, 2021 Posted November 12, 2021 I've got this working pretty good so far, but I'm stuck on vl-file-copy. I want to copy a drawing from one folder to another. Proto is the file I want to copy, which includes the directory. d is the folder I want to put it in. (defun c:ttt (/) (vl-load-com) (setq Fname (getfiled "Select AST Model" (getvar 'dwgprefix) "dwg" 16) a (vl-filename-directory Fname) b (vl-filename-base Fname) c (strcat a "\\" b) d (strcat c "\\" "Prototypes") );setq (vl-mkdir c) (vl-mkdir d) (setq Proto (getfiled "Select AST Prototype" "Z:\\ECI CAD\\AutoCAD\\Borders\\Advance Steel Prototypes\\" "dwg" 8)) (vl-file-copy Proto d) ) Quote
Lee Mac Posted November 12, 2021 Posted November 12, 2021 You'll need to specify the target filename for the copy operation, in addition to the target directory. Consider the following (untested) code: (defun c:ttt ( / a d f ) (cond ( (not (and (setq a (getfiled "Select AST Model" (getvar 'dwgprefix) "dwg" 16)) (setq f (getfiled "Select AST Prototype" "Z:\\ECI CAD\\AutoCAD\\Borders\\Advance Steel Prototypes\\" "dwg" 16)) ) ) (princ "\n*Cancel*") ) ( (not (LM:createdirectory (setq d (strcat (vl-filename-directory a) "\\" (vl-filename-base a) "\\Prototypes")))) (princ (strcat "\nUnable to create directory \"" d "\".")) ) ( (not (vl-file-copy f (strcat d "\\" (vl-filename-base f) (vl-filename-extension f)))) (princ (strcat "\nUnable to copy file \"" f "\" to folder \"" d "\".")) ) ( (princ (strcat "\nFile \"" f "\" copied to folder \"" d "\"."))) ) (princ) ) ;; Create Directory - Lee Mac ;; Creates all folders in a supplied directory path - assumes backslash delimiters (defun LM:createdirectory ( dir / pos ) (cond ( (vl-file-directory-p dir)) ( (and (setq pos (vl-string-position 92 dir nil t)) (LM:createdirectory (substr dir 1 pos))) (vl-mkdir dir) ) ) ) (princ) 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.