Jump to content

save my dwg to D:My Folder


Michaels

Recommended Posts

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 [b][color="red"]"D:\\My Folder\\"[/color][/b] Fname ".dwg"))

 

Why the above file path is not working ?

 

Thanks

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
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
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...