I have the following LISP code, disassembled from a very old program whos name is unknown to me. I am not sure what is wrong in this program but I cannot run the program from the command line. -----Begin Code ;Scope ; Macro to simplify the construction of Ballooning B/P's. ; The size of the text and balloon are based on the dimensioning ; variables. If the current text style has a fixed height then ; that height is used to scale the balloon and its text. ; A null response to the first prompt ("Balloon Center: ") will terminate ; the command. ; Numeric balloon text is incremented (defun C:bln3 (/ b h r txt) ;02.20.04 ; b : Balloon Center ; h : Text height ; r : Balloon radius ; Store and set system variables (setq ce (getvar "CMDECHO")) (setq bm (getvar "BLIPMODE")) (setvar "CMDECHO" 0) (setvar "BLIPMODE" 0) ) ; Check whether the current text style has a fixed height ;*(setq ts (cdr (assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE"))))) (if (zerop ts) ; Set balloon radius based on dimension text height ; Text height is set to 1.0 x DIMTXT (setq r (* (getvar "DIMSCALE") (getvar "DIMTXT") 1.0 1.0) h (* (getvar "DIMSCALE") (getvar "DIMTXT") 0.7) ) ; Set balloon radius based on current style text height (setq r (* ts 1.2)) ) ; Get start point (press "Escape" key to terminate function) (setq b (getpoint "\nBalloon Center: ")) ;02.20.04 ; Get balloon Center disallowing null responses (initget 1) (if (null oldtxt) (setq oldtxt "1")) (prompt (strcat "\nText <" oldtxt ">: ")) (setq txt (getstring)) (if (= txt "") (setq txt oldtxt)) (setvar "BLIPMODE" 0) ; Draw balloon (command "CIRCLE" b r) ; Draw text (checking against fixed text height) (if (zerop ts) (command "TEXT" "M" b h "0" txt) (command "TEXT" "M" b "0" txt) ) (setq oldtxt (itoa (1+ (atoi txt)))) ; Reset system variables (setvar "BLIPMODE" bm) (setvar "CMDECHO" ce) (princ) ------ End Code When ever "bln3" is entered to the command line in autocad (r14) it returns "0" (zero). I can run this from "appload" but then it attempts to run "appload" after its completed. I need this to run continuous until the operator wishes to exit the routine. I have to say it has been around 5 years since I have written or attempted to write in LISP, Im a bit rusty to say the least. As always, all help is greatly appreciated. Regards Rick
Check your opening and closing parentheses. Your main program (defun ...) ends after setting up your System Variables, and all of the rest of the code is ignored. The "0" you're getting is simply the return value for BLIPMODE. (defun C:bln3 (/ b h r txt) ;02.20.04 ; b : Balloon Center ; h : Text height ; r : Balloon radius ; Store and set system variables (setq ce (getvar "CMDECHO")) (setq bm (getvar "BLIPMODE")) (setvar "CMDECHO" 0) (setvar "BLIPMODE" 0) ) <<----- (defun C:bln3 ... ) ends here. ___
I managed to remove the reloading of "apload" but continue to have the problem trying to run at the command line. The project is to get my program working at every mouse click to display a ballon filled with a sequential number without having to interact with the keyboard or extra mouse clicks, IE, each mouse click sets another balloon on the dwg until canceled. Regards Rick p.s. I should have listened to my mom and became a doctor. :shrug:
Did you read my previous reply? Move that misplaced ")" to the very end of the file, and you'll be a long way toward solving your problem. Also, beware of linebreaks; the code you posted has linebreaks in the middle of commented (";") lines, which will confuse AutoLISP no end. ___
Paul, thank you. I have stared at the code for so long I ccould not see that. p.s. My second post managed to fall in behind yours somehow. Again, thank you. Regards Rick