Urgent Help with dimensions color change

Urgent Help with dimensions color change

Yamishon_Noah
Enthusiast Enthusiast
1,458 Views
9 Replies
Message 1 of 10

Urgent Help with dimensions color change

Yamishon_Noah
Enthusiast
Enthusiast

Hi

 

I have below lisp which changes color of any entities in autocad except dimension.

 

Can we change dimension color also with it?

 

please provide codes..

 

thanks

Yamishon Noah

0 Likes
Accepted solutions (1)
1,459 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

Dimensions behave similarly as blocks. Changing just a color property does not help.

So change the layer or style. See this LESSON

 

0 Likes
Message 3 of 10

Yamishon_Noah
Enthusiast
Enthusiast

Hi

 

Thanks for your reply,

 

May note I have another lisp which changes block color as well means it is possible in blocks.

 

Only problem with dimension.

 

I need some routine for it to attain.

 

Pls help

 

Yamishon

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

Although I don't think this is good idea but here you go.

 

(defun c:Ch_Clr (/ clr i ss ent elst)
  
  (vl-load-com)
  
  (if (and (setq clr     (acad_colordlg 0))
           (setq i -1 ss (ssget "_:L")))
    
    (while (setq ent (ssname ss (setq i (1+ i))))
      (if (= "DIMENSION" (cdr (assoc 0 (entget ent))))
        (progn
          (setpropertyvalue ent "Dimclrd" clr)
          (setpropertyvalue ent "Dimclre" clr)
          (setpropertyvalue ent "Dimclrt" clr))
        (progn
          (setq elst
                 (vl-remove-if
                   (function
                     (lambda (x)
                       (vl-position (car x) '(62 420)))) (entget ent)))
          
          (entmod (append elst (list (cons 62 clr))))))))
  (princ))
  
;;;  (alert (strcat
;;;           "\n  message 1"
;;;           "\n  message 2"
;;;           )
;;;         )

 

Message 5 of 10

Yamishon_Noah
Enthusiast
Enthusiast

That's awesomely worked well..

 

Thanks a lot..

 

There's one thing, There's "dot" in cyan color which is part of dimension you can see in picture below.

 

This dot color is not changed..

Any way out

 

 

 

 

0 Likes
Message 6 of 10

ВeekeeCZ
Consultant
Consultant
(defun c:Ch_Clr (/ clr i ss ent elst)
  
  (vl-load-com)
  
  (if (and (setq clr     (acad_colordlg 0))
           (setq i -1 ss (ssget "_:L")))
    
    (while (setq ent (ssname ss (setq i (1+ i))))
      (if (= "DIMENSION" (cdr (assoc 0 (entget ent))))
        (progn
          (setpropertyvalue ent "Color" clr)
          (setpropertyvalue ent "Dimclrd" clr)
          (setpropertyvalue ent "Dimclre" clr)
          (setpropertyvalue ent "Dimclrt" clr))
        (progn
          (setq elst
                 (vl-remove-if
                   (function
                     (lambda (x)
                       (vl-position (car x) '(62 420)))) (entget ent)))
          
          (entmod (append elst (list (cons 62 clr))))))))
  (princ))
Message 7 of 10

Yamishon_Noah
Enthusiast
Enthusiast

Thanks a lot.

I appreciate lot too.

 

One problem, Leader lines are not changing color..

 

Please help

 

Yamishon

 

 

0 Likes
Message 8 of 10

Yamishon_Noah
Enthusiast
Enthusiast

@ВeekeeCZ I Found this for leaders... is it possible to combine both?

(defun C:ch_Clr2 (/ ss ssn i obj liste col)
  (vl-load-com)
    (setq i -1 n 0 d 0 m 0 col (fix (acad_colordlg 0)))
    (if (setq ss (ssget))
        (repeat (sslength ss)
            (setq ssn (ssname ss (setq i (1+ i)))
                  obj (vlax-ename->vla-object ssn)
                  liste (cons (cons obj i) liste)
                  )
            )
          )
    (foreach lt liste
        (cond ((eq "AcDbLeader" (vla-get-objectname (setq obj (car lt))))
               (setq n (1+ n))
               (vla-put-DimensionLineColor obj col)
               )

              ((eq "AcDbMLeader" (vla-get-objectname (setq obj (car lt))))
               (setq m (1+ m))
               (command "_change" (vlax-vla-object->ename obj) "" "_p" "_c" col "")
               )
              )
        )
    
           )
    (princ)
    ) 
0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Sure.

 

(vl-load-com)

(defun c:Ch_Clr (/ clr i ss ent elst)
  
  (if (and (setq clr (acad_colordlg 0))
	   (setq i -1
		 ss (ssget "_:L")))
    
    (while (setq ent (ssname ss (setq i (1+ i))))
      
      (cond ((= "DIMENSION" (cdr (assoc 0 (entget ent))))
	     (setpropertyvalue ent "Dimclrd" clr)
	     (setpropertyvalue ent "Dimclre" clr)
	     (setpropertyvalue ent "Dimclrt" clr)
	     )
	    ((= "LEADER" (cdr (assoc 0 (entget ent))))
	     (setpropertyvalue ent "Dimclrd" clr)
	    )
	    ((= "MULTILEADER" (cdr (assoc 0 (entget ent))))
	     (setpropertyvalue ent "TextColor" clr)
	     (setpropertyvalue ent "LeaderLineColor" clr)
	    ))

      (setq elst (vl-remove-if '(lambda (x) (vl-position (car x) '(62 420))) (entget ent)))
      (entmod (append elst (list (cons 62 clr))))))
  (princ)
  )
Message 10 of 10

Yamishon_Noah
Enthusiast
Enthusiast

@ВeekeeCZ You saved me lot...

 

Thanks so much for your help on time..

I am curious to know one more thing from you, now am using below code for changing color for blocks.. is it possible to merge these two lisp? or in your code? That would save me more... @ВeekeeCZ

 

Yamishon

 

0 Likes