Aftertouch Posted June 8, 2017 Share Posted June 8, 2017 Hello all, I was looking for a code that allows me to select a object of a xref, and asks me to change the layers color. now i found the code below... (defun c:ChangeLayerColor (/ Sel EntList DataList cnt Num ClrNum EntData) (if (setq Sel (nentsel "\n Select object to change layers color: ")) (progn (if (> (length Sel) 2) (setq EntList (cons (car Sel) (last Sel))) (setq EntList (cons (car Sel) EntList)) ) (setq DataList (mapcar '(lambda (x / EntData) (setq EntData (entget x)) (cons (cdr (assoc 0 EntData)) (cdr (assoc 8 EntData))) ) EntList ) ) (setq cnt 0) (textscr) (prompt "\n Select number of layer to change color: ") (foreach lst DataList (prompt (strcat "\n " (itoa cnt) " - " (cdr lst) " - Object [ " (car lst) " ]")) (setq cnt (1+ cnt)) ) (while (and (not (setq Num (getint (strcat "\n Select number between 0 - " (itoa (1- cnt)) ": ")))) (not (< 0 Num (1- cnt))) ) ) (graphscr) (if (and Num (setq ClrNum (acad_colordlg 253))) (progn (setq EntData (entget (tblobjname "Layer" (cdr (nth Num DataList))))) (entmod (subst (cons 62 ClrNum) (assoc 62 EntData) EntData ) ) (command "_.Regen") ) ) ) ) (princ) ) But this gets all objects of the selected... So if i select a block it gets the 'XREF' layer, the block layer, the hatch in the blocks layer etc.. and i need to give in a number for wich i want to change. Can this code be stripped down so it instant changes the color of the layer of the selected object. So when i select a block of an xref, it changes the layer the block is on for example. Also... this code only allows Index Colors... how can true colors be added? Thanks in advance. :-) Quote Link to comment Share on other sites More sharing options...
Dadgad Posted June 8, 2017 Share Posted June 8, 2017 I can't help you with a lisp, but the system variable VISRETAIN might be of interest to you. Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted June 8, 2017 Author Share Posted June 8, 2017 I can't help you with a lisp, but the system variable VISRETAIN might be of interest to you. Hey Dadgad, Visretain has absolutely nothing to do with my 'problem'. :-) Quote Link to comment Share on other sites More sharing options...
Dadgad Posted June 8, 2017 Share Posted June 8, 2017 (edited) Hey Dadgad,Visretain has absolutely nothing to do with my 'problem'. :-) Perhaps I am mistaken. I was under the impression that by changing the VISRETAIN setting to 0, that you could essentially override the layer color defined in the original external drawing's layer table, and that your new layer color would be saved within your new drawing's layer table. My apologies, should that not be the case. Edited June 8, 2017 by Dadgad Quote Link to comment Share on other sites More sharing options...
mugsy8 Posted February 7, 2018 Share Posted February 7, 2018 Hello all, Can this code be stripped down so it instant changes the color of the layer of the selected object. So when i select a block of an xref, it changes the layer the block is on for example. Also... this code only allows Index Colors... how can true colors be added? Hi... sorry to necro your thread. but i just joined the forum. I found these and they suit my needs. I can't remember if i modified them or not. I have several others and a couple of my own but these should do what you want. I cant help you with true color as usage of true colors for what i do is generally not permitted. select multiple with color input (defun c:CHCOL (/ ncol ent lst) (while (setq ent (car (nentsel "\nSelect enity on layer: "))) (princ (setq ent (cdr (assoc 8 (entget ent))))) (setq lst (cons ent lst))) (setq ncol (getint "\nEnter index color number: ")) (and lst (mapcar '(lambda (x) (setq ent (entget (tblobjname "layer" x))) (entmod (subst (cons 62 ncol) (assoc 62 ent) ent))) lst)) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 1)) (vl-load-com) select one then color with menu (defun C:CHCOLPICK (/ lay col) (setq lay (cdr (assoc 8 (entget (car (nentsel "\nObject on Layer to assign color to: "))))) col (acad_colordlg (cdr (assoc 62 (tblsearch "layer" lay))) nil) ) (command "_.layer" "_color" col lay "") (princ) ) cheers, mugsy Quote Link to comment Share on other sites More sharing options...
mugsy8 Posted February 8, 2018 Share Posted February 8, 2018 Perhaps I am mistaken. I was under the impression that by changing the VISRETAIN setting to 0, that you could essentially override the layer color defined in the original external drawing's layer table, and that your new layer color would be saved within your new drawing's layer table. My apologies, should that not be the case. VISRETAIN is pretty much just like the reset button on your calculator but for the xref layers. sets all layer overrides back to what is stored in the xref. Cheers, mugsy 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.