Counting Text

Discussion in 'AutoCAD' started by richard_l_smith, Dec 7, 2004.

  1. I used to have a lisp routine (CTXT.lsp) that used to add sequential numbers. Similar to multiple copy, but when you drop the copy of a number into the drawing, it counts up by 1 digit. Does anyone know where i can find this? or anything similar?
     
    richard_l_smith, Dec 7, 2004
    #1
  2. richard_l_smith

    GaryDF Guest

    Something like this?

    Gary

    (defun C:CNTTX (/ s1 lg index count c x a d ct atext apoint)
    (prompt "\n* Count DText *")
    (setq S1 (ssget)
    LG (sslength S1)
    INDEX 0
    COUNT 0
    C 0
    )
    (while (/= INDEX LG)
    (setq X (ssname S1 INDEX)
    A (entget X)
    D (cdr (assoc 0 A))
    )
    (if (= D "TEXT")
    (progn (setq B (atof (cdr (assoc 1 A)))
    C (+ C B)
    COUNT (1+ COUNT)
    )
    )
    )
    (setq INDEX (1+ INDEX))
    )
    (setq CT (rtos C 2 0))
    (setq ATEXT (strcase CT))
    (setq
    APOINT (getpoint "\n* Pick Location for Text in Drawing... *")
    )
    (command "text" "j" "bl" APOINT ARCH#SC-N 0 ATEXT)
    (princ)
    )

    Similar to multiple copy, but when you drop the copy of a number into the
    drawing, it counts up by 1 digit. Does anyone know where i can find this? or
    anything similar?
     
    GaryDF, Dec 7, 2004
    #2
  3. richard_l_smith

    GaryDF Guest

    Sorry I cut the routine from a larger one...
    change ARCH#SC-N to (getvar "textsize")

    Gary
     
    GaryDF, Dec 7, 2004
    #3
  4. Close, but not exactly what I was looking for. Does anyone have anything closer to my original description? Thanks
     
    richard_l_smith, Dec 7, 2004
    #4
  5. richard_l_smith

    mattis Guest

    try this:
    (defun c:CTXT (/ ss ent text hgt)
    (setq ss (ssget ":s" '((-4 . "<OR") (0 . "text") (0 . "mtext") (-4 . "OR>"))))
    (if (not ss)
    (alert "You must select either text or mtext")
    (progn
    (setq ent (ssname ss 0))
    (setq text (distof (cdr (assoc 1 (entget ent)))))
    (setq hgt (cdr (assoc 40 (entget ent))))
    (if (not (numberp text))
    (alert "The text must be a number.")
    (progn
    (setq text (1+ text))
    (entmake (list '(0 . "text") (cons 1 (rtos text)) (cons 40 hgt) (cons 10 (getpoint "\nSelect the insertion point."))))
    )
    )
    )
    )
    (princ)
    )
     
    mattis, Dec 7, 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.