Author Topic: Parens  (Read 3167 times)

0 Members and 1 Guest are viewing this topic.

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Parens
« on: May 19, 2004, 02:13:03 PM »
Anyone have a lisp routine that they would be willing to share that adds () / [] / {} to an attribute block? I have a lisp that adds them to text, but not blocks. Any help is appreciated (No i am not too lazy to wirte one, just no time any more :( )
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Parens
« Reply #1 on: May 19, 2004, 02:15:07 PM »
Rug
can you upload a dwg showing examples of with and without.
TheSwamp.org  (serving the CAD community since 2003)

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Parens
« Reply #2 on: May 19, 2004, 02:21:46 PM »
lilly.pond/rugaroo/example.dwg
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

David Bethel

  • Swamp Rat
  • Posts: 656
Parens
« Reply #3 on: May 19, 2004, 02:48:49 PM »
What value do you have the sysvar TEXTEVAL set to?  -David
R12 Dos - A2K

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Parens
« Reply #4 on: May 19, 2004, 03:08:19 PM »
aLWAYS DEFAULTING TO 0
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
Parens
« Reply #5 on: May 19, 2004, 03:53:12 PM »
Ok - Here is what I came up with on lunch :)

Code: [Select]
(defun ukword (bit kwd msg def / inp)
  (if (and def (/= def ""))
    (setq msg (strcat "\n" msg "<" def ">: ")
          bit (* 2 (fix (/ bit 2)))
    )
    (setq msg (strcat "\n" msg ": "))
  )
  (initget bit kwd)
  (setq inp (getkword msg))
  (if inp inp def)
)

(defun C:PAR ( / txt ent ed et newtxt oldtxt parent)
  (if (= (ukword 0 "( [" "Add `()' or `[]' to selected entities " "(") "(")
    (setq ltchar "(" rtchar ")")
    (setq ltchar "[" rtchar "]")
  )
  (while (setq txt (nentsel "\nSelect a TEXT, ATTRIBUTE, ATTDEF or DIMENSION: "))
    (setq ent (car txt)
          ed (entget ent)
          et (cdr (assoc 0 ed))
          pt (cadr txt)
    )
    (cond
      ((= et "TEXT")
        (if (setq parent (car (cadddr txt)))
          (if (= (cdr (assoc 0 (entget parent))) "DIMENSION")
            (command ".DIM1" "NE" (strcat ltchar (cdr (assoc 1 ed)) rtchar) parent "")
            (prompt "\nCan't change that text.")
          )
          (progn
            (setq oldtxt (assoc 1 ed)
                  newtxt (cons 1 (strcat ltchar (cdr oldtxt) rtchar))
                  ed (subst newtxt oldtxt ed)
            )
            (entmod ed)
      ) ) )
      ((= et "ATTRIB")
        (setq parent (cdr (assoc -1 ed))
              oldtxt (assoc 1 ed)
              newtxt (cons 1 (strcat ltchar (cdr oldtxt) rtchar))
              ed (subst newtxt oldtxt ed)
        )
        (entmod ed)
        (entupd parent)
      )
      ((= et "ATTDEF")
        (setq oldtxt (assoc 1 ed)
              newtxt (cons 1 (strcat ltchar (cdr oldtxt) rtchar))
              ed (subst newtxt oldtxt ed)
        )
        (entmod ed)
      )
      (et
        (prompt "\nThat isn't a text entity.")
  ) ) )
  (princ)
)
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017