blueshake Posted October 1, 2010 Share Posted October 1, 2010 hi,all in autocad 2010,when I type "wblock" in the command line. cad will jump out a dialogue to choose/setting. but when I write a lsp file ,the context as follows. (defun c:partial_saving(/) (command "-wblock") ) cad turn into command line model.and I read help file.it says I should not set filedia as 0.so I change the codes to (defun c:partial_saving(/) (setvar filedia 1) (command "-wblock") ) and it make even worse.cad just give some error. if I want to show the dialogue,what should I do?can anyone help me?? thanks. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted October 1, 2010 Share Posted October 1, 2010 (initdia)(command "._wblock") Quote Link to comment Share on other sites More sharing options...
Mellie Posted August 22, 2014 Share Posted August 22, 2014 Hi all, I need to write a program that creates a wblock from and entire drawing. I also need this program to do all of the functions below automatically by typing a simple command: On the command line, enter wblock. In the Write Block dialog box, under Source, click Entire Drawing. Under Destination, in the File Name box, enter the file name for the WBLOCK. In the Location box, enter the location where you want to save the WBLOCK (new drawing file). Click OK to create the new drawing file. I know how to call an already existing autocad command but I'm not sure how to do steps 2 through 5. This is what I have so far: [color=#383838](defun c:wblockm () (initdia)(command "._wblock") )[/color] Please help! I've been trying to do this for a while and am finally coming to the conclusion that I need a little help. Thanks Quote Link to comment Share on other sites More sharing options...
Snownut Posted August 22, 2014 Share Posted August 22, 2014 (defun c:partial_saving(/) (setvar 'filedia 1) (command "-wblock") ) See this code for your error. Quote Link to comment Share on other sites More sharing options...
Snownut Posted August 22, 2014 Share Posted August 22, 2014 Try this ; (defun c:partial_saving (/ tmpvar) (if (= (setq tmpvar (getvar 'filedia)) 0) (setvar 'filedia 1) ) (vl-cmdf "-wblock" "file name" "*") (setvar 'filedia tmpvar) Quote Link to comment Share on other sites More sharing options...
Mellie Posted August 22, 2014 Share Posted August 22, 2014 Hi Snownut, This is getting me closer to what I want! So when I run this code it prompts me to enter a name for output file and then select "whole drawing" and then the file is saved on my desktop. But I want all of this to be done automatically. I would like for the file to be name Melanie every time and saved in this location ("C:\\AutoCAD\\"Melanie.dwg") when I enter the partial_saving command. I want the following to be done in the code: wblock Enter name of output file: nil Enter name of output file: Melanie Enter name of existing block or [= (block=output file)/* (whole drawing)] : * Is this possible? Quote Link to comment Share on other sites More sharing options...
Snownut Posted August 22, 2014 Share Posted August 22, 2014 This should do the trick; (defun c:partial_saving ( / tmpvar) (if (= (setq tmpvar (getvar 'filedia)) 0) (setvar 'filedia 1) ) (vl-cmdf "-wblock" "C:\\Autocad\\Melanie.dwg" "*") (setvar 'filedia tmpvar) );defun Just corrected the file name..... Quote Link to comment Share on other sites More sharing options...
Snownut Posted August 22, 2014 Share Posted August 22, 2014 One last go, with file delete if already exist; (defun c:partial_saving ( / file) (if (setq file(findfile "C:\\Autocad\\Melanie.dwg")) (vl-file-delete file) ) (vl-cmdf "-wblock" "C:\\Autocad\\Melanie.dwg" "*") );defun Quote Link to comment Share on other sites More sharing options...
Mellie Posted August 22, 2014 Share Posted August 22, 2014 Thanks Snownut this is awesome!! What does ( / file) mean? And what does vl-cmdf mean? Thank you very much!!! Quote Link to comment Share on other sites More sharing options...
Snownut Posted August 22, 2014 Share Posted August 22, 2014 The ( / file), declares the variable "file" that the function uses a local variable and nil's it out upon function completion. (doesn't clutter up memory that way) The vl-cmdf is the Visual Lisp equivalent of the "command" function, it does not call the wblock dialog box when executed like the command function does. Quote Link to comment Share on other sites More sharing options...
Mellie Posted August 22, 2014 Share Posted August 22, 2014 Thank you for the clarification! I'm still trying to grasp the main idea of the WBLOCK command, I know it reduces the file size but how does it do it? What does WBLOCK command take out of the drawing to reduce the file size? Thank you! Quote Link to comment Share on other sites More sharing options...
dbroada Posted August 23, 2014 Share Posted August 23, 2014 The WBLOCK command strips everything that is not needed, layers, linetype, blocks etc. It is an old technique for eliminating errors that you couldn't locate! However, use with caution. If you have spent a long time creating blocks that you are going to use next week, they will be disposed of using WBLOCK. Similarly if you have an expected layer convention but some of them are empty they will be removed and you may have to recreate them. Quote Link to comment Share on other sites More sharing options...
Negarth Posted January 13, 2017 Share Posted January 13, 2017 Hello, I tried the lisp and it works well. I would like to use this lisp to get rid of all Displayproperties. Because of the huge amount of drawings I have to manipulate, I thought of using this lisp in scriptpro 2.0. Is there a possibility do wblock a drawing and save the wblock in the original folder and maybe using the original filename or an name like ..._wblock.dwg? I hope you can help me. thanks. Bernd Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 13, 2017 Share Posted January 13, 2017 As your using a script and it opens a drawing it would be easy to then load a lisp, even though you know the dwg name via script the lisp does not, so just add (getvar "dwgname") add the "wblock" to name and use what you have already. Quote Link to comment Share on other sites More sharing options...
Negarth Posted January 16, 2017 Share Posted January 16, 2017 (edited) Hello Bigal, thanks for your Reply. I should have admitted, that I am a Code-Noob. So, usially my way is trail and error. I modified the lisp as: (defun c:partial_saving ( / file) getvar "dwgname" (if (setq file(findfile "dwgname")) (vl-file-delete file) ) (vl-cmdf "-wblock" "dwgname" "j" "*") );defun The lisp reports that there already exists dwgname.dwg .... override Yes/No. The lisp ends but I dont't know to where the file was saved. Greetings from Munich. Bernd Edited January 16, 2017 by rkmcswain added [CODE] tags Quote Link to comment Share on other sites More sharing options...
Negarth Posted January 16, 2017 Share Posted January 16, 2017 (edited) Hi, the solution is: (defun c:partial_saving ( / dwg) (setq dwg (strcat (getvar "dwgprefix") "wblock_" (getvar "dwgname"))) (if (findfile dwg) (vl-file-delete dwg) ) (vl-cmdf "-wblock" dwg "j" "*") );defun Greetings. Bernd Edited January 16, 2017 by rkmcswain added [CODE] tags Quote Link to comment Share on other sites More sharing options...
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.