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!
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)
|;
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.