I am looking for code to change the color of all xref dependant layers to color 251, without autocad turning "on" all xref layers.
|
I am looking for code to change the color of all xref dependant layers to color 251, without autocad turning "on" all xref layers.
Code:(defun c:xr-c(/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 xclr ocmd llist temp1) ; Change all the layers of an xref to selected color. (vl-load-com) (setq ocmd (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_.undo" "_end") (command "_.undo" "_group") (if (setq xr1 (entsel "\nSelect xref to change color of all layers: ")) (progn (setq xr2 (entget (car xr1))) (setq tx1 (cdr (assoc 0 xr2))) (if (and (= tx1 "INSERT") (setq xr3 (cdr (assoc 2 xr2))) (setq xr4 (tblsearch "block" xr3)) (setq xr5 (cdr (assoc 1 xr4))) ) (if (setq xclr (acad_colordlg 251)) (progn (if (assoc 62 xr2) (entmod (subst (cons 62 xclr) (assoc 62 xr2) xr2)) (entmod (append xr2 (list (cons 62 xclr)))) ) (setq xr6 (strcat xr3 "|")) (setq llist (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for item llist (if (vl-string-search xr6 (vlax-get item 'Name)) (progn (setq temp1 (vlax-get item 'TrueColor)) (vlax-put temp1 'ColorIndex (rtos xclr 2 0)) (vlax-put item 'TrueColor temp1) ) ) ) ) ) (prompt "\n No X-Ref selected.") ) ) (prompt "\n Nothing selected") ) (command "_.regenall") (command "_.undo" "_end") (setvar "cmdecho" ocmd) (princ) )
This is great, but I need it to automatically select all xrefs (not prompt for a selection), and auto set the colors to 251 (no color dialog box). Thanks
I know how to change the layer colors. The problem occurs when I change the color of xref layers that are turned "off". Autocad turns all the xref layers "on" when the layer color is changed.Originally Posted by FRAMEDNLV
Code:(defun c:Test (/ ActDoc) (vlax-for Lay (vla-get-Layers (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))) (if (vl-string-search "|" (vla-get-Name Lay)) (vla-put-Color Lay 251) ) ) (vla-Regen ActDoc acActiveViewport) (princ) )
Perfect! Thank youOriginally Posted by T.Willey
Hi mtubbs,
I love this, could you write one that lets you select on screen individual xref layers to change? That would be awesome if it was possible...
found it!
http://forums.augi.com/showthread.php?t=61726
Last edited by miffbenita848624; 2012-01-12 at 12:01 AM. Reason: found solution