Author Topic: Help with fake dimension lisp  (Read 2691 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Help with fake dimension lisp
« on: September 23, 2021, 05:05:19 AM »
Hi i am using this code to check if the drawing is fake dimensions. The code works fine and find all over write dimensions in the drawing and mark them with red number and fill color yellow.  I find that if in a drawing the dimension is not over write but we have change the dimension scale linear and then run the lisp  restore the dimension scale linear to 1 without any alert (and this is not correct). Is it possible not change the dimension scale linear to 1 but mark this dimensions with other color (for example blue numbers and fill green ) ?

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:fakedim (/ i ss)
  3.  (setvar "cmdecho" 0)
  4.  (if (setq ss (ssget "X" '((0 . "DIMENSION") (-3 ("ACAD")))))
  5.    (repeat (setq i (sslength ss))
  6.      (entmod (list (cons -1 (ssname ss (setq i (1- i)))) (list -3 (list "ACAD"))))
  7.    )
  8.    (if (setq ss (ssget "X" '((0 . "DIMENSION") (-4 . "<AND")(-4 . "<NOT")(1 . "")(-4 . "NOT>")(-4 . "<NOT")(1 . "*<>*")(-4 . "NOT>")(-4 . "AND>"))))
  9.      (repeat (setq i (sslength ss))
  10.        
  11.          (PROGN
  12.        (setq iOG(vlax-ename->vla-object (ssname ss (setq i (1- i)))))
  13.          (vlax-put-property iOG "textcolor" 1)
  14.          (vlax-put-property iOG 'TextFill :vlax-true)
  15.          (vlax-put-property iOG 'TextFillColor 2)
  16.        )
  17.      )
  18.      (alert "No fake dimensions in the drawing !!!!")
  19.    )
  20.  )
  21.  (princ)
  22. )
  23.  
  24.  


Thanks

mhupp

  • Bull Frog
  • Posts: 250
Re: Help with fake dimension lisp
« Reply #1 on: September 23, 2021, 09:34:57 AM »
This will do what you asked.

Code: [Select]
(defun c:fakedim (/ SS c i)
  (vl-load-com)
  (setvar "cmdecho" 0)
  (setq c 0 i 0)
  (if (setq ss (ssget "X" '((0 . "DIMENSION"))))
    (foreach dim (mapcar 'cadr (ssnamex ss))
      (setq iOG (vlax-ename->vla-object dim))
      (if (/= (vla-get-LinearScaleFactor iOG) 1)
        (progn
          (vlax-put-property iOG "textcolor" 5)
          (vlax-put-property iOG 'TextFill :vlax-true)
          (vlax-put-property iOG 'TextFillColor 3)
          (setq c (1+ c))
        )
      )
      (if (/= (vla-get-textoverride iOG) "")
        (progn
          (vlax-put-property iOG "textcolor" 1)
          (vlax-put-property iOG 'TextFill :vlax-true)
          (vlax-put-property iOG 'TextFillColor 2)
          (setq i (1+ i))
        )
      )
    )
    (alert "No Dimensions in the drawing !!!!")
  )
  (if (or (> i 0) (> c 0))
    (progn
      (prompt (strcat "\n" (itoa c) " Dimensions with Linear Scale Diffrence"))
      (prompt (strcat "\n" (itoa i) " Dimensions with Text Overwritten"))
    )
  )
  (setvar "cmdecho" 1)
  (princ)
)

--Edit-- updated code to use the same SS and added a counter with report.
 
Don't know what the (-3 ( "ACAD")) is used for can someone explain? might be better to just use    "(if (setq ss (ssget "X" '((0 . "DIMENSION"))))"
« Last Edit: September 23, 2021, 11:38:55 AM by mhupp »

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Help with fake dimension lisp
« Reply #2 on: September 23, 2021, 11:27:54 AM »
You're right...
There is no point if filtering for XDATA - it's obvious that '((0 . "DIMENSION")) is quite enough...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PM

  • Guest
Re: Help with fake dimension lisp
« Reply #3 on: September 23, 2021, 11:31:16 AM »
Hi mhupp. I try  your code but gives me

Code: [Select]
; error: syntax error
Can you fix it?

Thanks

mhupp

  • Bull Frog
  • Posts: 250
Re: Help with fake dimension lisp
« Reply #4 on: September 23, 2021, 11:40:39 AM »
Hi mhupp. I try  your code but gives me

Code: [Select]
; error: syntax error
Can you fix it?

Thanks

Was making some fixes added a counter should work now.

mhupp

  • Bull Frog
  • Posts: 250
Re: Help with fake dimension lisp
« Reply #5 on: September 23, 2021, 11:42:36 AM »
You're right...
There is no point if filtering for XDATA - it's obvious that '((0 . "DIMENSION")) is quite enough...

So it this changing more then the linear scale?

(entmod (list (cons -1 (ssname ss (setq i (1- i)))) (list -3 (list "ACAD"))))

PM

  • Guest
Re: Help with fake dimension lisp
« Reply #6 on: September 23, 2021, 11:52:58 AM »
Now work fine thanks

ScottMC

  • Newt
  • Posts: 191
Re: Help with fake dimension lisp
« Reply #7 on: September 25, 2021, 09:22:50 PM »
Excellent PM! Such a nice tool for "the-reveal"!