kennyutk Posted October 6, 2014 Posted October 6, 2014 Hello. I hope you guys can help with my LISP. I am new to this, so forgive me if I sound too basic. A problem occurred all of a sudden, and it was working before. Now, when I open a dwg, it stalls at this portion of my acad file. That is how I narrowed it down to this particular LISP. I can see my maps, but they are stalled. After about 1 minute, it says that there is a "Fatal Error - Out of Memory". Do you guys have any idea on what to do? If I take out the "N" portion on this line (command "purge" "block" "*" "N"), it seems to work, but I have to click through several options in my command line to do anything on my map. (defun T:PURGEBLOCK () (if (and (/= (getvar "dwgname") "unnamed")(/= (substr (getvar "dwgname") 1 7) "Drawing")) (progn (setq wts (getvar "writestat")) (if (/= wts 0) (progn (command "purge" "block" "*" "N") (setq chg (getvar "dbmod")) (if (/= chg 0) (progn (setvar "cmdecho" 0) (princ "\n Saving purged drawing \n") (setvar "expert" 3) (command "save" "") (setvar "expert" 0) ; (snd) );end progn );end if );end progn );end if );end progn );end if (setvar "cmdecho" 0) (princ) ) Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 Hello. Sorry but where in my LISP should I try that? Quote
Lee Mac Posted October 7, 2014 Posted October 7, 2014 Try the following (untested) code: (defun purgeblock ( / val var ) (if (= 1 (getvar 'dwgtitled) (getvar 'writestat)) (progn (setq var '(cmdecho expert) val (mapcar 'getvar var) ) (mapcar 'setvar var '(0 2)) (command "_.-purge" "_b" "*" "_n") (if (< 0 (getvar 'dbmod)) (progn (command "_.save" "") (princ "\nPurged drawing saved.") ) (princ "\nNothing to purge, drawing not saved.") ) (mapcar 'setvar var val) ) (princ "\nDrawing unsaved or read-only.") ) (princ) ) Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 Thank you. I will try this out! Try the following (untested) code: (defun purgeblock ( / val var ) (if (= 1 (getvar 'dwgtitled) (getvar 'writestat)) (progn (setq var '(cmdecho expert) val (mapcar 'getvar var) ) (mapcar 'setvar var '(0 2)) (command "_.-purge" "_b" "*" "_n") (if (< 0 (getvar 'dbmod)) (progn (command "_.save" "") (princ "\nPurged drawing saved.") ) (princ "\nNothing to purge, drawing not saved.") ) (mapcar 'setvar var val) ) (princ "\nDrawing unsaved or read-only.") ) (princ) ) Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 Both of the codes have the same error. It seems to only happen with my larger maps. Here is screenshot, but I'm not sure if that will help... It will get stuck at those point and eventually lock up. Could it be a different problem possibly? Thank you. I will try this out! Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 I should mention that if I change the code portion of (command "_.-purge" "_b" "*" "_n") to (command "_.-purge" "_b" "*" "_y") it seems to work. Is there any reason why I should use _n or _y? It seems that it is to just verify the name to be purged? Try the following (untested) code: (defun purgeblock ( / val var ) (if (= 1 (getvar 'dwgtitled) (getvar 'writestat)) (progn (setq var '(cmdecho expert) val (mapcar 'getvar var) ) (mapcar 'setvar var '(0 2)) (command "_.-purge" "_b" "*" "_n") (if (< 0 (getvar 'dbmod)) (progn (command "_.save" "") (princ "\nPurged drawing saved.") ) (princ "\nNothing to purge, drawing not saved.") ) (mapcar 'setvar var val) ) (princ "\nDrawing unsaved or read-only.") ) (princ) ) Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 Sorry, here is the link where I saw the information. http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-C3876E92-3478-449C-8FAB-DA760B2EDD09 I should mention that if I change the code portion of (command "_.-purge" "_b" "*" "_n") to (command "_.-purge" "_b" "*" "_y") it seems to work. Is there any reason why I should use _n or _y? It seems that it is to just verify the name to be purged? Quote
SLW210 Posted October 7, 2014 Posted October 7, 2014 Please read the Code Posting Guidelines and edit your posts to include the Code in Code Tags. Quote
kennyutk Posted October 7, 2014 Author Posted October 7, 2014 let me try again (defun T:PURGEBLOCK () (if (and (/= (getvar "dwgname") "unnamed")(/= (substr (getvar "dwgname") 1 7) "Drawing")) (progn (setq wts (getvar "writestat")) (if (/= wts 0) (progn (command "purge" "block" "*" "N") (setq chg (getvar "dbmod")) (if (/= chg 0) (progn (setvar "cmdecho" 0) (princ "\n Saving purged drawing \n") (setvar "expert" 3) (command "save" "") (setvar "expert" 0) ; (snd) );end progn );end if );end progn );end if );end progn );end if (setvar "cmdecho" 0) (princ) ) Quote
Lee Mac Posted October 7, 2014 Posted October 7, 2014 I should mention that if I change the code portion of (command "_.-purge" "_b" "*" "_n") to (command "_.-purge" "_b" "*" "_y") it seems to work. Is there any reason why I should use _n or _y? It seems that it is to just verify the name to be purged? As far as I am aware, the code I have posted is correct & should perform successfully; I would therefore hazard a guess that your drawings must contain a huge number of blocks to be purged, which is consequently causing AutoCAD to exhaust the available memory whilst attempting to purge all such blocks simultaneously (hence the reason that confirming each block to be purged alleviates the problem). I would suggest using the following program to WBLOCK your entire drawing; the following code will generate a copy of the drawing in the working directory, with all unnecessary components removed: (defun c:wba ( / dwg fnm tmp ) (setq fnm (strcat (getvar 'dwgprefix) (cadr (fnsplitl (getvar 'dwgname))) "_wblock" ) ) (if (findfile (setq dwg (strcat fnm ".dwg"))) (progn (setq tmp 1) (while (findfile (setq dwg (strcat fnm "(" (itoa (setq tmp (1+ tmp))) ").dwg")))) ) ) (command "_.wblock" dwg "*") (princ) ) This method usually resolves most issues. 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.