Pugazh Posted February 9, 2019 Share Posted February 9, 2019 Hello, Change all hatch (including nested block) to a particular layer using accoreconsole it's possible? please help me! Regards, Pugazh Quote Link to comment Share on other sites More sharing options...
rlx Posted February 9, 2019 Share Posted February 9, 2019 try to feed something like this to your console : (defun c:t1 ( / b l e d ) (if (not (tblsearch "layer" "rlx"))(command "-layer" "new" "rlx" "")) (while (setq b (cdadr (tblnext "block" (not b))))(setq l (cons b l))) (foreach b l (setq e (tblobjname "block" b)) (while (setq e (entnext e)) (if (= (cdr (assoc 0 (setq d (entget e)))) "HATCH") (progn (setq d (subst (cons 8 "rlx") (assoc 8 d) d))(entmod d)))) ) (command "_.regen") (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
Pugazh Posted February 9, 2019 Author Share Posted February 9, 2019 Hello rlx, Thanks for the reply rlx & Nice Code :). Yeah it's working fine in nested block hatch. Could please update code for all hatch need change layer (outside of block hatch also). Quote Link to comment Share on other sites More sharing options...
rlx Posted February 9, 2019 Share Posted February 9, 2019 (defun c:t2 ( / b l e d i s) (if (not (tblsearch "layer" "rlx"))(command "-layer" "new" "rlx" "")) (while (setq b (cdadr (tblnext "block" (not b))))(setq l (cons b l))) (foreach b l (setq e (tblobjname "block" b)) (while (setq e (entnext e)) (if (= (cdr (assoc 0 (setq d (entget e)))) "HATCH") (progn (setq d (subst (cons 8 "rlx") (assoc 8 d) d))(entmod d)))) ) (if (setq s (ssget "x" '((0 . "HATCH")))) (repeat (setq i (sslength s)) (setq d (entget (ssname s (setq i (1- i))))) (entmod (setq d (subst (cons 8 "rlx") (assoc 8 d) d))))) (command "_.regen") (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
Pugazh Posted February 9, 2019 Author Share Posted February 9, 2019 Wow!! Working fine!! Great!! Thanks for sparing your valuable time rlx... Quote Link to comment Share on other sites More sharing options...
rlx Posted February 9, 2019 Share Posted February 9, 2019 5 minutes ago, Pugazh said: Wow!! Working fine!! Great!! Thanks for sparing your valuable time rlx... you're welcome 1 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 9, 2019 Share Posted February 9, 2019 Hi @rlx A few info if you don't mind of course. cons function can create the layer name "rlx" if its not already existed in the drawing file that included in the pair list as this => (cons 8 "rlx") You can shorten the program via removing the progn function and add the entmod right before the subst function like this: (entmod (subst .... etc 1 Quote Link to comment Share on other sites More sharing options...
rlx Posted February 9, 2019 Share Posted February 9, 2019 (edited) 5 hours ago, Tharwat said: Hi @rlx A few info if you don't mind of course. cons function can create the layer name "rlx" if its not already existed in the drawing file that included in the pair list as this => (cons 8 "rlx") You can shorten the program via removing the progn function and add the entmod right before the subst function like this: (entmod (subst .... etc Of course I don't mind Tharwat. Didn't know (or just forgot...Altzheimer or something haha) about the cons 8 but good to know. Funny you mention the entmod. First I had coded it like you said but decided to split it for both clarity and I remembered I had a situation where I had nested too much code and it didn't work any more but not sure if it was vanilla or vla(x) anyways , after splitting it worked again. And else its never really a bad thing to split your code if only for debugging purposes. Now and again some of the mapcar(ish) constructions are a pain to debug because the vlide editor refusus to put a breakpoint where I want it. But if anything, thanx for the advise (hope I don't forget it) Edited February 9, 2019 by rlx Quote Link to comment Share on other sites More sharing options...
Pugazh Posted February 10, 2019 Author Share Posted February 10, 2019 17 hours ago, rlx said: (defun c:t2 ( / b l e d i s) (if (not (tblsearch "layer" "rlx"))(command "-layer" "new" "rlx" "")) (while (setq b (cdadr (tblnext "block" (not b))))(setq l (cons b l))) (foreach b l (setq e (tblobjname "block" b)) (while (setq e (entnext e)) (if (= (cdr (assoc 0 (setq d (entget e)))) "HATCH") (progn (setq d (subst (cons 8 "rlx") (assoc 8 d) d))(entmod d)))) ) (if (setq s (ssget "x" '((0 . "HATCH")))) (repeat (setq i (sslength s)) (setq d (entget (ssname s (setq i (1- i))))) (entmod (setq d (subst (cons 8 "rlx") (assoc 8 d) d))))) (command "_.regen") (princ) ) Hello @rlx How to add (cons 62 256) in this code. Quote Link to comment Share on other sites More sharing options...
rlx Posted February 10, 2019 Share Posted February 10, 2019 (defun c:t5 ( / b l e d i s) (while (setq b (cdadr (tblnext "block" (not b))))(setq l (cons b l))) (foreach b l (setq e (tblobjname "block" b)) (while (setq e (entnext e))(if (= (cdr (assoc 0 (setq d (entget e)))) "HATCH")(entmod (append (subst (cons 8 "rlx") (assoc 8 d) d) '((62 . 256))))))) (if (setq s (ssget "x" '((0 . "HATCH")))) (repeat (setq i (sslength s))(entmod (append (subst (cons 8 "rlx") (assoc 8 (setq d (entget (ssname s (setq i (1- i)))))) d) '((62 . 256)))))) (command "_.regen") (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
Pugazh Posted February 10, 2019 Author Share Posted February 10, 2019 Just now, rlx said: (defun c:t5 ( / b l e d i s) (while (setq b (cdadr (tblnext "block" (not b))))(setq l (cons b l))) (foreach b l (setq e (tblobjname "block" b)) (while (setq e (entnext e))(if (= (cdr (assoc 0 (setq d (entget e)))) "HATCH")(entmod (append (subst (cons 8 "rlx") (assoc 8 d) d) '((62 . 256))))))) (if (setq s (ssget "x" '((0 . "HATCH")))) (repeat (setq i (sslength s))(entmod (append (subst (cons 8 "rlx") (assoc 8 (setq d (entget (ssname s (setq i (1- i)))))) d) '((62 . 256)))))) (command "_.regen") (princ) ) Perfect!! Thank you @rlx 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.