Jump to content

Delete all Wipeouts within a Drawing including Blocks


Bobzy20

Recommended Posts

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    12

  • masterfal

    10

  • kpblc

    8

  • Bluebird1973

    5

Top Posters In This Topic

Posted Images

is it possible to add something to this code so that it specifies the number of wipeouts removed?

 

(vl-load-com)
(defun c:Test (/ b o)
 ;;--- Tharwat 26.June.2013 ---;;  
 (or doc
     (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
 )
 (vlax-for b
             (vla-get-blocks
               doc
             )
   (if
     (and
       (eq :vlax-false (vla-get-isLayout b))
       (eq :vlax-false (vla-get-isXref b))
     )
      (vlax-for o b
        (if (eq "AcDbWipeout" (vla-get-objectname o))
          (vl-catch-all-apply 'vla-delete (list o))
        )
      )
   )
 )
 (if 
    (setq ss (ssget "_X" '((0 . "WIPEOUT")(410 . "Model"))))
    (command "_.erase" ss "")
 )
 (vla-regen doc acAllViewports)
 (princ)
)

Link to comment
Share on other sites

Try this. I added proceeding layers and counters for successfully and error erasing wipeouts

 

cool thanks for having a look. after testing this its returning:

 

"Too many actual parameters"

 

Any ideas why thats happening?

Link to comment
Share on other sites

Ah, sorry. New version:

 

almost perfect... just need it to also include wipeouts inside of blocks. the original code i posted included removing wipeouts inside of blocks (thats why i like this one so much), it just doesn't return how many

Link to comment
Share on other sites

is it possible to add something to this code so that it specifies the number of wipeouts removed?

 

Try this:

 

(defun c:Test (/ num doc ss i)
 ;;--- Tharwat 12.Aug.2016 ---;;  
 (setq num 0
       doc (vla-get-ActiveDocument (vlax-get-acad-object))
 )
 (vlax-for b
             (vla-get-blocks
               doc
             )
   (if
     (and
       (eq :vlax-false (vla-get-isLayout b))
       (eq :vlax-false (vla-get-isXref b))
     )
      (vlax-for o b
        (if (and (eq "AcDbWipeout" (vla-get-objectname o))
                 (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list o))))
                 )
          (setq num (1+ num))
        )
      )
   )
 )
 (if (setq ss (ssget "_X" '((0 . "WIPEOUT") (410 . "Model"))))
   (repeat (setq i (sslength ss))
     (if (entdel (ssname ss (setq i (1- i))))
       (setq num (1+ num))
     )
   )
 )
 (vla-regen doc acAllViewports)
 (if (< 0 num)
   (princ (strcat "\nNumber of deleted Wipeout(s) is: ["
                  (itoa num)
                  "]"
          )
   )
   (princ "\nNo Wipeouts found in this drawing !")
 )
 (princ)
)(vl-load-com)

Edited by Tharwat
Link to comment
Share on other sites

kpblc, is there any way your code could have changed some of my settings because i'm getting the strangest things happening. alot of my lisp routines don't seem to work properly anymore (some commands i need to type twice as the first time it says its an unknown command and other commands just don't work at all - after working fine for years) and with blocks on my drawing when i double click to edit them the "edit block definition" dialog box appears and to edit it i have to pick the block from the list... so confused. if it wasn't your code would you have any other idea what could be causing that to happen? i can't work like this..

Capture.PNG

Link to comment
Share on other sites

My code don't change any commands. As you can see, code used only ActiveX-technology, no commands.

Could you do some things, please?

1. Attach any dwg with wipeouts inside blocks. I changed code to update block definitions, but i'm not sure it's enough.

2. What kind of commands you have to type twice?

3. What you code doesn't work?

4. Version of AutoCAD is... And ServicePacks and hotfixes are installed or not?

 

Once upon a time i wrote code like this (as i remember, hatches and wipeouts should be erased) - and noone reports me any problem.

 

P.S. code:

(vl-load-com)

(defun c:remove-wipeout2 (/ adoc layers count err)
 (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
 (vlax-for item (vla-get-layers adoc)
   (if (not (wcmatch (vla-get-name item) "*|*"))
     (setq layers (cons (append (list item)
                                (mapcar (function (lambda (prop / tmp)
                                                    (setq tmp (vlax-get-property item prop))
                                                    (vl-catch-all-apply (function (lambda () (vlax-put-property item prop :vlax-false))))
                                                    (cons prop tmp)
                                                    ) ;_ end of lambda
                                                  ) ;_ end of function
                                        '("freeze" "lock")
                                        ) ;_ end of mapcar
                                ) ;_ end of append
                        layers
                        ) ;_ end of cons
           ) ;_ end of setq
     ) ;_ end of if
   ) ;_ end of vlax-for
 (setq count 0
       err 0
       ) ;_ end of setq
 (vlax-for blk_def (vla-get-blocks adoc)
   (if (equal (vla-get-isxref blk_def) :vlax-false)
     (vlax-for ent blk_def
       (if (wcmatch (strcase (vla-get-objectname ent)) "*WIPEOUT*")
         (if (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () (vla-erase ent)))))
           (setq err (1+ err))
           (setq count (1+ count))
           ) ;_ end of if
         ) ;_ end of if
       ) ;_ end of vlax-for
     ) ;_ end of if
;;; Attach string to update block definition
   (vl-catch-all-apply (function (lambda () (vla-update blk_def))))
   ) ;_ end of vlax-for
 (foreach item layers
   (foreach prop (cdr item)
     (vl-catch-all-apply (function (lambda () (vlax-put-property (car item) (car prop) (cdr prop)))))
     ) ;_ end of foreach
   ) ;_ end of foreach
;;; Attach string to regenerate current document
 (vla-regen adoc acallviewports)
 (princ (strcat "\nErased wipeout : " (itoa count) "\nError erasing  : " (itoa err)))
 (vla-endundomark adoc)
 (princ)
 ) ;_ end of defun

Link to comment
Share on other sites

my bad.. in regards to removing the wipeouts from blocks, i realised after that i needed to regen the drawing to see the wipeouts removed from blocks. so thats all good. sorry for implying it didn't work properly!

basically majority of my custom commands either don't work or need to be input twice and even noticed "c" for 'copy' now does 'copy multiple'! where it got that from i have no idea. i've always had copy multiple as 'cm'. i even tried removing the reference to the custom lsp file i use (so as to return it to default settings/commands) which fixed the copy command it still did that weird thing where i can't edit blocks properly. i don't understand what happened or how to fix it :( i'm using autocad 2011..

Link to comment
Share on other sites

also just noticed when i try to edit any text it doesn't go into it straight away. it asks me which annotation i want to edit..

anno.PNG

Link to comment
Share on other sites

is it possible to add something to this code so that it specifies the number of wipeouts removed?

Did you try the last mods of my program that I did for you?

Link to comment
Share on other sites

yeh i just tried it then. it seems to be one of the commands i need to put in twice to work..

the first time i run it it says "test argument is not a vl-catch-all-apply error: nil"

then if i try do it again it works.. this is doing my head in. can't work out why its doing this

 

ps - it only seems to count the number of wipeouts removed which aren't in blocks. (when i tested i had one wipeout outside block and one inside, it removed them both but said only 1 deleted)

Link to comment
Share on other sites

Hey Tharwat,

 

One last thing to 'perfect' this code would be if it could return 0 if there are none removed. Not sure if that is an easy thing to add in or not..

At the moment when you try to use it and there are no wipeouts, it doesn't say anything so sometimes not sure if its actually run properly or not.

Link to comment
Share on other sites

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