Jump to content
stenna

Deleting Hatch from Blocks

Recommended Posts

stenna

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

Share this post


Link to post
Share on other sites
ReMark

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

Share this post


Link to post
Share on other sites
Tharwat

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

Share this post


Link to post
Share on other sites
dbroada

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.

Share this post


Link to post
Share on other sites
stenna

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

Share this post


Link to post
Share on other sites
Tharwat
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)
)

Share this post


Link to post
Share on other sites
Tharwat

Did you find any five minutes more to look at the code or not yet ?

Share this post


Link to post
Share on other sites
stenna

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

Many Thanks :D

Share this post


Link to post
Share on other sites
Tharwat
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

Share this post


Link to post
Share on other sites
stenna

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

Share this post


Link to post
Share on other sites
Tharwat
You've saved me about 2 hours of editing blocks this evening. Many thanks

Best of luck and happy CADing :)

Share this post


Link to post
Share on other sites
mirco354

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

; error: syntax error

; error: syntax error

 

you know help me?

Mirco

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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