woodman78 Posted July 28, 2011 Share Posted July 28, 2011 Does anyone have a lisp that would allow me to select an entity in a drawing and the bylayer colour of that layer would change to 253. I have a lot of greying out to do and rather than going through the layer list I thought this might be easier. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 (defun c:test ( / el i la ls ss ) (if (setq ss (ssget)) (repeat (setq i (sslength ss)) (if (not (member (setq la (cdr (assoc 8 (entget (ssname ss (setq i (1- i))))))) ls)) (progn (setq el (entget (tblobjname "LAYER" la)) ls (cons la ls) ) (entmod (subst (cons 62 253) (assoc 62 el) el)) ) ) ) ) (princ) ) Or single: (defun c:test ( / e ) (and (setq e (car (entsel))) (setq e (entget (tblobjname "LAYER" (cdr (assoc 8 (entget e)))))) (entmod (subst (cons 62 253) (assoc 62 e) e)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 28, 2011 Author Share Posted July 28, 2011 I tried both of them LeeMac but neither of them seem to work. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 Did you Regen after using them? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 28, 2011 Author Share Posted July 28, 2011 yeah, tried that but no joy. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 yeah, tried that but no joy. It's simple code, not much can really go wrong - are your layers colours not being changed? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 28, 2011 Author Share Posted July 28, 2011 No. It gives me the option to select something but then nothing happens. The colour remains the same and the item is set to bylayer. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 No. It gives me the option to select something but then nothing happens. The colour remains the same and the item is set to bylayer. Are your objects nested within blocks? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 28, 2011 Author Share Posted July 28, 2011 No wait. I was selecting hatch and it didn't work for that but it does work for lines. My bad. Quote Link to comment Share on other sites More sharing options...
irneb Posted July 28, 2011 Share Posted July 28, 2011 Strange! It works perfectly on my 2011 (even using hatches). Edit: Slight mod on Lee's code (setq *SetLayerColor* 253) (defun c:SetLayerColor (/ e c) (if (setq c (acad_colordlg *SetLayerColor* nil)) (setq *SetLayerColor* c) ) (while (and c (setq e (car (entsel "\nPick entity on layer (Enter to stop): "))) (setq e (entget (tblobjname "LAYER" (cdr (assoc 8 (entget e)))))) ) (entmod (subst (cons 62 c) (assoc 62 e) e)) ) (princ) ) Allows for selecting a different colour, and also works "similar" to LayFrz. If you want it to work on nested entities change entsel to nentsel. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 28, 2011 Share Posted July 28, 2011 vla-put-color is the best way to deal with entities' colors . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 vla-put-color is the best way to deal with entities' colors . Why is that? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 28, 2011 Share Posted July 28, 2011 I have faced the issue which is the OP facing it right now with (cons 62 ......) and with entmod which is not working in some special cases that I also do not know why but with VLA*** it's been doing as needed. Quote Link to comment Share on other sites More sharing options...
sharpooth Posted July 28, 2011 Share Posted July 28, 2011 If the object's color is set to bylayer there is no group 62. You must add in entities group 62 by (cons 62 . 253) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2011 Share Posted July 28, 2011 I think you guys are getting a little confused, we are not changing the colour of the entities, but the colour of the layers - these will always have a DXF 62 code. The entities are only being selected to determine which layers need to be changed, the type of object selected should make no difference. Quote Link to comment Share on other sites More sharing options...
irneb Posted July 29, 2011 Share Posted July 29, 2011 ...but the colour of the layers - these will always have a DXF 62 code.What? You mean you can't set a layer's colour to "ByLayer"???? Quote Link to comment Share on other sites More sharing options...
dober Posted July 29, 2011 Share Posted July 29, 2011 If color adjustment layer, such as image, the color is not changed. Wenn Layerfarbe Einstellung wie Bild, dann wird die Farbe nicht geändert. Quote Link to comment Share on other sites More sharing options...
irneb Posted July 29, 2011 Share Posted July 29, 2011 You didn't mention you were using Pantone/RGB colours. Those are a bit more complex. In such case I'd say the vla route would make for an easier way to adjust. Edit: It is possible to work with these as well using entmod, but they are in the 430 and 420 code though: http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7a3d.htm Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 29, 2011 Share Posted July 29, 2011 I have faced the issue which is the OP facing it right now with (cons 62 ......) and with entmod which is not working in some special cases that I also do not know why but with VLA*** it's been doing as needed. Those issues generally only exist when trying to entmod certain properties of newer type entities (MLeader, etc.) or any annotative object, but color/layer/linetype are not of that list. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 29, 2011 Share Posted July 29, 2011 Oh yeah, here's a color one I did a while back (I took the lazy convert layer object to vla-object route) and a linetype one I did, but it requires DosLib.... (defun c:CLC (/ ss color i layer lst) ;; Change color of selected objects' layer ;; Alan J. Thompson, 07.23.09 / 05.16.11 (if (and (setq ss (ssget)) (setq color (acad_colordlg 1 nil))) (repeat (setq i (sslength ss)) (if (not (member (setq layer (cdr (assoc 8 (entget (ssname ss (setq i (1- i))))))) lst)) (vla-put-color (vlax-ename->vla-object (tblobjname "LAYER" (car (setq lst (cons layer lst))))) color ) ) ) ) (princ) ) (defun c:CLL (/ ss linetype i layer lst) ;; Change linetype of selected objects' layer ;; DosLib required (dos_linetypebox) ;; Alan J. Thompson, 05.16.11 (if dos_linetypebox (if (and (setq ss (ssget)) (setq linetype (dos_linetypebox))) (repeat (setq i (sslength ss)) (if (not (member (setq layer (cdr (assoc 8 (entget (ssname ss (setq i (1- i))))))) lst)) (vla-put-linetype (vlax-ename->vla-object (tblobjname "LAYER" (car (setq lst (cons layer lst))))) linetype ) ) ) ) (progn (alert "DosLib must be loaded!") (command "_.browser" "http://www.en.na.mcneel.com/doslib.htm") ) ) (princ) ) 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.