Jump to content
wee

Method to change hatch background in multi block to none...

Recommended Posts

wee

I have a drawing that was exported from Revit that has multiple blocks with a hatch background set to a color and I need them all set to none. I can use the blockeditor and do them one at a time but there are over 1000 blocks. Looking for a way to get them all at once. Small example file attached.

 

Thank You

Brian

 

 

block-hatch-fix-.dwg

Share this post


Link to post
Share on other sites
ronjonp

Like this?

(defun c:effh (/ a c d)
  ;; RJP » 2020-11-16
  (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  (vlax-for b (vla-get-blocks d)
    ;; This line will only process block definitions
    (if	(= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
      (vlax-for	o b
	(cond ((and (vlax-write-enabled-p o) (wcmatch (vla-get-objectname o) "AcDbHatch"))
	       (setq c (vla-get-backgroundcolor o))
	       (vla-setrgb c 0 0 0)
	       (vla-put-backgroundcolor o c)
	      )
	)
      )
    )
  )
  (foreach l a (vlax-put l 'lock -1))
  (vla-regen d acallviewports)
  (princ)
)

 

Edited by ronjonp
  • Like 2

Share this post


Link to post
Share on other sites
wee

That helps but deletes the hatch, I would like to leave the hatch just set the background color to "None".

 

Brian

Share this post


Link to post
Share on other sites
ronjonp
18 minutes ago, wee said:

That helps but deletes the hatch, I would like to leave the hatch just set the background color to "None".

 

Brian

Code updated above.

Share this post


Link to post
Share on other sites
ronjonp

@wee Did you get what you needed?

  • Like 1

Share this post


Link to post
Share on other sites
wee

Yes...That did the trick.

 

Thank You very much....

Brian

Share this post


Link to post
Share on other sites
ronjonp
3 hours ago, wee said:

Yes...That did the trick.

 

Thank You very much....

Brian

Glad to help. 🍻

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