Small Fish Posted February 24, 2011 Posted February 24, 2011 Below is some code written by an unknown author. I have slightly modified it for a acad_colordlg chart. My question is how can I use "Bylayer" or"ByBlock" buttons on the dialogue box? At the moment it produces an error when either of these two buttons is picked. thanks ;;;Attribute color change (defun c:acc (/ attc co) (setq attc (acad_colordlg 256));open colour chart (command "attedit" "y" "*" "*" "*" "c" pause pause) (while (= 1 (logand (getvar "cmdactive") 1)) (command "c" attc "n") );while );defun Quote
pBe Posted February 24, 2011 Posted February 24, 2011 (defun c:acc (/ attc co) (setq attc (acad_colordlg 256));open colour chart (command "attedit" "y" "*" "*" "*" "c" pause pause) (while (= 1 (logand (getvar "cmdactive") 1)) (command "c" [color=blue](cond[/color] [color=blue] ((and (< attc 256)[/color] [color=blue] (> attc 0))[/color] [color=blue] attc)[/color] [color=blue] ((= attc 256)[/color] [color=blue] "Bylayer")[/color] [color=blue] ((= attc 0)[/color] [color=blue] "Byblock")) "n")[/color] );while ) Quote
alanjt Posted February 24, 2011 Posted February 24, 2011 (defun c:acc (/ attc co) (setq attc (acad_colordlg 256));open colour chart (command "attedit" "y" "*" "*" "*" "c" pause pause) (while (= 1 (logand (getvar "cmdactive") 1)) (command "c" [color=blue](cond[/color] [color=blue] ((and (< attc 256)[/color] [color=blue] (> attc 0))[/color] [color=blue] attc)[/color] [color=blue] ((= attc 256)[/color] [color=blue] "Bylayer")[/color] [color=blue] ((= attc 0)[/color] [color=blue] "Byblock")) "n")[/color] );while ) (cond ((cdr (assoc attc '((0 . "ByBlock") (256 . "ByLayer"))))) (attc) ) or (defun c:TEst (/ ss c i) (if (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) (setq c (acad_colordlg 256)) ) (repeat (setq i (sslength ss)) (foreach a (vlax-invoke (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'GetAttributes) (vla-put-color a c) ) ) ) (princ) ) Quote
Small Fish Posted February 24, 2011 Author Posted February 24, 2011 many thanks Alan and Pbe SF Quote
Lee Mac Posted February 25, 2011 Posted February 25, 2011 This thread spurred me to update my ancient code from here - perhaps a little overkill, but since I enjoyed writing it, I added it to my site: http://lee-mac.com/attributecolour.html Enjoy! Quote
alanjt Posted February 25, 2011 Posted February 25, 2011 (edited) I still can't imagine why people would want to change the color of an attribute. Nice coding BTW, Lee. I like the menu. Edited February 25, 2011 by alanjt Quote
Lee Mac Posted February 25, 2011 Posted February 25, 2011 I still can't imagine why people would want to change the color of an attribute. *shrug* judging by this thread and the other one I linked to, it seemed to be requested by a select few Nice coding BTW, Lee. I like the menu. Cheers dude, was fun to write Quote
pBe Posted February 25, 2011 Posted February 25, 2011 (cond ((cdr (assoc attc '((0 . "ByBlock") (256 . "ByLayer"))))) (attc) ) Never thought of doing it that way so... my version would be (defun c:test (/ disTag attc) (vl-load-com) (if (and (setq disTag (car (nentsel "\nSelect Attribute: "))) (setq attc (acad_colordlg 256)) ) (vla-put-color (vlax-ename->vla-object distag) [color=blue](cond ((car (assoc attc '((0 . "ByBlock") (256 . "ByLayer")))))[/color] [color=blue](attc))))[/color] (princ) ) Thanks Alanjt This thread spurred me to update my ancient code from here - perhaps a little overkill, but since I enjoyed writing it, I added it to my site: http://lee-mac.com/attributecolour.html Enjoy! Nice, simple like that Quote
alanjt Posted February 25, 2011 Posted February 25, 2011 Never thought of doing it that way so... my version would be (defun c:test (/ disTag attc) (vl-load-com) (if (and (setq disTag (car (nentsel "\nSelect Attribute: "))) (setq attc (acad_colordlg 256)) ) (vla-put-color (vlax-ename->vla-object distag) [color=blue](cond ((car (assoc attc '((0 . "ByBlock") (256 . "ByLayer")))))[/color] [color=blue](attc))))[/color] (princ) ) Thanks Alanjt Nice, simple like that No, only command required "ByLayer" and "ByBlock". Entmod and VLA use the actual number. Quote
troggarf Posted February 26, 2011 Posted February 26, 2011 I sometime pick up drafting work from a company who has a bunch of drafters who never had any training in drafting or cad. They change the color of ATTs because they either don't know how, or don't want to insert blocks with different names. So they just change the color of the Atts to distinguish the "different" blocks. Also, most of them have AutoCAD LT and cant extract attributes so they change the values of the ATTs and sort them by color so they can add up the values later. I know it's crazy but it would be harder to get some of these guys to change than it is for me to deal with it once in a while... 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.