PDA

View Full Version : save my dwg to D:My Folder



Michaels
24th Oct 2010, 09:47 pm
Hello,

How to save my dwg to the drive D and to specific folder . for example called My Folder.



(setq Fname (getstring T "\n new file name :"))
(setq x (strcat "D:\\My Folder\\" Fname ".dwg"))


Why the above file path is not working ?

Thanks

Lee Mac
24th Oct 2010, 09:48 pm
Does 'My Folder' exist?

JohnM
24th Oct 2010, 10:00 pm
please post the rest of the code so we can see what's going on

Michaels
24th Oct 2010, 10:09 pm
Yes Lee the "My Folder" is already made or existed in drive D.

Mr Johnm. Here are the codes nothings more than that up to this moment .


(if (and (setq Fname (getstring T "\n new file name :"))
(setq x (strcat "D:\\My Folder\\" Fname ".dwg"))
)
(command "_.save" x)
(princ)
)


By Mr Lee 's question, Is it possible also to create a folder before save the dwg and include it within ?

many thanks for you all.

Lee Mac
24th Oct 2010, 10:21 pm
Perhaps something like this...



(defun c:test ( / dir file )

(setq dir "D:\\My Folder")

(vl-mkdir dir)

(if (and (vl-file-directory-p dir)
(snvalid (setq file (getstring t "\nEnter Filename: ")))
)
(vla-saveas (vla-get-ActiveDocument (vlax-get-acad-object))
(strcat dir "\\" file ".dwg")
)
)

(princ)
)

Michaels
24th Oct 2010, 10:35 pm
Perhaps something like this...


(defun c:test ( / dir file )
(setq dir "D:\\My Folder")
(vl-mkdir dir)
(if (and (vl-file-directory-p dir)
(snvalid (setq file (getstring t "\nEnter Filename: ")))
)
(vla-saveas (vla-get-ActiveDocument (vlax-get-acad-object))
(strcat dir "\\" file)
))
(princ))


What a great work Lee. :)

That's really amazing and wonderful. :thumbsup:

one question please about (snvalid). I've read about it but I couldn't understand it well ?

Thank you so much.

Michaels

Lee Mac
24th Oct 2010, 10:43 pm
Thanks Michaels :)

snvalid checks whether the string is valid for use as a symbol table name, hence it checks for characters such as /\?*" etc - the help files document it better.

(BTW, I updated the code above to include the .dwg extension)

Michaels
24th Oct 2010, 10:48 pm
(BTW, I updated the code above to include the .dwg extension)

That's right. The first code that you posted before post 5 and re update it within the same reply , it did not work because it was (saveas) and I tried it with (save) command only and it was as great as the the last undated one.

Thank you so much Lee.

Tiger
25th Oct 2010, 11:37 am
Further on Lee's teaching career see This Thread (http://www.cadtutor.net/forum/showthread.php?53713-Professor-Lee-Ph.D-M.D-and-all-around-Nice-Guy).