Exchange Forum > AutoLISP and Visual LISP
Update Dims with dimension text
Update Dims with dimension text

#1

Malcolm
Join Date:
10-18-2007
Is there an easy way to update dimensions with the actual dimension text. We sometimes have to draw an assembly to scale and then stretch a long section back and re-type the dimension text, and then add the section break lines. Is this possible?
Malcolm
Update Dims with dimension text

#2

Zeanor
Join Date:
07-26-2007
Malcolm,
We never explode dimensions at my firm. It's not acceptable. From what you are describing you don't either. In the rare instances where the layout would look better we use this DimMtext function to change the dimension value to it's mtext value before stretching the objects in the layout.
Zeanor
 
Code:
(defun c:DimMtext (/ EntDxfs Entity Number Selection Text)
  (princ "\nSelect dimensions to change to mtext value: ")
  (if (setq Selection (ssget (list (cons 0 "dimension"))))
    (progn
      (command "undo" "begin")
      (setq Number 0)
      (repeat (sslength Selection)
        (setq Entity (ssname Selection Number))
        (command "undo" "mark")
        (command "explode" Entity)
        (setq EntDxfs (entget (entlast)))
        (setq Text (cdr (assoc 1 EntDxfs)))
        (command "undo" "back")
        (setq EntDxfs (entget Entity))
        (entmod (subst (cons 1 Text) (assoc 1 EntDxfs) EntDxfs))
        (setq Number (1+ Number))
      )
      (command "undo" "end")
    )
  )
  (princ)
)
Update Dims with dimension text

#3

Chandler
Join Date:
09-04-2007
Malcolm,
If your talking about faking your dimension values, here's a version that we use once in a while.
Chandler
 
Code:
(defun c:FakeDims (/ BlkName DxfList EntBlk EntName EntType Found Num SelSet Text)
  (princ "\nSelect Dimensions to fake: ")
  (if (setq SelSet (ssget '((0 . "DIMENSION"))))
    (progn
      (command "UNDO" "BEGIN")
      (setq Num 0)
      (repeat (sslength SelSet)
        (setq EntName (ssname SelSet Num))
        (setq DxfList (entget EntName))
        (setq BlkName (cdr (assoc 2 DxfList)))
        (setq EntBlk (tblobjname "BLOCK" BlkName))
        (setq Found nil)
        (while (not Found)
          (setq EntBlk (entnext EntBlk))
          (setq DxfList (entget EntBlk))
          (setq EntType (cdr (assoc 0 DxfList)))
          (if (= EntType "MTEXT")
            (progn
              (setq Text (cdr (assoc 1 DxfList)))
              (setq DxfList (entget EntName))
              (entmod (subst (cons 1 Text) (assoc 1 DxfList) DxfList))
              (setq Found t)
            )
          )
        )
        (setq Num (1+ Num))
      )
      (command "UNDO" "END")
    )
    (princ "\nNo Dimensions selected")
  )
  (princ)
)
Update Dims with dimension text

#4

Malcolm
Join Date:
10-18-2007
I tried both versions and they both work equally well.
Thanks for your help.