Jump to content

Recommended Posts

Posted

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

Posted
(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
)

Posted
(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)
)

Posted (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 by alanjt
Posted
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 :unsure:

 

Nice coding BTW, Lee. I like the menu.

 

Cheers dude, was fun to write :)

Posted
(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 :thumbsup:

Posted
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 :thumbsup:

No, only command required "ByLayer" and "ByBlock". Entmod and VLA use the actual number.
Posted

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...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...