plackowski Posted December 27, 2016 Posted December 27, 2016 I think I'm encountering the same problem that was not resolved here. I'm trying to set all the layers of an xref to layer 251. I found two codes online, posted below. CVX: (defun c:cvx (/ ent_data);;changes all layers in selected xref to color 251 (setq ent_data (entget (car (entsel)))) (command "-layer" "Color" 251 (strcat (cdr (assoc 2 ent_data)) "*")"") ) X251: (defun C:X251 (/ EN L X ad layers) (command "UNDO" "BEGIN") (setq EN (nentsel "\nSelect Xref: ") L (cdr (assoc 8 (entget (car EN)))) X (substr L 1 (vl-string-position (ascii "|") L)) ) (setq AD (vla-get-ActiveDocument (vlax-get-Acad-Object)) layers (vla-get-Layers ad)) (if (/= (vl-string-search "|" L) nil) (progn (vlax-for layer layers (if (/= (vl-string-search (strcat X "|") (vla-get-name layer)) nil)(vla-put-Color layer 251)) ) (command ".REGEN") ) (princ "Not an Xref!") ) (prin1) (command "UNDO" "END") ) I used the CVX routine for a while, until I discovered that it doesn't work if I select xrefs that are attached to overlaid xrefs. So I tried switching to the X251 routine, but if I use UNDO, the changes aren't reflected until I REGEN the drawing. I tried using an undo group as suggested in the linked post, but that didn't change the result. Any advice? Quote
Roy_043 Posted December 28, 2016 Posted December 28, 2016 Try: (defun c:cvx ( / lst) ; Changes all layers in selected xref to color 251. (if (and (setq lst (nentsel)) (= 4 (length lst)) ) (command "_.-layer" "_color" 251 (strcat (cdr (assoc 2 (entget (car (cadddr lst))))) "|*") "") ) (princ) ) 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.