Overwritten Dims to a new color

Overwritten Dims to a new color

3arizona
Advocate Advocate
1,192 Views
10 Replies
Message 1 of 11

Overwritten Dims to a new color

3arizona
Advocate
Advocate

I found this lisp on a old thread and want to see if someone can add to it?  Current lisp selects all dims that are forced an moves them to a new layer.  The problem is that our dim styles LINES and TEXT Colors are forced.  so there is no visual as to what dims where selected, unless you isolate the new layer. is there a way to for the lisp to move this to a different color (magenta) or change properties to by layer so that it takes on the new layer color properties?   i don't want move the select dims to a different dim style as we have too may different styles. 

 

thanks you fore your time

 

(defun c:test2 ( / ss en ed n dt new old report)

(setq oldcmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq n 0)
(command "layer" "make" "Fake_Dims" "color" 6 "" "")

(prompt "Select dimensions to examine: ")
(setq ss (ssget '((0 . "DIMENSION"))))


(while (< n (sslength ss))
    (setq en (ssname ss n))
    (setq ed (entget en))
    (setq dt (cdr (assoc 1 ed)))
    (if 
      (not (or (= dt "") (wcmatch dt "*<>*")))
      (progn
        (setq old (assoc 8 ed))   
        (setq new (cons 8 "Fake_Dims"))
        (setq ed (subst new old ed))

        (setq old (assoc 62 ed)) 
        (setq new (cons 62 256)) ;;bylayer
        (setq ed (subst new old ed))
        
        (entmod ed)
        );progn
      ):if
    (setq n (1+ n))
  );while

(setvar "cmdecho" oldcmd)
(princ)

);defun

(prompt "FindFakeDims loaded.")
(princ)

 

 

0 Likes
Accepted solutions (3)
1,193 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

You can use >this<, and change this line:

 

          (vlax-put obj 'Color 256); = Bylayer

 

to say this instead:

 

          (vlax-put obj 'TextColor 211)

 

replacing the 211 with whatever color would make the text of such Dimensions easily distinguishable.  If done with Text Color, consider maybe not  also changing the Layer, in which case you would eliminate all the Layer-related stuff, but keep the:

 

    (setq obj (vlax-ename->vla-object en))

 

that's currently buried inside the Layer-changing line just preceding, because you need that VLA-object conversion for the Text Color assignment.

Kent Cooper, AIA
0 Likes
Message 3 of 11

3arizona
Advocate
Advocate

Thanks Kent, 

took your advice and went with your lisp to only change text color.   I modified and it works perfect.  Can you help me insert a prompt to window a section or type ALL for entire dwg.   at the moment it set to select entire drawing

(defun c:Test2 ()
(if (setq ss (ssget "_X" '((0 . "DIMENSION") (1 . "~")))); ignores no-override ones; returns nil if it finds none
  (repeat (sslength ss)     
   (setq en (ssname ss 0))
      (if (not (wcmatch (cdr (assoc 1 (entget en))) "*<>*")); override doesn't contain actual measurement
        (vlax-put (setq obj (vlax-ename->vla-object en))
          (vlax-put obj 'textColor 211); = Bylayer
        ); progn
      ); if
      (ssdel en ss)
    ); repeat
  ); progn ['then' -- no 'else' -- do nothing if none found]
(princ)

Here is a copy of what i have.

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant

@3arizona wrote:

... prompt to window a section or type ALL for entire dwg.  

(defun c:Test2 ()
(if (setq ss (ssget "_X" '((0 . "DIMENSION") (1 . "~")))); ignores no-override ones; returns nil if it finds none
  (repeat (sslength ss)     
   (setq en (ssname ss 0))
      (if (not (wcmatch (cdr (assoc 1 (entget en))) "*<>*")); override doesn't contain actual measurement
        (vlax-put (setq obj (vlax-ename->vla-object en))
          (vlax-put obj 'textColor 211); = Bylayer
        ); progn
      ); if
      (ssdel en ss)
    ); repeat
  ); progn ['then' -- no 'else' -- do nothing if none found]
(princ)

Here is a copy of what i have.


 

That is really all you need to do. Remove "_X". Then type ALL when you're prompted for a selection. It behave just like any other selection in autocad.

0 Likes
Message 5 of 11

3arizona
Advocate
Advocate

Kent, is it also possible to change the color to true color (255, 127, 255)?  this is just in case a dim is overlooked, it will print in color. 

 

 

thanks again for your time.

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@3arizona wrote:

.... is it also possible to change the color to true color (255, 127, 255)?  ....


 

I don't know of a way to do that.  I tried giving a Dimension's text a TrueColor in the Properties palette, to see how it shows in VLA Properties, and oddly, it won't let me use those -- only the "index colors" 0 through 255.  You could give the overall  Dimension a TrueColor and then make its Text color "ByBlock" [0].  I'm not sure how to give a TrueColor to an object via VLA Properties, but you can probably find something with a Search.

Kent Cooper, AIA
0 Likes
Message 7 of 11

3arizona
Advocate
Advocate
Accepted solution

i think this will work fine .   i overlooked an error on the command line.  Can you see if i took off to much or not enough

(defun c:test2 ()
(if (setq ss (ssget  '((0 . "DIMENSION") (1 . "~")))); ignores no-override ones; returns nil if it finds none
  (repeat (sslength ss)     
   (setq en (ssname ss 0))
      (if (not (wcmatch (cdr (assoc 1 (entget en))) "*<>*")); override doesn't contain actual measurement
        (vlax-put (setq obj (vlax-ename->vla-object en))
          (vlax-put obj 'textColor 211); = Bylayer
        ); progn
      ); if
      (ssdel en ss)
    ); repeat
  ); progn ['then' -- no 'else' -- do nothing if none found]
(princ)
)

of your original lisp.  i'm getting error ; error: too few arguments

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

Took away too much:

 

(defun c:GiveItAMoreMeaningfulName (/ ss en)
  (if (setq ss (ssget  '((0 . "DIMENSION") (1 . "~")))); ignores no-override ones; returns nil if it finds none
    (repeat (sslength ss); then   
      (setq en (ssname ss 0))
      (if (not (wcmatch (cdr (assoc 1 (entget en))) "*<>*")); override doesn't contain actual measurement
        (progn ; then
(vlax-put (setq obj (vlax-ename->vla-object en)) (vlax-put obj 'textColor 211); = Bylayer ); progn ); if (ssdel en ss) ); repeat ); if (princ) ); defun
Kent Cooper, AIA
0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

Took away too much:

 

(defun c:GiveItAMoreMeaningfulName (/ ss en)
  (if (setq ss (ssget  '((0 . "DIMENSION") (1 . "~")))); ignores no-override ones; returns nil if it finds none
    (repeat (sslength ss); then   
      (setq en (ssname ss 0))
      (if (not (wcmatch (cdr (assoc 1 (entget en))) "*<>*")); override doesn't contain actual measurement
        (progn ; then
(vlax-put (setq obj (vlax-ename->vla-object en)) (vlax-put obj 'textColor 211); = Bylayer ); progn ); if (ssdel en ss) ); repeat ); if (princ) ); defun

 

Looks like TC is not supported. Possibly changing the format of MTEXT within the mtext-editor will have the same effect, but that seems to be too complicated for this purpose. Anyway, a minor adjustment still has to be done to make the code working. 

0 Likes
Message 10 of 11

Jonathan3891
Advisor
Advisor

I've been using the FindFakeDims lisp for years and it works great. 

 

Puts dimensions that have been overridden on a seperate layer (Fake_Dims) and color magenta.


Jonathan Norton
Blog | Linkedin
0 Likes
Message 11 of 11

3arizona
Advocate
Advocate

Kent, BeekeeCZ

 

thank you both for your time.  

 

 

0 Likes