wee Posted November 16, 2020 Share Posted November 16, 2020 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 16, 2020 Share Posted November 16, 2020 (edited) 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 November 16, 2020 by ronjonp 2 Quote Link to comment Share on other sites More sharing options...
wee Posted November 16, 2020 Author Share Posted November 16, 2020 That helps but deletes the hatch, I would like to leave the hatch just set the background color to "None". Brian Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 16, 2020 Share Posted November 16, 2020 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. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 17, 2020 Share Posted November 17, 2020 @wee Did you get what you needed? 1 Quote Link to comment Share on other sites More sharing options...
wee Posted November 18, 2020 Author Share Posted November 18, 2020 Yes...That did the trick. Thank You very much.... Brian Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 18, 2020 Share Posted November 18, 2020 3 hours ago, wee said: Yes...That did the trick. Thank You very much.... Brian Glad to help. Quote Link to comment Share on other sites More sharing options...
Ajmal Posted July 4 Share Posted July 4 (setq c (vla-get-backgroundcolor o)) (vla-setrgb c 0 0 0) (vla-put-backgroundcolor o C) how can i change to none Quote Link to comment Share on other sites More sharing options...
Ajmal Posted July 12 Share Posted July 12 how can I remove the hatch background colour means I need to set none Quote Link to comment Share on other sites More sharing options...
Ajmal Posted August 12 Share Posted August 12 please someone help with this, Have lots of objects in the block. I need to change the Hatch background colour to none. now am doing one by one Quote Link to comment Share on other sites More sharing options...
SLW210 Posted August 12 Share Posted August 12 Did you try the LISP in this thread? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 12 Share Posted August 12 8 hours ago, Ajmal said: please someone help with this, Have lots of objects in the block. I need to change the Hatch background colour to none. now am doing one by one Post an example drawing of before and after of what you're looking for. Quote Link to comment Share on other sites More sharing options...
Ajmal Posted August 13 Share Posted August 13 14 hours ago, ronjonp said: Post an example drawing of before and after of what you're looking for. while I am using this, all hatches will add background 0,0,0. if there is no background colour also will be changed to this I have different Hatch background colours. Someone is true colours someone is index colour and someone is without background colour (none). Need all hatch without background colour (need to set none). but I don't want to change any hatch type, pattern, and general colour. need to change background to none HATCH.dwg Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 13 Share Posted August 13 (edited) I'm not sure I follow .. the code HERE does that already? Nevermind .. I see what you are saying... let me take a look. Try this version: (defun c:foo (/ a c d) ;; RJP » 2023-08-13 ;; Sets hatch background color in blocks to 'none' (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-put-EntityColor c -939524096) (vla-put-backgroundcolor o c) ) ) ) ) ) (foreach l a (vlax-put l 'lock -1)) (vla-regen d acallviewports) (princ) ) Edited August 13 by ronjonp 2 1 Quote Link to comment Share on other sites More sharing options...
Ajmal Posted August 15 Share Posted August 15 On 13/08/2023 at 19:26, ronjonp said: I'm not sure I follow .. the code HERE does that already? Nevermind .. I see what you are saying... let me take a look. Try this version: (defun c:foo (/ a c d) ;; RJP » 2023-08-13 ;; Sets hatch background color in blocks to 'none' (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-put-EntityColor c -939524096) (vla-put-backgroundcolor o c) ) ) ) ) ) (foreach l a (vlax-put l 'lock -1)) (vla-regen d acallviewports) (princ) ) wow great. thanks, ronjonp Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 15 Share Posted August 15 5 hours ago, Ajmal said: wow great. thanks, ronjonp 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.