Jump to content

Change all hatch to a particular layer using accoreconsole


Recommended Posts

Posted

Hello,

 

 Change all hatch (including nested block) to a particular layer using accoreconsole it's possible? please help me!

 

Regards,

Pugazh

Posted

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)
)

 

  • Thanks 1
Posted

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).

 

Posted


(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)
)

  • Thanks 1
Posted

Wow!! Working fine!! Great!! 

Thanks for sparing your valuable time rlx...👏 

Posted
5 minutes ago, Pugazh said:

Wow!! Working fine!! Great!! 

Thanks for sparing your valuable time rlx...👏 

 

you're welcome 😓

  • Like 1
Posted

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

  • Like 1
Posted (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)

:beer:

Edited by rlx
Posted
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.

 

Posted

(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)
)

  • Thanks 1
Posted
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 :) :beer:

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...