Jump to content

Recommended Posts

Posted

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!

Posted

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)

Posted

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

Posted

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!

Posted

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.

Posted

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

Posted

I almost got it. I tried ATTD. LOL

 

Thanks again!

Posted
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

Posted

That will come in handy! Check your cookie jar and Merry Christmas.

 

Thanks again!

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