Author Topic: modify the text color of dimension  (Read 3336 times)

0 Members and 1 Guest are viewing this topic.

77077

  • Guest
modify the text color of dimension
« 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.



mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: modify the text color of dimension
« Reply #1 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.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

77077

  • Guest
Re: modify the text color of dimension
« Reply #2 on: September 26, 2014, 10:39:01 AM »
I know this is simple ,but I can't , I am sorry

kpblc

  • Bull Frog
  • Posts: 396
Re: modify the text color of dimension
« Reply #3 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
Sorry for my English.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: modify the text color of dimension
« Reply #4 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. )
« Last Edit: September 26, 2014, 11:44:14 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

77077

  • Guest
Re: modify the text color of dimension
« Reply #5 on: September 26, 2014, 11:52:51 AM »
@kpblc , ronjonp
thank you sir. good! is what I want

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: modify the text color of dimension
« Reply #6 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.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7527
Re: modify the text color of dimension
« Reply #7 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:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

BensLisp

  • Guest
Re: modify the text color of dimension
« Reply #8 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..