ksperopoulos Posted June 13, 2010 Share Posted June 13, 2010 I got this lisp off here (Lee Mac) and I am trying to cut the portion "delete all layout tabs" out of it and put it into a new lisp routine. But since I am just starting to learn about lisps, I am having trouble finding out what it is I exactly need to do this. Please help. (defun c:Brian (/ *error* uFlag) (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark *doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq *doc (cond (*doc) ((vla-get-ActiveDocument (vlax-get-acad-object))))) (setq uFlag (not (vla-StartUndoMark *doc))) (vlax-for blk (vla-get-Blocks *doc) (if (eq :vlax-true (vla-get-isXref blk)) (if (vl-catch-all-error-p (vl-catch-all-apply (function vla-Detach) (list blk))) (princ (strcat "\n** Error Detaching Xref: " (vla-get-name blk) " **"))))) (vlax-for lay (vla-get-Layers *doc) (vla-put-Lineweight lay acLnWt025) (vla-put-LayerOn lay :vlax-true)) (vlax-for lay (vla-get-layouts *doc) (if (not (eq "MODEL" (strcase (vla-get-Name lay)))) (vla-delete lay))) (vlax-for v (vla-get-views *doc) (vla-delete v)) (command "_.-scalelistedit" "_R" "_Y" "_E") (vl-Catch-All-Apply (function (lambda nil (vla-Remove (vla-GetExtensionDictionary (vla-Get-Layers *doc)) "ACAD_LAYERFILTERS")))) (if (setq states (layerstate-getnames t t)) (mapcar (function layerstate-delete) states)) (repeat 3 (vla-PurgeAll *doc)) (mapcar (function setvar) '("CLAYER" "INSBASE" "CANNOSCALE" "LTSCALE" "MSLTSCALE" "PSLTSCALE") '( "0" (0 0 0) "1/4\" = 1'-0\"" 1 1 1 )) (setq uFlag (vla-EndUndoMark *doc)) (princ)) Quote Link to comment Share on other sites More sharing options...
jammie Posted June 13, 2010 Share Posted June 13, 2010 Just working with what you supplied from Lee's code, the following bits are relevant (setq *doc (cond (*doc) ((vla-get-ActiveDocument (vlax-get-acad-object))))) (vlax-for lay (vla-get-layouts *doc) (if (not (eq "MODEL" (strcase (vla-get-Name lay)))) (vla-delete lay))) Regards Jammie Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2010 Share Posted June 13, 2010 Also, this may help Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 13, 2010 Author Share Posted June 13, 2010 Thank you guys! Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 13, 2010 Author Share Posted June 13, 2010 I am also trying to incorporate the delete layer states command of this lisp routine, but it is not getting them all. Any ideas why? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2010 Share Posted June 13, 2010 (if (setq states (layerstate-getnames t t)) (mapcar (function layerstate-delete) states)) Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 13, 2010 Author Share Posted June 13, 2010 Lee Mac That is what I have, but when I run the lisp, it doesn't get all of the layer states that were created in the drawing that I have. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2010 Share Posted June 13, 2010 Not sure. I've never used layerstates Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 14, 2010 Author Share Posted June 14, 2010 Me neither, but I have asked around and this seems to be one of the things people have told me to eliminate to make drawing file sizes smaller. Here is a snapshot of a message that I see when I go into the layer states. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 14, 2010 Share Posted June 14, 2010 Try each of these at the command line, and post the return: (layerstate-getnames t t) (mapcar (function layerstate-delete) (layerstate-getnames t t)) Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 14, 2010 Author Share Posted June 14, 2010 Here is what it is showing: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 14, 2010 Share Posted June 14, 2010 Ok, so the ones with 'nil' in the list are your problem ones Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 14, 2010 Share Posted June 14, 2010 Me neither, but I have asked around and this seems to be one of the things people have told me to eliminate to make drawing file sizes smaller. Here is a snapshot of a message that I see when I go into the layer states. Those are from the old Express Tool LMan (Layer State Manager) before they were merged with the original (core) Layer States. I haven't used this in years, but I just couldn't bring myself to delete it. ;;; Delete all LMAN groups ;;; From Tom Stoeckel <tom.stoeckel@autodesk.com> (defun c:killstates (/ lyr ent) (while (setq lyr (tblnext "layer" (not lyr))) (setq ent (entget (tblobjname "layer" (cdr (assoc 2 lyr))) '("RAK"))) (if (and ent (assoc -3 ent)) (progn (setq ent (subst '(-3 ("RAK")) (assoc -3 ent) ent)) (entmod ent) ) ;progn ) ;if );while (princ) ) Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 15, 2010 Author Share Posted June 15, 2010 I haven't used this in years, but I just couldn't bring myself to delete it. alanjt - Your inability to let go of the past has just got rid of the pesky layer states that I have been trying to get rid of. Thank you. And thanks to you too Lee Mac. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 15, 2010 Share Posted June 15, 2010 alanjt - Your inability to let go of the past has just got rid of the pesky layer states that I have been trying to get rid of. Thank you. And thanks to you too Lee Mac. Happy to help. 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.