Jump to content

Deleting Solid hatching within blocks according to block name


Recommended Posts

Posted

Good morning all. I've found this routine that ALMOST does what i need it to do. Basically, I need this routine to only run on blocks that have a suffix of "-NI" (ex. XXX-##-XX-#-NI) at the end of the block name. Does anyone have any idea how to do this? I'm not great working with vla stuff. Anything helps! Thanks!!

 

EDIT: just FYI these will be dynamic blocks, if that makes any difference.

 

(defun c:Test (/ doc)
 (vlax-for bks (vla-get-blocks (setq
                     doc (vla-get-ActiveDocument (vlax-get-acad-object))
                   )
                 )
   (if (and (eq :vlax-false (vla-get-islayout bks))
            (eq :vlax-false (vla-get-isXref bks))
       )
     (vlax-for obj bks
       (if (and (wcmatch (vla-get-objectname obj)
                         "AcDbHatch"
                )
                (vlax-write-enabled-p obj)
           )
         (vla-delete obj)
       )
     )
   )
 )
 (vla-regen doc AcAllViewports)
 (princ)
)(vl-load-com)

Posted

Hi,

 

Its a good manner to reference the codes to the link where you got them from as long as you are not the one who wrote them. Right?

 

(if (and 
(eq :vlax-false (vla-get-islayout bks))
            (eq :vlax-false (vla-get-isXref bks))
(wcmatch (vla-get-name bks) "*-NI")
       )
( .......

Posted

This is perfect, thank you!

I've honestly had this one sitting around for a while after using it for another application a while back! I'm not too sure where it came from! Very appreciative to whoever did write it though! Works great, and thank you very much for the extra line!

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