Zorg Posted June 19, 2009 Posted June 19, 2009 Words, numbers or emoticons cannot express how much this stresses me out in AutoCAD2008. Already today, i have lost approximately 2 hours having AutoCAD crash on me then having to located the culprit files and run a scalelist edit on them:x. If only you could see my event viewer - it shows from 8am this morning about 25 application hangs due to this simply, yet horrible fault. What im wondering and potentially after is a lisp file that i can shove in my acaddoc that will purge the binded xref's scales leaving only 1:1, 1:20, 1:50 & 1:100. I've created one which simply resets the scale so that i can actually perform a scalelistedit once i've opened it up. But my problem is that the whole process of removing them idividually is not only annoying but incredibly time consuming. Is there anyone who can help me? The lisp routine im running to reset the scale is very basic, but im afraid my knoweldge is just that! (command "-scalelistedit" "reset" "y" "e") Regards, Z Quote
Zorg Posted June 19, 2009 Author Posted June 19, 2009 To make this a little more intresting - anyone who can solve this i will buy a pint of thier chosen larger/ale/cider . If you can't make it to my local or mine to your, i will send you a voucher of some form for one. Now, doesn't that sound a little more worth while? :wink: ReMark - If you solve my problem, i'll give you a personal oil change! Z Quote
Lee Mac Posted June 19, 2009 Posted June 19, 2009 Check out the similar threads below - there are tons on this topic Now, where's my reward... Quote
Zorg Posted June 19, 2009 Author Posted June 19, 2009 In all honesty... Im afraid to edit the registry Its a work machine!! Quote
Commandobill Posted June 19, 2009 Posted June 19, 2009 Something i hacked together. (Doesn't Edit the registry) (defun c:slclean ( / slist rlist) (vl-load-com) (setvar "cmdecho" 0) (setq slist '("1:1" "1:20" "1:50" "1:100")) (setq rlist (vl-remove-if '(lambda (z) (member z slist)) (getscalelist))) (mapcar '(lambda (z) (command "-scalelistedit" "d" z "e")) rlist) (setq slist (vl-remove-if '(lambda (z) (member z (getscalelist))) slist)) (mapcar '(lambda (z) (command "-scalelistedit" "a" z z "e")) slist) (setvar "cmdecho" 1) (princ) ) ;*************************************GETSCALELIST****************************************** ;*****************************Provided By Daniel J. Altam*********************************** (defun GETSCALELIST (/ ScaleListDict ScaleListEnts ScaleListNumber ScaleListUnits N DIGIT ACAD-KEY) (if (>= (atof (substr (getvar "acadver") 1 4)) 17.1) (progn ; 2008 and higher (setq ScaleListDict (dictsearch (namedobjdict) "ACAD_SCALELIST") ScaleListEnts (MASSOC 350 ScaleListDict) ScaleList (list "") N 0 ) (repeat (length ScaleListEnts) (setq ScaleList (cons (cdr (assoc 300 (entget (nth N ScaleListEnts)))) ScaleList) N (+ N 1) ) ) (setq ScaleList (cdr (reverse ScaleList))) ) (progn ; 2007& lower (setq ACAD-KEY (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Scale List")) (if (vl-registry-descendents ACAD-KEY T) (progn (setq ScaleListNumber (/ (vl-list-length (vl-registry-descendents ACAD-KEY T)) 3) ScaleList (list "") N 0 ) (repeat ScaleListNumber (if (>= N 10) (setq DIGIT (itoa N)) (setq DIGIT (strcat " " (itoa N))) ) (setq ScaleList (cons (vl-registry-read ACAD-KEY (strcat DIGIT ".ScaleName")) ScaleList) N (+ N 1) ) ) (setq ScaleList (cdr (reverse ScaleList))) ) ) ) ) ) (defun MASSOC (KEY ALIST / X NLIST) (foreach X ALIST (if (eq KEY (car X)) (setq NLIST (cons (cdr X) NLIST)) ) ) (reverse NLIST) ) Quote
Zorg Posted June 19, 2009 Author Posted June 19, 2009 ! Will this leave only my desired scales or just clear all the ones not supported by an annotative object? Also, can i update my acaddoc file with this to run on every drawing? Z Quote
Commandobill Posted June 19, 2009 Posted June 19, 2009 if the scale is used it wont be able to erase the scale from the list. It is going to leave the scales you want. As you can see "slist" is a list of the named scales you asked for. sure you can put this in your acaddoc file. just somewhere else not in a defun add (c:slclean) so it will automatically run. Quote
Zorg Posted June 19, 2009 Author Posted June 19, 2009 great! i take it this will execute only once the drawing has opened? how is a scale defined if it is in use or not? justy if anything annoative is using it? Quote
Commandobill Posted June 19, 2009 Posted June 19, 2009 great! i take it this will execute only once the drawing has opened? how is a scale defined if it is in use or not? justy if anything annoative is using it? Yes once you open the drawing it will run. It's in use if something annotative is using it or if you have a viewport using that scale Quote
Commandobill Posted June 19, 2009 Posted June 19, 2009 This is it only slightly different (defun c:slclean ( / slist rlist) (vl-load-com) (setvar "cmdecho" 0) (setq slist '("1:1" "1:20" "1:50" "1:100")) (setq rlist (vl-remove-if '(lambda (z) (member z slist)) (getscalelist))) (mapcar '(lambda (z) (command "-scalelistedit" "d" z "e")) rlist) (setq slist (vl-remove-if '(lambda (z) (member z (getscalelist))) slist)) (mapcar '(lambda (z) (command "-scalelistedit" "a" z z "e")) slist) (setvar "cmdecho" 1) (princ) ) ;*************************************GETSCALELIST****************************************** ;**********************************The updated Version************************************** (defun GETSCALELIST ( / csobj drac cslst) (setq csobj (vlax-ename->vla-object (cdar (dictsearch (namedobjdict) "ACAD_SCALELIST"))) drac 0) (repeat (vla-get-count csobj) (setq cslst (append (list (cdr (assoc 300 (entget (vlax-vla-object->ename (vlax-invoke-method csobj 'item drac)))))) cslst)) (setq drac (1+ drac))) cslst ) Quote
Commandobill Posted June 19, 2009 Posted June 19, 2009 And even different still... The only thing with this one is that it doesnt add any of the scales it just deletes them. This one deletes them even if they are in use.... Except the ones you tell it not to ofcourse (defun c:slclean ( / slist rlist drac csobj entlst entnm) (vl-load-com) (setvar "cmdecho" 0) (setq slist '("1:1" "1:20" "1:50" "1:100")) (setq csobj (vlax-ename->vla-object (cdar (dictsearch (namedobjdict) "ACAD_SCALELIST"))) drac 0) (repeat (vla-get-count csobj) (if (not (member (cdr (assoc 300 (entget (setq entnm (vlax-vla-object->ename (vlax-invoke-method csobj 'item drac)))))) slist)) (setq entlst (append (list entnm) entlst))) (setq drac (1+ drac))) (mapcar 'entdel entlst) (setvar "cmdecho" 1) (princ) ) Quote
Zorg Posted June 23, 2009 Author Posted June 23, 2009 Woah, nice! Two last thing, will this delete scales within xref files? Do i just remove the defun function from the start of the lisp and load it into my acaddoc for it too run on every drawing? Z Quote
Commandobill Posted June 23, 2009 Posted June 23, 2009 Personally i would throw that function into your acaddoc lsp then somewhere at the end (not in a function) simply write (c:slclean) that will load it everytime you open autocad or open a file. Quote
Zorg Posted June 23, 2009 Author Posted June 23, 2009 Kool, thanks for all yopur help Bill! Looks like i owe you a pint :wink: Quote
Lee Mac Posted June 23, 2009 Posted June 23, 2009 Looks like i owe you a pint :wink: haha, for the amount of times I've heard that phrase, I reckon we'd all be alcoholics on here in no time... Quote
Commandobill Posted June 23, 2009 Posted June 23, 2009 Kool, thanks for all yopur help Bill! Looks like i owe you a pint :wink: Lol I'll let you know if I'm ever in the UK. Quote
Alnaibii Posted August 4, 2009 Posted August 4, 2009 Hello, i tried the last lisp above, and it only leaves me with 1:1 scale. any idea why? Thanks Quote
Lee Mac Posted August 4, 2009 Posted August 4, 2009 Hello, i tried the last lisp above, and it only leaves me with 1:1 scale. any idea why? Thanks Perhaps the other scales were not present in your scale list to begin with 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.