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

0 Members and 1 Guest are viewing this topic.

PM

  • Bull Frog
  • Posts: 275
Help with fake dimension lisp
« on: Today at 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

  • Newt
  • Posts: 31
Re: Help with fake dimension lisp
« Reply #1 on: Today at 09:34:57 AM »
This will do what you asked.

Code: [Select]
(defun c:fakedim (/ i ss)
  (vl-load-com)
  (setvar "cmdecho" 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)
        )
      )
    )
    (if (setq ss (ssget "X" '((0 . "DIMENSION") (-4 . "<AND") (-4 . "<NOT") (1 . "") (-4 . "NOT>") (-4 . "<NOT") (1 . "*<>*") (-4 . "NOT>") (-4 . "AND>"))))
      (foreach dim (mapcar 'cadr (ssnamex ss))
        (setq iOG (vlax-ename->vla-object dim))
        (vlax-put-property iOG "textcolor" 1)
        (vlax-put-property iOG 'TextFill :vlax-true)
        (vlax-put-property iOG 'TextFillColor 2)
      )
    )
    (alert "No fake dimensions in the drawing !!!!")
  )
  (princ)
)

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: Today at 09:38:42 AM by mhupp »