sequential numbers

Discussion in 'AutoCAD' started by Chuck, Mar 2, 2004.

  1. Chuck

    Chuck Guest

    I am writing a lisp routine where I'm trying to get balloons
    numbered/lettered sequentially, mostly, but sometimes out of sequence. The
    first time through the routine you will always be prompted for a "grid mark"
    and on subsequent passes you will be able to either choose the next one
    sequentially or to start a new sequence from there. This is the subroutine I
    am using. There are repeated calls to this routine until the user quits the
    program. In the initial loading of the program count has been set (setq
    count 0).
    It seems to not work however. What am I doing wrong please?

    (defun balloonstring ()
    (setq count (+ count 1)) ;setq count
    (if (> count 1)
    (progn (setq balloontext (chr (+ 1 (ascii balloontext)))
    promptstring (strcat "\nballoontext <" balloontext ">")
    newstring (getstring promptstring)
    ) ;setq balloon
    (if (/= newstring "")
    (progn (setq balloontext newstring)) ;progn
    ) ;if newstring
    ) ;progn
    ) ;if count
    (if (= count 1)
    (progn (setq newstring (getstring "\nEnter ballon text")) ;setq
    (setq balloontext newstring)
    ) ;progn
    ) ;if count
    )
     
    Chuck, Mar 2, 2004
    #1
  2. Chuck

    Chuck Guest

    Ok, here's the whole story. It quits half way through the
    routine for some reason. It seemed to work ok until I added the subroutine I
    mentioned earlier.

    (DEFUN setup ()
    (SETQ OsOLD (GETVAR "OSMODE")
    TEXTOLD (GETVAR "TEXTSIZE")
    LAYROLD (GETVAR "CLAYER")
    ORTHOLD (GETVAR "ORTHOMODE")
    )
    (setq count 0)
    (if (= (tblsearch "layer" "GRID") nil)
    (progn (command "-layer" "n" "GRID" "c" "2"
    "GRID" "lt" "CENTER" "GRID" ""
    )
    )
    )
    (if (= (tblsearch "layer" "BALLOON") nil)
    (progn (command "-layer" "n" "BALLOON" "c"
    "2" "BALLOON" "lt" "CONTINUOUS"
    "BALLOON" ""
    )
    )
    )
    )
    (defun balloonstring ()
    (setq count (+ count 1)) ;setq count
    (if (> count 1)
    (progn (setq balloontext (chr (+ 1 (ascii balloontext)))
    promptstring (strcat "\nballoontext <" balloontext ">")
    newstring (getstring promptstring)
    ) ;setq balloon
    (if (/= newstring "")
    (progn (setq balloontext newstring)) ;progn
    ) ;if newstring
    ) ;progn
    ) ;if count
    (if (= count 1)
    (progn (setq newstring (getstring "\nEnter ballon text")) ;setq
    (setq balloontext newstring)
    ) ;progn
    ) ;if count
    ) ;defun

    (DEFUN BALLOON ()
    (setq entgrid (entlast))
    (setq entlist (entget entgrid))
    (setq endpt1 (cdr (assoc 10 entlist))
    endpt2 (cdr (assoc 11 entlist))
    dwgtextsize (getvar "textsize")
    bubblesize (* 1.5 dwgtextsize)
    )
    (balloonstring)
    (if (= (car endpt1) (car endpt2))
    (progn (setq rota (/ pi 2)))
    )
    (if (= (cadr endpt1) (cadr endpt2))
    (progn (setq rota pi))
    )
    (setvar "clayer" "balloon")
    (command "circle"
    "2p"
    endpt1
    (polar endpt1 rota (* 3 bubblesize))
    "text"
    "mc"
    "cen"
    endpt1
    bubblesize
    ""
    balloontext
    "circle"
    "2p"
    endpt2
    (polar endpt2 rota (* -3 bubblesize))
    "text"
    "mc"
    "cen"
    endpt2
    bubblesize
    ""
    balloontext
    )
    (setvar "textsize" dwgtextsize)
    (setvar "clayer" layrold)
    (setvar "osmode" osold)
    (setvar "orthomode" orthold)
    (DRAWNEXT)
    )
    (DEFUN DRAWNEXT ()
    (setq offdist (getstring "\nOffset to next grid? ")
    offdec (distof offdist 3)
    )
    (command "offset" offdec entgrid pause "")
    (BALLOON)
    )
    (DEFUN c:gl ()
    (setup)
    (SETVAR "CLAYER" "GRID")
    (SETVAR "ORTHOMODE" 1)
    (ALERT "Let's draw the first grid line")
    (setq pt1 (getpoint "\nfirst point"))
    (command "line" pt1 pause "")
    (setq pt2 (getvar "lastpoint"))
    (BALLOON)
    )
    I don't understand the question. The function you posted seems to work
    (although going from 9 to : to ;, etc seems strange)

    What is it not doing that it should, or what is it doing that it shouldn't?
     
    Chuck, Mar 3, 2004
    #2
  3. Chuck

    Chuck Guest

    I solved it me self...........thx

     
    Chuck, Mar 4, 2004
    #3
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.