TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: 77077 on September 26, 2014, 09:14:04 AM

Title: modify the text color of dimension
Post by: 77077 on September 26, 2014, 09:14:04 AM
hello.

I need a routine to modify the text color of dimension,

step.
1. enter command .
2. Pop-up color dialog , Choose a color
3. multi-select dimension 

only modify the text color.


Title: Re: modify the text color of dimension
Post by: mjfarrell on September 26, 2014, 09:27:25 AM
hello.

I need a routine to modify the text color of dimension,

step.
1. enter command .
2. Pop-up color dialog , Choose a color
3. multi-select dimension 

only modify the text color.

That's a nice request, however most here would prefer you attempt some code on your own, and then ask for help to solve code challenges.
Title: Re: modify the text color of dimension
Post by: 77077 on September 26, 2014, 10:39:01 AM
I know this is simple ,but I can't , I am sorry
Title: Re: modify the text color of dimension
Post by: kpblc on September 26, 2014, 11:16:08 AM
Terrible mix :)
Code: [Select]
(vl-load-com)

(defun tt (/ adoc color selset)
  (if (and (setq color (acad_colordlg (cond
                                        ((= (strcase (vl-princ-to-string (getvar "cecolor"))) "BYLAYER")
                                         (cdr (assoc 62 (entget (tblobjname "layer" (getvar "clayer")))))
                                         )
                                        ((= (strcase (vl-princ-to-string (getvar "cecolor"))) "BYBLOCK")
                                         0
                                         )
                                        (t (atoi (getvar "cecolor")))
                                        ) ;_ end of cond
                                      ) ;_ end of acad_colordlg
                 ) ;_ end of setq
           (= (type (setq selset (vl-catch-all-apply
                                   (function
                                     (lambda (/ tab item ss)
                                       (setq ss (ssget "_:L" '((0 . "DIM*"))))
                                       (repeat (setq tab  nil
                                                     item (sslength ss)
                                                     ) ;_ end setq
                                         (setq tab (cons (ssname ss (setq item (1- item))) tab))
                                         ) ;_ end of repeat
                                       ) ;_ end of lambda
                                     ) ;_ end of function
                                   ) ;_ end of vl-catch-all-apply
                          ) ;_ end of setq
                    ) ;_ end of type
              'list
              ) ;_ end of =
           ) ;_ end of and
    (progn
      (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
      (foreach ent (mapcar (function vlax-ename->vla-object) selset)
        (vla-put-textcolor ent color)
        ) ;_ end of foreach
      (vla-endundomark adoc)
      ) ;_ end of progn
    ) ;_ end of if
  (princ)
  ) ;_ end of defun
Title: Re: modify the text color of dimension
Post by: ronjonp on September 26, 2014, 11:38:40 AM
Here's my "free fish"  :)  ... although this can be achieved via the property palette too without any code.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ r o n)
  2.   (if (and (setq n (acad_colordlg 256 t)) (setq r (ssget ":L" '((0 . "DIMENSION")))))
  3.     (foreach o (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex r))))
  4.       (vla-put-textcolor o n)
  5.     )
  6.   )
  7.   (princ)
  8. )
Title: Re: modify the text color of dimension
Post by: 77077 on September 26, 2014, 11:52:51 AM
@kpblc , ronjonp
thank you sir. good! is what I want
Title: Re: modify the text color of dimension
Post by: alanjt on October 06, 2014, 01:01:50 PM
Here's my "free fish"  :)  ... although this can be achieved via the property palette too without any code.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ r o n)
  2.  
Those variables. lol.
Title: Re: modify the text color of dimension
Post by: ronjonp on October 06, 2014, 04:07:39 PM
Here's my "free fish"  :)  ... although this can be achieved via the property palette too without any code.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ r o n)
  2.  
Those variables. lol.
:whistling:
Title: Re: modify the text color of dimension
Post by: BensLisp on October 14, 2014, 04:40:10 PM
I wrote this awhile back due to operators changing text or part of text and leader to a non-bylayer color and then being required to change the color. Hope this helps...if not sorry.... stilll just a rookie..