JWisniowski Posted December 11, 2023 Posted December 11, 2023 I am looking to: 1. Select all hatches 2. Change all hatch background color to None. That is it. i have tried so may different ways and cannot get it to work. Any assistance would be greatly appreicated. (defun c:ChangeHatchColor () (vl-load-com) (setq ss (ssget "X" '((0 . "HATCH")))) (if ss (progn (setq len (sslength ss)) (repeat len (setq ent (ssname ss (setq len (1- len)))) (vl-cmdf "_chprop" ent "" "b" "none") ) (princ "\nBackground color set to none for all hatches.") ) (princ "\nNo hatches found.") ) (princ) ) Quote
Steven P Posted December 11, 2023 Posted December 11, 2023 (edited) What does your cad do when you type into the command line "chprop" <select entities> "b" Noting here that solid hatches don't have a background colour, you might want to exclude them from the selection set (dxf code 2, 'Solid') and you can also chprop an entire selection set, you don't need to loop through each entity in turn to do so. However the fix is to look at the chprop line, run it via the command line and see what happens Edited December 11, 2023 by Steven P Quote
JWisniowski Posted December 11, 2023 Author Posted December 11, 2023 Steven, Thanks for the reply. The problem with CHPROP is that you cannot "dig into" the Pattern Properties. The CHPROP only gives you "General" options to change. I am just realizing that most of my lisp deals with these options. This is turning into a bit of a bust. Quote
JWisniowski Posted December 11, 2023 Author Posted December 11, 2023 39 minutes ago, Steven P said: What does your cad do when you type into the command line "chprop" <select entities> "b" Noting here that solid hatches don't have a background colour, you might want to exclude them from the selection set (dxf code 2, 'Solid') and you can also chprop an entire selection set, you don't need to loop through each entity in turn to do so. However the fix is to look at the chprop line, run it via the command line and see what happens I am getting somewhere.... No it wont let me just run the "-HATCHEDIT"..... It keeps my selection up. (setq all-hatches (ssget "_X" '((0 . "HATCH")))) (if all-hatches (progn (command "_SELECT" all-hatches) ; Select all hatches (command "-HATCHEDIT" "CO" "." ".") ; Change hatch fill to none (princ (strcat "\n" (itoa (sslength all-hatches)) " hatches modified.")) ) (princ "\nNo hatches found.") ) (princ) ) Quote
Steven P Posted December 11, 2023 Posted December 11, 2023 I have this somewhere but can't remember where (140 LISP files and 3 times that many snippets, got to give the brain time to think. I think you'll have to look at vla-put-property-backgroundcolor or something like that. A quick check gives me the error " ; error: lisp value has no coercion to VARIANT with this type " - I'll have to remember what I saw before Quote
JWisniowski Posted December 11, 2023 Author Posted December 11, 2023 (setq all-hatches (ssget "_X" '((0 . "HATCH")))) (if all-hatches (progn (setq total-hatches (sslength all-hatches)) (setq counter 0) (while (< counter total-hatches) (setq hatch (ssname all-hatches counter)) ; Change the hatch fill to none for each hatch individually (command "-HATCHEDIT" hatch "CO" "." ".") (setq counter (1+ counter)) ) (princ (strcat "\n" (itoa total-hatches) " hatches modified.")) ) (princ "\nNo hatches found.") ) (princ) ) 1 Quote
Steven P Posted December 11, 2023 Posted December 11, 2023 (edited) You could add this in too: (ssget "_X" '((0 . "HATCH") (-4 . "<NOT") (2 . "SOLID") (-4 . "NOT>"))) Solid hatches tend to be a special case, don't have all the properties of the other hatches (like background colours) Edited December 11, 2023 by Steven P Quote
ronjonp Posted December 12, 2023 Posted December 12, 2023 On 12/11/2023 at 8:30 AM, Steven P said: You could add this in too: (ssget "_X" '((0 . "HATCH") (-4 . "<NOT") (2 . "SOLID") (-4 . "NOT>"))) Solid hatches tend to be a special case, don't have all the properties of the other hatches (like background colours) Or this: (ssget "_X" '((0 . "HATCH") (2 . "~SOLID"))) 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.