combining lisp routines

Discussion in 'AutoCAD' started by FELIPE, Feb 8, 2005.

  1. FELIPE

    FELIPE Guest

    this is two lisp routines that I combined.
    The 1st one copies a line of dtext by a scale factor.
    The 2nd one lets me select several lines of dtext and edit them from top to bottom.
    The problem that I have is when I put them together it remembers the previous text. (Its not clearing before the new selection).
    I think I need to put a nil statement somewhere but I cant figure out where?
    I still new to this.

    (defun c:5 (/ qlst tsize inp que num)
    (princ "\n* DText only *")
    (SETQ QUE (ssget '((0 . "text"))))
    (setq qlst (entget (ssname que 0)))
    (if nonstandardspacing
    (setq spacingmodifier nonstandardspacing)
    (setq spacingmodifier 1.35)
    )
    (setq tsize (* -1 (* spacingmodifier (cdr (assoc 40 qlst)))))
    (SETQ INP (GETreal "\n* Enter how many lines of dtext to add *"))
    (cond
    ((= INP NIL) (SETQ NUM 2))
    ((minusp inp) (setq num (fix (1+ (abs inp)))))
    (t (setq num (fix (1+ (abs inp)))))
    )
    (COND
    ((NULL INP) (command "array" "p" "" "r" num "1" tsize))
    ((MINUSP inp) (command "array" "p" "" "r" num "1" (abs tsize)))
    (T (command "array" "p" "" "r" num "1" tsize))
    )
    (SETQ QUE NIL)




    (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
    (progn
    (setq cnt1 0)
    (while (< cnt1 (sslength ss))
    (setq TxtList (cons (ssname ss cnt1) TxtList))
    (setq cnt1 (1+ cnt1))
    )
    (setq TxtList (vl-sort TxtList '(lambda (a b) (> (cadr (cdr (assoc 10 (entget a)))) (cadr (cdr (assoc 10 (entget b))))))))
    (foreach item TxtList
    (command "_.ddedit" item "")
    )
    )
    )
    )
     
    FELIPE, Feb 8, 2005
    #1
  2. FELIPE

    ECCAD Guest

    Felipe,
    Here's the problem line:
    (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
    ....
    After (first) making an array of 'text'..
    this line selects 'all' of the 'text' and makes
    'ss' contain that selection..then you process
    the 'ss' elements using ddedit.

    For the top portion of the lower function, I suggest doing:
    (setq ss nil)
    (Prompt "\nSelect Text")
    (setq ss (ssget))
    (if ss
    (progn
    ............ remainder of lower function.


    Bob
     
    ECCAD, Feb 8, 2005
    #2
  3. FELIPE

    Tom Smith Guest

    (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
    No, there's no "x" in it. It's just a filter list, it isn't selecting "all"
    text. The OP probably wants such a filter.
    Or declare sset local, as it sould be, which amounts to the same thing. None
    of the variables in the bottom part are declared local, therefore the (if ss
    ....) test won't work properly after the first execution of the routine in a
    session.
     
    Tom Smith, Feb 8, 2005
    #3
  4. FELIPE

    ECCAD Guest

    Tom,
    Oops. We all miss things once in a while. :(
    Change:
    (setq cnt1 0)
    To:
    (setq cnt1 0 TxtList (list))

    Bob
     
    ECCAD, Feb 8, 2005
    #4
  5. FELIPE

    FELIPE Guest

    Thanks to all!
    I'm not to good at this stuff, so I had to read you replies about 100 times.
    Then I plugged it all in and it worked for me.
    Thanks again.
     
    FELIPE, Feb 8, 2005
    #5
  6. FELIPE

    T.Willey Guest

    I only caught it because I wrote the bottom part.

    Tim
     
    T.Willey, Feb 8, 2005
    #6
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.