Results 1 to 3 of 3

Thread: opening a .dwg OR .dwt file AND saveas with a lisp routine

  1. #1
    Member
    Join Date
    2012-05
    Posts
    5
    Login to Give a bone
    0

    Default opening a .dwg OR .dwt file AND saveas with a lisp routine

    Does anyone have a lisp routine to open a template or drawing file in one folder, and save it as another name in another folder? This would help in setting up a new project. The routine I've pasted below stops working immediately after:
    (command "open" "S:/Drawing Template/Sheet Template.dwg"

    It seems the lisp routine needs something between: (Sheet Template.dwg" and "saveas" "2010")


    Code:
    (defun c:project setup () 
    (command "SDI" 1)
    (command "FILEDIA" 0)
    (command "open" "S:/Drawing Template/Sheet Template.dwg"
    "saveas" "2010" "S:/Project/B-1.dwg")
    (command "tilemode" "0" "layer" "s" "0" ""
    "xref" "a" "xtblk30x42=x-tblk 30x42.dwg" "0,0,0" "1" "" "0" 
    "INSERT" "SHEETNO=S:/Drawing Template/Sheet No" "0,0,0" "1" "" "0" "zoom" "e")
    (command "explode" "L")
    (command "filedia" 1)
    (PRINC))
    Thanks for your help!
    Last edited by mmccollum661679; 2012-08-23 at 09:12 PM. Reason: [code] tags added ~Opie

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: opening a .dwg OR .dwt file AND saveas with a lisp routine

    Lisp must be loaded and run in a single drawing session. What you need to do is copy the file with lisp, script or shell to a batch file, then activate the file with something like:
    Code:
     (defun MyOpen (FileName ReadOnly / )
      (vla-activate 
        (vla-Open 
          (vla-get-Documents  (vlax-get-Acad-Object))
          FileName
          (if ReadOnly :vlax-true :vlax-false)
        )
      )
    )
    ; wye.dwg
    ; (MyOpen "G:\\TOMBU\\EaglePointProjects\\CntrvleTrace\\wye.dwg" nil)
    ; (MyOpen "G:/TOMBU/EaglePointProjects/CntrvleTrace/wye.dwg" nil)
    ;|(MyOpen (strcat (getvar "roamablerootprefix")"Support" (chr 92) "acaddoc.lsp") nil)(princ)) 
    (MyOpen "C:\\Documents and Settings\\User\\Application Data\\Autodesk\\AutoCAD Map 3D 2008\\R17.1\\enu\\support\\acaddoc.lsp" nil)
    
    ^C^C^P(or C:ViewBox(load "ViewBox.lsp"));ViewBox 
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "G:/TOMBU/Blocks/Leon_County_Plans_Binder.dwg" nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (getenv "QnewTemplate") nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "map2d_Leon.dwt") nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen (strcat (getvar "localrootprefix") "template" (chr 92) "FLHP-NF.dwt") nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "FLHP-NF.dwt" nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "" nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "" nil)(princ)
    ^C^C^P(or C:MyOpen(load "MyOpen.lsp"));(MyOpen "acaddoc.lsp" nil)(princ)
    |;

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: opening a .dwg OR .dwt file AND saveas with a lisp routine

    Why not create a drawing template that has the xref already attached and the block inserted and exploded? You could then copy that template using the vl-file-copy function to create your project drawing.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. Set file name from block attribute with lisp routine
    By email.dnewton396831 in forum AutoLISP
    Replies: 0
    Last Post: 2013-07-03, 08:51 PM
  2. Use Saveas Command from a Lisp Routine
    By CADdancer in forum AutoLISP
    Replies: 6
    Last Post: 2011-06-23, 03:01 PM
  3. Replies: 4
    Last Post: 2008-12-03, 06:39 AM
  4. A LISP routine for runing a batch file ?
    By stephen.coff in forum AutoLISP
    Replies: 3
    Last Post: 2006-09-07, 02:40 AM
  5. xref file relocation lisp routine
    By kgano in forum AutoLISP
    Replies: 3
    Last Post: 2005-04-15, 12:24 PM

Posting Permissions

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