Author Topic: Override Dimension text  (Read 1748 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Override Dimension text
« on: March 15, 2011, 09:14:30 AM »
How would I make this work with alternate dimensions?

Code: [Select]
(defun C:dc (/ ss changed count cmd ent strdim)
  (princ "OVERWRITE")
  (setq cmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq ss (ssget))
  (setq count 0)
  (setq changed 0)
  (command "undo" "begin")
  (if (/= ss nil)
    (repeat (sslength ss)
      (progn
        (setq ent (entget (ssname ss count)))
        (if (= (cdr(assoc 0 ent)) "DIMENSION")
          (progn
            (setq verada(tblsearch "BLOCK" (cdr(assoc 2 ent))))
            (setq niktu(entnext (cdr(assoc -2 verada)))); ent name
            (while (boundp 'niktu); has niktu been set?
              (setq niktuent (entget niktu))
              (if (and(= (cdr(assoc 0 niktuent))"MTEXT")(> (strlen (cdr(assoc 1 niktuent)))0))
                (setq strdim (cdr(assoc 1 niktuent)))
              ); end if
              (setq niktu(entnext niktu))
            ); end while
            (if (/= strdim nil)
      (progn
        (COMMAND ".DIM1" "NEW" strdim (ssname ss count) "")
(setq changed (1+ changed))
      ); end progn
            ); end if
    (setq strdim nil)
  ); end progn
        ); end if
        (setq count (1+ count))
      ); end progn
    ); end repeat
    (princ "No objects were selected. ")
  ); end if
  (if (/= ss nil)
    (progn
      (princ (sslength x))
      (if (= 1 (sslength x))
        (princ " object was selected. ")
        (princ " objects were selected. ")
      )
    ) 
  ) 
  (if (= 0 changed)
    (princ "No dimensions were overwritten.")
    (progn
      (princ changed)
      (if (= 1 changed)
        (princ " dimension was overwritten.")
        (princ " dimensions were overwritten.")
      )
    )
  ) 
  (command "undo" "end")
  (setvar "cmdecho" cmd)
  (princ)
)

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Override Dimension text
« Reply #1 on: March 15, 2011, 08:11:55 PM »
I do not know what version you are using or maybe you just want to roll your own; but do you know about this app from Autodesk Labs?

Quote
DimensionPatrol for AutoCAD
June 2010

Dimension Patrol highlights dimensions in a drawing for which the user has customized the dimension text. These are dimensions that may not display the correct size of they entity they are attached to if the drawing is edited. Potentially errant dimensions are highlighted by drawing a colored rectangle behind the dimension.

Link will take you to their catalog page.  You will the app a 1/3 of the way down.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

A_LOTA_NOTA

  • Guest
Re: Override Dimension text
« Reply #2 on: April 08, 2011, 09:25:41 AM »
Thanks for the reply. Unless I'm reading this wrong "DimensionPatrol" only highlights the dimensions that have been changed. I want to select a dimension, then over write with the dimension text. So if the dimension is 10'-0" then it is stretched it still reads 10'-0". The code I posted does that now but it doesn't work with alternate dimension text.

A_LOTA_NOTA

  • Guest
Re: Override Dimension text
« Reply #3 on: April 08, 2011, 02:29:16 PM »
Not sure this was the way to go but it's getting close to doing what I want. I think the only thing it's not doing it stacking the factions.

Code: [Select]
(defun C:dc (/ cmd ss count changed ent dimMeasure)
  (setq cmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq ss (ssget))
  (setq count 0)
  (setq changed 0)
  (if (/= ss nil)
    (repeat (sslength ss)
      (progn
        (setq ent (entget (ssname ss count)))
        (if (= (cdr(assoc 0 ent)) "DIMENSION")
          (progn
    (setq dimMeasure (cdr (assoc 1 ent)))
    (if (= dimMeasure "")
      (progn
(setq dimMeasure (cdr (assoc 42 ent)))
); end progn
      ); end if
    (if (/= dimMeasure nil)
      (progn
(if (= (getvar "DIMALT") 1); has alternat units
  (progn
    (setq dimMeasure (strcat
       (rtos (cdr (assoc 42 ent)) (getvar "DIMLUNIT") (getvar "DIMDEC")); Primary dim text
       (getvar "DIMPOST"); Alternate Above / Below
       "["(rtos (* dimMeasure (getvar "DIMALTF")) (getvar "DIMALTU")(getvar "DIMALTD"))"]")); Anternate dim text
    ); end progn
  (progn
    (setq dimMeasure (rtos (cdr (assoc 42 ent)) (getvar "DIMLUNIT") (getvar "DIMDEC"))); Primary dim text
    ); end progn
  ); end if

(setq ent (subst (cons 1 dimMeasure) (assoc 1 ent) ent)); replaces the existing string
(entmod ent)

(setq changed (1+ changed))
      ); end progn
            ); end if
    (setq dimMeasure nil)
  ); end progn
        ); end if
        (setq count (1+ count))
      ); end progn
    ); end repeat
    (progn
      (princ "No objects were selected. ")
      ); end progn
    ); end if

(if (/= ss nil)
    (progn
      (princ (sslength x))
      (if (= 1 (sslength x))
        (princ " object was selected. ")
        (princ " objects were selected. ")
      )
    ) 
  ) 
  (if (= 0 changed)
    (princ "No dimensions were overwritten.")
    (progn
      (princ changed)
      (if (= 1 changed)
        (princ " dimension was overwritten.")
        (princ " dimensions were overwritten.")
      )
    )
  )
  (setvar "cmdecho" cmd)
  (princ)
); end defun
« Last Edit: April 08, 2011, 04:12:33 PM by A_LOTA_NOTA »