Jump to content

Recommended Posts

Posted

Morning All,

 

Is the a lisp or some code to delete a hatch from every block in a drawing. The super market chain I'm working with use the same blocks over and over on different projects but there is a hatch on most of the blocks which interferes with my phasing drawings.

 

I've tried Freezing/Turning Off the layer but as they have not set the blocks up with layer intelligence that doesn't work.

 

I'm not worried about loosing the information contained within there blocks as I'm working for the builder producing CAD files that are only issued in PDF format. I don't want to explode the blocks!

 

Look forward to your comments

Posted

Please do not double post. Try to show some patience. We're all just volunteers here. Thank you.

Posted

Try this ..

 

(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 "AcDbHatch" (vla-get-objectname o))
          (vl-catch-all-apply 'vla-delete (list o))
        )
      )
   )
 )
 (vla-regen doc acAllViewports)
 (princ)
)

Posted

if they are the same blocks used many times in different drawings you only need to modify one instance of each block, behaps using BEDIT or Tharwat's code. Then having modified all the necessary blocks in a single "master" drawing you can use the Design Centre to redefine the blocks in any current drawing.

  • 2 months later...
Posted

Tharwat,

I've finally had 5 mins to look at your code; it works just fine many thanks apart from one thing could you amend the code so it only works on selected items rather than across the whole drawing. We have a number of blocks that we now use that contain gradient fill/hatching and I don't want to delete the the hatch from them.

Look forward to hearing from you

Thanks again Stenna

Posted
Tharwat,

I've finally had 5 mins to look at your code; it works just fine many thanks apart from one thing could you amend the code so it only works on selected items rather than across the whole drawing.

 

Try this ...

 

(vl-load-com)
(defun c:Test (/ ss i sn name bd l)
 ;; Tharwat 18. Sep. 2013     ;;
 (or acdoc
     (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 )
 (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (if (not
           (member (setq name (cdr (assoc 2 (entget sn)))) l)
         )
       (progn
         (setq l (cons name l))
         (vlax-for x (setq bd
                            (vla-item (vla-get-blocks acdoc)
                                      name
                            )
                     )
           (if
             (and (eq :vlax-false (vla-get-isxref bd))
                  (eq (vla-get-objectname x) "AcDbHatch")
             )
              (vl-catch-all-apply 'vla-delete (list x))
           )
         )
       )
     )
   )
   (princ)
 )
 (if ss
   (vla-regen acdoc acAllViewports)
 )
 (princ)
)

Posted

I have just used it for the first time in the last five minutes and it works a blinder.....super coding

Many Thanks :D

Posted
I have just used it for the first time in the last five minutes and it works a blinder.....super coding

Many Thanks :D

 

Happy to hear that at last :D

  • Funny 1
Posted

You've saved me about 2 hours of editing blocks this evening. Many thanks

Posted
You've saved me about 2 hours of editing blocks this evening. Many thanks

Best of luck and happy CADing :)

  • 1 year later...
Posted

Good morning to you all , loading the lisp indicated by the following error :

; error: syntax error

; error: syntax error

 

you know help me?

Mirco

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