rcb007 Posted February 22, 2023 Posted February 22, 2023 I have been messing around with the following code which works great when selecting a single picked xref. I am trying to figure out how to apply it to all nested xrefs that are picked; or when a nested xref is picked, it would change the color to all xrefs that are in the group. https://autocadtips1.com/2018/03/07/change-xref-layer-colors-to-one-color/ (defun c:SXC (/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 tb1) (if (setq xr1 (entsel "\nSelect Xref to change color: ") ) ;_ end of setq (progn (setq xr2 (entget (car xr1))) (setq tx1 (cdr (assoc 0 xr2))) (if (and (= tx1 "INSERT") ) ;_ end of and (progn (setq xr3 (cdr (assoc 2 xr2))) (setq xr4 (tblsearch "block" xr3)) (if (setq xr5 (cdr (assoc 1 xr4))) (progn (setq xr6 (strcat xr3 "|*")) (command "-layer" "c" (acad_colordlg 1) xr6 "LW" "0.0" xr6 "PS" "Color" xr6 "") ;;Use color wheel to pick color ) ;_ end of progn (prompt (strcat "\n" xr3 " is not an X-Ref.")) ) ;_ end of if ) ;_ end of progn (prompt "\nNo valid XREF selected") ) ;_ end of if ) ;_ end of progn (princ " ...Nothing selected") ) ;_ end of if (princ) ) Thank you for any help. Quote
mhupp Posted February 23, 2023 Posted February 23, 2023 Maybe https://autocadtips1.com/2011/12/16/autolisp-control-xref-color/ Quote
ronjonp Posted February 23, 2023 Posted February 23, 2023 (edited) Try this: (defun c:clc (/ c d e l n) ;; RJP » 2018-08-17 ;; Set layer color by pick (or (getenv "clc") (setenv "clc" "(62 . 1)")) (cond ((setq c (acad_truecolordlg (read (getenv "clc")))) (setenv "clc" (vl-prin1-to-string (last c))) (setq d (vla-get-activedocument (vlax-get-acad-object))) (while (setq e (nentsel "\nSelect entity to change layer color: ")) (foreach x (append (list (car e)) (cadddr e)) (cond ((setq n (cdr (assoc 8 (entget x)))) (setq l (tblobjname "layer" n)) (and (not (wcmatch n "0")) (entmod (append (entget l) c))) ) ) ) (vla-regen d acactiveviewport) ) ) ) (princ) ) Edited February 23, 2023 by ronjonp Quote
rcb007 Posted February 23, 2023 Author Posted February 23, 2023 Thank you guys, I forgot to use a keyword. "The whole xref and nested xref All the same color". right now, if i select the main xref and change its color to magenta, it only will make it magenta and not the other attchments (nested xrefs) and leaves them alone. Again. sorry for not being clear. Quote
ronjonp Posted February 23, 2023 Posted February 23, 2023 (edited) This might be a bit closer: (defun c:foo (/ c d e f k) (setq k "rjpfoo") (or (getenv k) (setenv k "(62 . 1)")) (cond ((and (setq c (acad_truecolordlg (read (getenv k)))) (setq e (nentsel "\nSelect entity to change all xref layer color: ")) ) (setenv k (vl-prin1-to-string (last c))) (setq d (vla-get-activedocument (vlax-get-acad-object))) (setq f "") (foreach x (cadddr e) (setq f (strcat (cdr (assoc 2 (entget x))) "*," f))) (vlax-for l (vla-get-layers d) (if (wcmatch (vla-get-name l) f) (entmod (append (entget (vlax-vla-object->ename l)) c)) ) ) (vla-regen d acactiveviewport) ) ) (princ) ) Edited February 24, 2023 by ronjonp 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.