Enclose DTEXT with parenthesis

Discussion in 'AutoCAD' started by twlincoln, Sep 29, 2004.

  1. twlincoln

    twlincoln Guest

    Hello,

    I have a request from a client to enclose certain DTEXT objects within parenthesis. Short of having to do this manually... (and I am not a programmer) is there a quick LISP routine that could allow a user to select the DTEXT (either one at a time or possibly in bulk) and put a ( as a prefix and ) as a suffix?

    Any help will be gretaly appreciated.

    Tracy W. Lincoln
    Autodesk Online Discussion Group Facilitator
     
    twlincoln, Sep 29, 2004
    #1
  2. twlincoln

    T.Willey Guest

    I have one I use. Hope it works for you.

    Tim

    (defun c:pAR(/ tset1 tlng1 to1 to2 tx1 tx2 ntx to3)

    (command "undo" "group")

    (prompt "\nSelect text to put parenthesis around: ")
    (setq tset1 (ssget '((0 . "*TEXT"))))
    (if (= tset1 nil)
    (setq tlng1 0)
    (setq tlng1 (sslength tset1))
    )

    (while (/= tlng1 0)
    (setq to1 (ssname tset1 0))
    (setq to2 (entget to1))
    (setq tx1 (assoc 1 to2))
    (setq tx2 (cdr tx1))
    (setq ntx (strcat "("tx2")"))
    (setq to3 (subst (cons 1 ntx) tx1 to2))
    (entmod to3)
    (entupd to1)
    (ssdel to1 tset1)
    (setq tlng1 (1- tlng1))
    )

    (command "undo" "end")
    (princ)
    )
     
    T.Willey, Sep 29, 2004
    #2
  3. twlincoln

    twlincoln Guest

    Thank you...

    While looking around a bit I did find an ADDTEXT.LSP posted on the CADalyst "Get the Code" site from 1993 (aka: TIP908.LSP). Will keep them both for good measure.

    Thanks again.

    - Tracy
     
    twlincoln, Sep 29, 2004
    #3
  4. Tim,

    That was perfect, works with MTEXT also... thank you again!
     
    Tracy W. Lincoln, Sep 30, 2004
    #4
  5. twlincoln

    T.Willey Guest

    Tracy,

    That was just one I wrote because it was getting to be a pain in the butt. I never thought anyone else had that problem with text and parenthesis. Glad someone else can use it.

    Tim
     
    T.Willey, Sep 30, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.