NH3man! Posted December 17, 2011 Posted December 17, 2011 For the life of me I can't find it. I used to have a lisp that would 1. Turn on all layers 2. Delete all text 3. Delete all lines and points 4. Set Properties of all remaining object to (0 layer) (line type to by block) (color to by block) (line weight to by block) 5. Deletes existing layout tabs 6. Purge all regapps I have had to do this manually to about 100 files and have another close to 2000 to go. I will keep looking around but it was an old file. If any of you have it or have seen it could you link it in you post. Thanks NH3man! Quote
dirkvandonkelaar Posted December 17, 2011 Posted December 17, 2011 is this the post you need?? http://www.cadtutor.net/forum/showthread.php?44801-Cleaning-Drawings-Lisp&highlight=lisp+turn+layers Quote
Lee Mac Posted December 17, 2011 Posted December 17, 2011 Try this: (defun c:DoItAll ( / *error* _startundo _endundo acdoc cmdecho locked i s ) (defun *error* ( msg ) (if cmdecho (setvar 'CMDECHO cmdecho)) (if acdoc (_EndUndo acdoc)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (defun _StartUndo ( doc ) (_EndUndo doc) (vla-StartUndoMark doc) ) (defun _EndUndo ( doc ) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-EndUndoMark doc) ) ) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)) cmdecho (getvar 'CMDECHO) ) (_StartUndo acdoc) (setvar 'CMDECHO 0) ;; Turn on and unlock all Layers (vlax-for layer (vla-get-layers acdoc) (vla-put-layeron layer :vlax-true) (if (eq :vlax-true (vla-get-lock layer)) (vla-put-lock (car (setq locked (cons layer locked))) :vlax-false) ) ) ;; Delete Layout Tabs: (vlax-for layout (vla-get-layouts acdoc) (if (not (eq "Model" (vla-get-name layout))) (vla-delete layout) ) ) ;; Delete all Text, MText, Lines & Points (if (setq s (ssget "_X" '((0 . "TEXT,MTEXT,LINE,POINT")))) (repeat (setq i (sslength s)) (entdel (ssname s (setq i (1- i)))) ) ) ;; Set properties of remaining objects (vlax-for obj (vla-get-modelspace acdoc) (vla-put-layer obj "0") (vla-put-linetype obj "BYBLOCK") (vla-put-color obj acbyblock) (vla-put-lineweight obj aclnwtbyblock) ) ;; Purge all RegApps: (command "_.-purge" "_R" "*" "_N") ;; Relock those layers! (foreach layer locked (vla-put-lock layer :vlax-true)) ;; Reset the environment (setvar 'CMDECHO 1) (_EndUndo acdoc) (princ) ) (vl-load-com) (princ) Quote
NH3man! Posted December 17, 2011 Author Posted December 17, 2011 Work way better!!!!! Tried it on about 10 files and all worked great. I like how you separated it. I can understand it much better. Thanks again Lee for bailing me out!!!!!! Quote
Lee Mac Posted December 17, 2011 Posted December 17, 2011 Excellent NH3man, glad to hear its working for you Quote
NH3man! Posted December 18, 2011 Author Posted December 18, 2011 Lee I just ran into another issue. Not with you code, with some of the files that I am working on. When I run your code on some of the (attribute definition) appear. I have no need for them because we are converting all of our blocks and part drawings into MVparts for MEP. I have tried adding (attribute) (att) (attr) and a few others into what I thought was your delete string of code but it had no effect. I also tried adding in parts of some other code into yours but that didn't work at all. Thanks for all your help. NH3man! Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 I don't quite understand NH3man, what are you looking to add? Quote
NH3man! Posted December 18, 2011 Author Posted December 18, 2011 When I run your code on some of the drawings. Attribute Definitions appear on the drawing. They look like text but are not. I can click on one of them and select similar. Then delete them. So then I tried to edit your code by adding (attributes) into what I think is your delete string. But that didn't work. Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 Hmmm, I'm not sure why they would appear (unless they are perhaps on an OFF layer that is being turned ON by the routine?). Anyway, change this: (0 . "TEXT,MTEXT,LINE,POINT") to: (0 . "ATTDEF,TEXT,MTEXT,LINE,POINT") Quote
NH3man! Posted December 18, 2011 Author Posted December 18, 2011 I almost got it. I tried ATTD. LOL Thanks again! Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 I almost got it. I tried ATTD. LOL To find out what the correct code should be, use this, type 'ee', click on your object and look at the value associated with DXF Group 0 Quote
NH3man! Posted December 18, 2011 Author Posted December 18, 2011 That will come in handy! Check your cookie jar and Merry Christmas. Thanks again! Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 Thanks NH3man! A Very Merry Christmas to you and yours! Lee 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.