+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2009
    Posts
    65

    Default Dxf to file location

    Registered forum members do not see this ad.

    Trying to get this lisp to save a dxf to a specific folder ex. C:\My Documents\DXF\. I tryed putting that in the code but I'm not writing it right or something. Could someone point me in the right direction.

    Code:
    (defun c:dxf ()
    (vl-load-com)
    (vlax-for LAYOUT (vla-get-layouts(vla-get-activedocument(vlax-get-acad-object)))
    (vl-catch-all-apply 'vla-delete (list LAYOUT))
    )
    (command "CHANGE" "ALL" "" "P" "LA" "0" "")
    (command "-PURGE" "ALL" "" "N")
    (nowdxf)
    )
    (defun nowdxf () 
     (command "saveas" "dxf" "")
    )

  2. #2
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    I'd look into the DXFOUT command in lieu of saveas

    Also you will need \\ or use / for directory locations in lieu of the single \

    -David
    R12 (Dos) - A2K

  3. #3
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2009
    Posts
    65

    Default

    Tryed this. Its still not working. By usings just the saveas or dxfout, it works but I want to force it to this folder with out have to select it.

    Code:
    (defun c:dxf ()
    (vl-load-com)
    (vlax-for LAYOUT (vla-get-layouts(vla-get-activedocument(vlax-get-acad-object)))
    (vl-catch-all-apply 'vla-delete (list LAYOUT))
    )
    (setvar "CLAYER" "0")
    (command "change" "all" "" "p" "la" "0" "")
    (command "-purge" "all" "" "n")
    (nowdxf)
    )
    (defun nowdxf (/ dxfname)
     (setq dxfname (getstring "n\DXF Name:  "))
     (command "_SAVEAS"  "DXF" "" (strcat "C:\\Users\\My Documents\\DXF\\" DXFNAME))
    (princ)
    )

  4. #4
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    If you're trying to avoid the SaveAs dialog, then consider this example:

    Code:
    (defun c:FOO ( / fileName)
      (vl-load-com)
      (if (setq fileName (getstring T "\nEnter a file name: "))
        (vla-saveas
          (vla-get-activedocument (vlax-get-acad-object))
          (strcat "C:\\Users\\My Documents\\DXF\\" fileName ".dxf")
          ac2010_dxf)
        )
      (princ)
      )
    "Potential has a shelf life." - Margaret Atwood

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Oh - Almost forgot... For reference: ActiveX SaveAs Method
    "Potential has a shelf life." - Margaret Atwood

  6. #6
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2009
    Posts
    65

    Default

    Thanks. It works perfect

  7. #7
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Quote Originally Posted by bradb View Post
    Thanks. It works perfect
    Happy to help.
    "Potential has a shelf life." - Margaret Atwood

  8. #8
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2009
    Posts
    65

    Default

    How different would this code look if dxfout were used instead of saveas. Just curious

  9. #9
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Pseudo code:

    Code:
    (defun c:FOO  ()
      (vl-load-com)
      (vlax-for oLayout  (vla-get-layouts
                           (vla-get-activedocument
                             (vlax-get-acad-object)))
        (vl-catch-all-apply 'vla-delete (list oLayout)))
    
      (setvar 'clayer "0")
    
      (command "._change" "all" "" "properties" "layer" "0" "")
      (command "._-purge" "all" "" "no")
      (command "._dxfout"
               (vl-string-subst
                 ".dxf"
                 ".dwg"
                 (strcat (getvar 'dwgprefix) (getvar 'dwgname)))
               16)
    
      (princ))
    "Potential has a shelf life." - Margaret Atwood

  10. #10
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2009
    Posts
    65

    Default

    Registered forum members do not see this ad.

    Cool. Still trying to learn this visiual lisp. Thanks

Similar Threads

  1. .ctb File Location
    By LSDS in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 21st Jun 2012, 01:29 pm
  2. File Location on IDW
    By pgcust in forum Autodesk Inventor
    Replies: 1
    Last Post: 15th Aug 2008, 04:36 pm
  3. ac$ file location?
    By NEWUSER in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 24th Aug 2006, 06:42 pm
  4. CTB file location
    By WannaBeCader in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 25th Oct 2005, 03:55 pm
  5. BAK File location
    By geoffc in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 30th Jun 2005, 06:43 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