conradsteve Posted April 6, 2017 Posted April 6, 2017 Hi, I have this batch file that opens each drawing in a specific folder, does a purge on each file, then saves and closes it. What I'd like to do is add a WBLOCK command to that script file that would write the entire drawing to a designated folder, but instead of calling the new file 'new block.dwg' (which is the default name), it would use the same name as the original. Below are a few lines from the script file and I'd like to insert the WBLOCK command after the purges. Is that possible? Many thanks _open "U:\Project\A - CURRENT DRAWINGS\TitleBlock.dwg" _purge all * no _purge all * no _purge all * no _zoom extents _qsave _close Quote
ReMark Posted April 6, 2017 Posted April 6, 2017 Is there a way to invoke the WBlock command that does not result in a dialog box? Quote
nukecad Posted April 6, 2017 Posted April 6, 2017 Instead of wblock'ing the whole drawing could you not do a _-saveas to the designated folder straight after the _qsave? Using the hyphen would keep it on the command line without opening a dialogue. Quote
conradsteve Posted April 6, 2017 Author Posted April 6, 2017 Instead of wblock'ing the whole drawing could you not do a _-saveas to the designated folder straight after the _qsave? Using the hyphen would keep it on the command line without opening a dialogue. Thanks, but the WBLOCK gets rid of a lot of garbage that's in drawings and leaves you with a cleaner, leaner, smaller, faster-opening drawing. Quote
ReMark Posted April 6, 2017 Posted April 6, 2017 For cleaning drawings I'd recommend the following... Overkill -Purge (Regapps first) -Purge (ALL) Audit and respond "yes" to fixing all errors that are found. I can't see a way to add WBlock to a script. Maybe you "call" a lisp routine to handle this command? Quote
conradsteve Posted April 6, 2017 Author Posted April 6, 2017 Thanks ReMark. I'll try looking for a lisp routing that I can invoke from the script file. I tried overkill on a couple of the files and the wblock seemed to have better results for me. With 360 more files to clean up, the lisp routine within the script file is the way to go for me Thanks again. Quote
ReMark Posted April 6, 2017 Posted April 6, 2017 WBlock and Overkill have two different purposes. One is not a substitute for the other. Quote
conradsteve Posted April 6, 2017 Author Posted April 6, 2017 Of course, you're correct. I misspoke. My intent was not to get rid of duplicate lines, but to cleanup hidden garbage that seems to bloat up drawings. For that, WBLOCK is my best friend Quote
ReMark Posted April 6, 2017 Posted April 6, 2017 And you would be surprised to see how many duplicate or overlapping objects will be found using Overkill. Quote
conradsteve Posted April 6, 2017 Author Posted April 6, 2017 I'm sort of scared to use it as we often have lines on top of each other, but in different layers. Or we had 2 polylines on the same layer and one polyline was drawn thin and one thick and the thick one should be kept. I'll read up on the command before I use on a real drawing Quote
Roy_043 Posted April 6, 2017 Posted April 6, 2017 You should be able to use the -WBLOCK command in a script. Quote
ReMark Posted April 6, 2017 Posted April 6, 2017 You should be able to use the -WBLOCK command in a script. Which also means one should be able to invoke the -WBLOCK command at the command line right? Quote
conradsteve Posted April 6, 2017 Author Posted April 6, 2017 I got it to work by adding the following line to my script -WBLOCK "c:/X/TEMP.DWG" "*" I have to get the filename of the new drawing to be the same as each drawing that i open (all 362 drawings), but I'm working on that Quote
Steven P Posted April 6, 2017 Posted April 6, 2017 would something like this help? (vl-filename-base (getvar 'dwgname)) Quote
Steven P Posted April 6, 2017 Posted April 6, 2017 You might need to use (vl-load-com) at the start of your script too Quote
BIGAL Posted April 7, 2017 Posted April 7, 2017 You can have lisp in a script -WBLOCK (strcat "c:/X/" (getvar 'dwgname)) "*" Re 362 dwgs there are various methods to get the dwg filenames http://www.cadtutor.net/forum/showthread.php?100318-Export-Drawing-Names-to-txt-file-format-C I use old fashioned dir and either word or excel to make for 362 dwgs. Take advantgae of copy and paste Quote
conradsteve Posted April 7, 2017 Author Posted April 7, 2017 (edited) Thanks to all who are trying to help me. Here's the code that I'm working with. It pops up a dialg box asking to select a drawing from a folder and then creates a batch file that performs commands on all the drawings in that folder I did not write the program (no surprise there, as it's obvious to all that I don't know my arse from my elbow when it comes to programming), but I did add the WBLOCK line However, Autocad is not happy as it says that I've too many arguments. Is is obvious to anybody where I went wrong? ============================================== (defun C:RV ( / COUNT DIR FILENAME FILES SCRIPTNAME) (if (setq dir (getfiled "Select the drawing directory:" "" "dwg" 0)) (setq dir (vl-filename-directory dir)) ) (if dir (setq files (vl-directory-files dir "*.dwg" 1)) ) (if files (progn (setq scriptname (open "C:\x\batch.scr" "w") count 0 ) (while (setq filename (nth count files)) (setq filename (strcat dir "\\" filename)) (write-line (strcat "_open \"" filename "\"") scriptname) (write-line "_purge all * no" scriptname) (write-line "_purge all * no" scriptname) (write-line "_purge all * no" scriptname) (write-line "_FILEDIA 0" scriptname) (write-line -WBLOCK (strcat "c:/X/" (getvar 'dwgname) "*") scriptname) (write-line "_FILEDIA 1" scriptname) (write-line "_zoom extents" scriptname) (write-line "_qsave" scriptname) (write-line "_close" scriptname) (setq count (1+ count)) ) (close scriptname) ) ) (princ) ) =================================================== Edited April 7, 2017 by SLW210 Added Code Tags Quote
SLW210 Posted April 7, 2017 Posted April 7, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
conradsteve Posted April 7, 2017 Author Posted April 7, 2017 (defun C:RV ( / COUNT DIR FILENAME FILES SCRIPTNAME) (if (setq dir (getfiled "Select the drawing directory:" "" "dwg" 0)) (setq dir (vl-filename-directory dir)) ) (if dir (setq files (vl-directory-files dir "*.dwg" 1)) ) (if files (progn (setq scriptname (open "C:\x\batch.scr" "w") count 0 ) (while (setq filename (nth count files)) (setq filename (strcat dir "\\" filename)) (write-line (strcat "_open \"" filename "\"") scriptname) (write-line "_purge all * no" scriptname) (write-line "_purge all * no" scriptname) (write-line "_purge all * no" scriptname) (write-line "_FILEDIA 0" scriptname) (write-line -WBLOCK (strcat "c:/X/" (getvar 'dwgname) "*") scriptname) (write-line "_FILEDIA 1" scriptname) (write-line "_zoom extents" scriptname) (write-line "_qsave" scriptname) (write-line "_close" scriptname) (setq count (1+ count)) ) (close scriptname) ) ) (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.