Jump to content

Recommended Posts

Posted

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))

Posted

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

Posted

Thank you guys!

Posted

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?

Posted
  (if (setq states (layerstate-getnames t t))
   (mapcar (function layerstate-delete) states))

Posted

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.

Posted

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.

Layer States.JPG

Posted

Try each of these at the command line, and post the return:

 

(layerstate-getnames t t)

 

(mapcar (function layerstate-delete) (layerstate-getnames t t))

Posted

Here is what it is showing:

Layer State-Get Names.JPG

Layer State-mapcar.JPG

Posted

Ok, so the ones with 'nil' in the list are your problem ones :thumbsup:

Posted
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)
)

Posted

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.

Posted
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.:lol:

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...