Hudster, similar to what I'm doing. After the project is 90%, we need to send it to the client. I need to copy it to another directory, purge it and bind it. This routine will make life simple.
Daron, And anyone else who could help, here's the code.
;;Simple Save-as, Purge All and Bind routine
;;for preparing dwgs for clients
;;
;;By Hangman April 19, 2005
;;
;;
(defun c:SPG ()
(command ".undo" "be")
(setq echoprv (getvar "cmdecho")
old_err *error*
*error* $error
)
(setvar "cmdecho" 0)
(setvar "bindtype" 1)
;
(setq cfpath (getvar "dwgprefix"); Current File Path
cfname (getvar "dwgname"); Current File Name
fpend "bind\/" ; -- see note1 below --
nfpath (strcat cfpath fpend); New File Path
nfname (strcat nfpath cfname); New File Name
)
(command ".saveas" "2004" nfname)
;
(command "qsave")
(setq space (getvar "tilemode"))
;
(if (= space 1)
(progn
(command "zoom" "E")
(command "-layer" "S" "0" "")
(command "tilemode" 0)
(command ".pspace")
)
)
(if (= space 0)
(progn
(command ".pspace")
(command "zoom" "E")
(command "-layer" "S" "0" "")
)
)
(command "purge" "A" "" "N")
(command "purge" "A" "" "N")
(command "purge" "A" "" "N"); Just mak'n sure it's all gone
(command "qsave")
(command "-xref" "R" "*")
(command "-xref" "B" "*")
;
(setq fname (getvar "dwgname"); File Name
fnamel (strlen fname)
fname (substr fname 1 (- fnamel 4)); Taking off .dwg
fnend "_2000" ; Adding to end of File name
f-2k (strcat fname fnend) ; --see note2 below --
fpath (getvar "dwgprefix")
fpf-2k (strcat fpath f-2k) ; New path and file name
)
(command ".undo" "e")
(setq *error* old_err
old_err nil)
(setvar "cmdecho" echoprv)
(command ".saveas" "2000" fpf-2k)
(princ)
(command "close")
)
Note 1 -- I need to check for the directory BIND, if it's there, great, continue the code. If not, then make the directory to save the dwg to.
Note 2 -- I need to check for an existing dwg w/ same name. If it exists, over write. If not, great, continue code.
I usually run the purge two or three times because there are some plans that I have that are created with a base plan in mind. Having several layers with different objects for different sheets. Think of a five story building, each floor having different objects at each floor. The objects I have all on the base plan under different layer names designated for each floor. If I don't purge all before I bind, all those layers for the different floors show up on the dwgs making a real mess.
This code is working, but I need to manually check for the directory and any existing dwgs before I run it. If I forget to do that, it screws up my original dwg - Don't want that.
Also, could you give me some suggestions on my $error input, I don't think this is working very well.
Thanks guys.