Sequential letters?

Discussion in 'AutoCAD' started by Cad_Girl, Jun 10, 2004.

  1. Cad_Girl

    Cad_Girl Guest

    Hi all, just wondering if one of you generous types might help?!
    Found this little routine on this forum the other day, and its proved so useful I was wondering if anyone had a similar routine for "letters" (A,B,C...) they might like to share?

    Many thanks again,
    Cad_Girl

    -----------------------------------
    (defun c:seqnumb () :Attribute SeQuential numbering
    (princ "\nStarting Number: ")
    (setq startnum (getint))
    (setq num startnum)
    (princ "\nPick Block to sequentially number: ")
    (while
    (setq a (entsel))
    (setq b (car a))
    (setq c (entget b))
    (setq d (entnext b))
    (setq e (entget d))
    (setq f (assoc 0 e))
    (setq g (assoc 2 e))
    (setq h (assoc 1 e))
    (setq num$ (itoa num))
    (setq hh (cons 1 num$))
    (setq e (subst hh h e))
    (entmod e)
    (entupd d)
    (setq num (1+ num))
    (princ "\nNext block: ")
    )
    (princ)
    )
     
    Cad_Girl, Jun 10, 2004
    #1
  2. Cad_Girl

    David Bethel Guest

    ;;;Attribute SeQuential Lettering

    (defun c:seqletr (/ start num a b c d e f g h num$ hh e)

    (while (or (not start)
    (> (strlen start) 1)
    (< (ascii start) 65)
    (> (ascii start) 90))
    (setq start (strcase (getstring "\nStarting Letter A-Z: "))))

    (setq num (ascii start))
    (princ "\nPick Blocks to Sequentially Letter: ")
    (while
    (setq a (entsel))
    (setq b (car a))
    (setq c (entget b))
    (setq d (entnext b))
    (setq e (entget d))
    (setq f (assoc 0 e))
    (setq g (assoc 2 e))
    (setq h (assoc 1 e))
    (setq num$ (chr num))
    (setq hh (cons 1 num$))
    (setq e (subst hh h e))
    (entmod e)
    (entupd d)
    (setq num (1+ num))
    (princ "\nNext block: ")
    )
    (princ)
    )


    ;|-David
     
    David Bethel, Jun 10, 2004
    #2
  3. Cad_Girl

    Cad_Girl Guest

    Thanks David, works a treat.
    Typed my original post a bit too quick though!! :eek:)

    Was going to ask if there is anything like these commands to work on DTEXT (as opposed to block atts like these routines)?
    I have single line numbers and single line text and need to update/continue sequentially. Exactly as these routine, but for DTEXT.

    Hope this makes sense - sorry!

    Cad_Girl
     
    Cad_Girl, Jun 10, 2004
    #3
  4. I'm not sure you can give content input for DTEXT through lisp, since the
    "D" is for Dynamic (on-screen). You probably want plain old ordinary TEXT.

    Kent Cooper, AIA


    (as opposed to block atts like these routines)?
    update/continue sequentially. Exactly as these routine, but for DTEXT.
     
    Kent Cooper, AIA, Jun 10, 2004
    #4
  5. Cad_Girl

    NParcon Guest

    Here's a version using characters:

    (defun c:seqchar () :Attribute SeQuential lettering
    (princ "\nStarting Letter: ")
    (setq startchar (getstring))
    (setq num (ascii startchar)
    (princ "\nPick Block to sequentially letter: ")
    (while
    (setq a (entsel))
    (setq b (car a))
    (setq c (entget b))
    (setq d (entnext b))
    (setq e (entget d))
    (setq f (assoc 0 e))
    (setq g (assoc 2 e))
    (setq h (assoc 1 e))
    (setq num$ (chr num))
    (setq hh (cons 1 num$))
    (setq e (subst hh h e))
    (entmod e)
    (entupd d)
    (setq num (1+ num))
    (princ "\nNext block: ")
    )
    (princ)
    )
     
    NParcon, Jun 10, 2004
    #5
  6. Here's a part of my column-grid drawing menu routine (defun it if you
    prefer), the part that writes the numbers and letters into column-line
    identification bubbles.

    (setq txtvl (getvar "TEXTEVAL")) TEXTEVAL 1 +
    TEXT S <the-text-style-I-want> ^C(setq letter 65) +
    (setq ltrht (* mf <the-text-height-I-want>)) +
    [...the parts that fill in the numbered bubbles are in here....]
    (while (>= vlines 1) +
    (command "TEXT" "M" columna ltrht "0" (chr letter)) +
    (setq columna (list (+ (car columna) spacex) (cadr columna))) +
    (setq vlines (1- vlines)) (setq letter (1+ letter))) +
    TEXTEVAL !txtvl

    The 65 ascii value in (setq letter 65) starts you off at capital A for the
    lettered grid-line identification bubbles.
    The "mf" stands for "multiplier factor", and most people could put in
    (getvar "DIMSCALE") in its place, to help define the text height.
    The "vlines" value is an integer from earlier in the routine, for the number
    of vertical grid lines (the ones that get letters).
    The "columna" value is a point from earlier, the center of the first
    (left-most) lettered bubble (for Column line A).
    The "spacex" value is the distance in the x direction between vertical grid
    lines.
    It "counts" up the letters from A by increasing "letter" each time, and
    moves over one bay for the location of the next letter, and counts down the
    quantity so it knows when to stop.

    The parts that should be the most use to you are:
    (setq letter 65) - to get a capital A to start with (ascii character
    number);
    (setq letter (1+ letter)) - to increment that up each time for the next
    capital letter.
    (chr letter) - to give that ascii character-value as text content input.

    You should be able to apply those ideas to any number of particular
    applications for sequential letters.

    The "ascii" lisp function tells you the character number for a letter (or
    any text character), and "assoc 1" in an entget list is the text content of
    a Text entity. So if you want to continue the sequence from an existing
    letter, you can do:

    (setq letter (ascii (cdr (assoc 1 (entget (car (entsel)))))))

    to set the "letter" value from a selected piece of text. (The ascii
    function evaluates the first character if you pick a text string with more
    than one.)

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Jun 10, 2004
    #6
  7. Cad_Girl

    zeha Guest

    ;Modified version
    ;Maybe wrong with Char above the z and Z

    (defun c:seqnumb () :Attribute SeQuential numbering
    (princ "\nStarting Character or Number: ")
    (setq startnum (getstring))
    (setq num (if (wcmatch startnum "#*")(atoi startnum)(ascii startnum)))
    (princ "\nPick Block to sequentially number: ")
    (while
    (if (and (setq a (nentsel))
    (setq b (car a))
    (setq c (entget b))
    (setq f (assoc 0 c))
    (or(= (cdr f) "ATTRIB")
    (= (cdr f) "TEXT")
    ))
    (progn
    (setq num$ (if (wcmatch startnum "#*")(itoa num)(chr num)))
    (setq c (subst (cons 1 num$)(assoc 1 c) c))
    (entmod c)
    (entupd (if (= f "TEXT") d (cdr (assoc 330 c))))
    (setq num (1+ num))
    (princ "\nNext block: ")
    )

    )
    (princ)
    )
    )
     
    zeha, Jun 10, 2004
    #7
  8. Thinking about it some more, the "update" part and the "continue" part are
    very different animals. One changes existing text content, and the other
    has to create new entities. Other people's posted routines appear to be for
    the "update" part, but something derived from my earlier one should do the
    "continue" part.

    My response about using TEXT instead of DTEXT was based on the assumption of
    creating NEW text entities. If you're talking about changing existing ones,
    there's no such thing as DTEXT -- the entities are pieces of TEXT. DTEXT is
    a command, just a Dynamic on-screen way of entering TEXT entities, but the
    end result is the same as from the TEXT command.

    Kent Cooper, AIA


    (as opposed to block atts like these routines)?
    update/continue sequentially. Exactly as these routine, but for DTEXT.
     
    Kent Cooper, AIA, Jun 10, 2004
    #8
  9. Cad_Girl

    Cad_Girl Guest

    Thanks Zeha.
    Exactly what I'm after.

    Cad_Girl xx :eek:)
     
    Cad_Girl, Jun 10, 2004
    #9
  10. Cad_Girl

    GaryDF Guest

    FYI

    CHANGE (defun c:seqnumb () :Attribute SeQuential numbering

    TO (defun c:seqnumb () ;Attribute SeQuential numbering

    Gary
     
    GaryDF, Jun 10, 2004
    #10
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.