+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default save my dwg to D:My Folder

    Registered forum members do not see this ad.

    Hello,

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

    Code:
    (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

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,705

    Default

    Does 'My Folder' exist?
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Senior Member
    Computer Details
    JohnM's Computer Details
    Operating System:
    xp pro
    Using
    AutoCAD 2006
    Join Date
    Feb 2009
    Location
    houston, texas
    Posts
    380

    Default

    please post the rest of the code so we can see what's going on

  4. #4
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default

    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 .

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

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,705

    Default

    Perhaps something like this...

    Code:
    (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)
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default

    Quote Originally Posted by Lee Mac View Post
    Perhaps something like this...
    Code:
    (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.

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

    Thank you so much.

    Michaels

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,705

    Default

    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)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2010
    Posts
    347

    Default

    Quote Originally Posted by Lee Mac View Post
    (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.

  9. #9
    Super Moderator Tiger's Avatar
    Computer Details
    Tiger's Computer Details
    Operating System:
    Windows 7 Enterprise 64 bit
    Computer:
    Dell Precision M4500
    CPU:
    Intel Core i5 2.40GHz
    RAM:
    8GB
    Graphics:
    NVIDIA Quadro FX 880M
    Primary Storage:
    280 GB
    Monitor:
    2 x Samsung SyncMaster 2443 24''
    Using
    AutoCAD 2012
    Join Date
    Nov 2006
    Location
    Sthlm, Sweden
    Posts
    4,595

    Default

    Registered forum members do not see this ad.

    Further on Lee's teaching career see This Thread.
    Life doesn't suck, although we all go through periods when it may be easier to think that, than to discern the solution to whatever problem is the most formidable
    at the moment in one's personal UCS.
    Go to PLAN view instead. - Dadgad

Similar Threads

  1. Why can't I save a DWT to a custom folder?
    By CADnewb in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 18th Oct 2010, 12:48 am
  2. Autocad doesn´t prompt to save, just save
    By gilsoto13 in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 1
    Last Post: 7th Apr 2010, 08:08 pm
  3. Replies: 1
    Last Post: 6th Oct 2008, 09:40 pm
  4. VB to select input folder and output folder
    By TroutKing in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 7th Jun 2007, 11:07 pm
  5. Fatal error during automatic save or manual save
    By Autodesk in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 11th Sep 2006, 08:50 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts