wee Posted November 16, 2020 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
ronjonp Posted November 16, 2020 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
wee Posted November 16, 2020 Author 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
ronjonp Posted November 16, 2020 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
wee Posted November 18, 2020 Author Posted November 18, 2020 Yes...That did the trick. Thank You very much.... Brian Quote
ronjonp Posted November 18, 2020 Posted November 18, 2020 3 hours ago, wee said: Yes...That did the trick. Thank You very much.... Brian Glad to help. Quote
Ajmal Posted July 4, 2023 Posted July 4, 2023 (setq c (vla-get-backgroundcolor o)) (vla-setrgb c 0 0 0) (vla-put-backgroundcolor o C) how can i change to none Quote
Ajmal Posted July 12, 2023 Posted July 12, 2023 how can I remove the hatch background colour means I need to set none Quote
Ajmal Posted August 12, 2023 Posted August 12, 2023 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
ronjonp Posted August 12, 2023 Posted August 12, 2023 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
Ajmal Posted August 13, 2023 Posted August 13, 2023 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
ronjonp Posted August 13, 2023 Posted August 13, 2023 (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, 2023 by ronjonp 2 1 Quote
Ajmal Posted August 15, 2023 Posted August 15, 2023 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
ronjonp Posted August 15, 2023 Posted August 15, 2023 5 hours ago, Ajmal said: wow great. thanks, ronjonp 1 Quote
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.