Change all Hatch on a Layer

Change all Hatch on a Layer

Anonymous
Not applicable
3,492 Views
25 Replies
Message 1 of 26

Change all Hatch on a Layer

Anonymous
Not applicable

(defun C:H-C ()
(Setq a (ssget "X" '((8 . "Test1"))))(command "-hatchedit" a "p" "ANSI31" "1" "0")
(Setq a (ssget "X" '((8 . "test2"))))(command "-hatchedit" a "p" "SOLID" "1" "0")

(Setq a (ssget "X" '((8 . "Test3"))))(command "-hatchedit" a "p" "ANSI33" "1" "0")
(Setq a (ssget "X" '((8 . "test4"))))(command "-hatchedit" a "p" "DASH" "1" "0")

(Setq a (ssget "X" '((8 . "Test5"))))(command "-hatchedit" a "p" "ANSI33" "1" "0")
(Setq a (ssget "X" '((8 . "test6"))))(command "-hatchedit" a "p" "ANSI31" "1" "0")

)

 

If I have a lot of objects on the layer it doesn't work, where is the mistake?

0 Likes
Accepted solutions (1)
3,493 Views
25 Replies
Replies (25)
Message 21 of 26

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

; error: bad DXF group: (2)


Post your Layer-name-edited version.

Kent Cooper, AIA
0 Likes
Message 22 of 26

Anonymous
Not applicable

(defun C:H-C (/ pairs ss n hatch edata)
(setq pairs '(("XXX_Bohrpfahl_Konstr_N-1_Bestand_Hatch" "ANSI31") ("TEST2_Hatch" "SOLID") ("TEST3_Hatch" "ANSI33") ("TEST4_Hatch" "DASH") ("TEST5_Hatch" "ANSI33") ("TEST6_Hatch" "ANSI31")))
(if (setq ss (ssget "_X" '((0 . "HATCH") (8 . "*_Hatch")))); all Hatch patterns on Layers with such names
(repeat (setq n (sslength ss)); then
(setq
hatch (ssname ss (setq n (1- n))); the Hatch object
edata (entget hatch); its entity data
edata (subst (cons 2 (cadr (assoc (strcase (cdr (assoc 8 edata))) pairs))) (assoc 2 edata) edata); pattern
edata (subst '(41 . 1.0) (assoc 41 edata) edata); scale
edata (subst '(52 . 0.0) (assoc 52 edata) edata); angle
); setq
(entmod edata)
); repeat
); if
(princ)
); defun

0 Likes
Message 23 of 26

Kent1Cooper
Consultant
Consultant

Nothing jumps out at me....  I can't spend time with it right now, but I'll look again.

Kent Cooper, AIA
0 Likes
Message 24 of 26

Anonymous
Not applicable

When I use the Test Layer it works perfekt.

0 Likes
Message 25 of 26

Anonymous
Not applicable

Can it be that the length of the layer name plays a role?

0 Likes
Message 26 of 26

ВeekeeCZ
Consultant
Consultant

This thread is getting old. How about start behaving yourself like you really what to solve the issue?!

This is a simple task and ALL the suggested solutions work flawlessly for the most. So you must use something extraordinary that stops it from working. 

 

- what OS/SW you use

- any vertical?

- any extensions or plugins like Carlson...

 

- post a test drawing where it fails

- post the command-line listing with the cmdecho on 

- post a video with screen capture, the free one from adsk HERE 

 
0 Likes