Jump to content

Script file to write entire set of drawings to a a new folder using WBLOCK


conradsteve

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • conradsteve

    10

  • ReMark

    5

  • Steven P

    2

  • nukecad

    1

Top Posters In This Topic

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by SLW210
Added Code Tags
Link to comment
Share on other sites

(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)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...