PDA

View Full Version : Another ballon Lisp Q


Rick Stanich
2009-07-17, 09:24 PM
I found a lisp routine for balloons on this forum and began modifying it for my needs. I stripped out the leader and sheet portions of showing a balloon Number and sheet Number in one circle.

Unfortunately I havent used Lisp since circa 1996 or so. As of now I cant seem to get the text to center in the circle and the number to begin counting from a user input value?


;ANY QUESTIONS or REQUESTS: paulmcz@yahoo.com
;
;*************************************************************************
; Size of balloon depends on dimscale setting *
; Looks best with 3 digits for part and sheet numbers *
; If part number starts with number, next increment is 1+ that number *
; If you want to increment any number, start with that number *
; You can overwrite the numbers any time on prompt *
; Typed in part number overwrite defaults *
;*************************************************************************

(defun incr ()
(progn (setq inn2 (atoi inn))
(setq inn3 (1+ inn2))
(setq inn (itoa inn3))
)
(setq sl (strlen inn))
(cond
((= sl 1) (setq inn (strcat "" inn)))
((= sl 2) (setq inn (strcat "" inn)))
(T nil)
)
)

(defun c:bn (/ in)

(setq cmd (getvar "cmdecho")
osm (getvar "osmode")
)
(setvar "cmdecho" 0)
(setq cc (getpoint "\n Center point of balloon: "))
(if inn
()
(setq inn "1")
)
(incr)
;enter to accept or enter a numeric value
(princ "\n Start Number < ")
(princ inn)
(princ " >? :")
(setq in (getstring))
(if (= in "")
(setq in inn)
)
(setq ds (getvar "dimscale"))
(setq th (getvar "dimtxt"))
(setq cd (* th 4.0))
(setq dia (* cd ds))
(setq txt (* th ds))
(setq rad (/ dia 2))
(setq ptl1 (list (- (car cc) rad) ))

(setq ptl2 (list (+ (car cc) rad) (cadr cc)))

(setq ptt1 (list (car cc) (+ (cadr cc) (* 0.8 txt))))

(setq ptt2 (list (car cc) (- (cadr cc) (* 0.8 txt))))

(setvar "osmode" 0)
(command "circle" cc rad)
;(command ".line" ptl1 ptl2 "")
(command ".text" "m" ptt1 (* txt 0.8) 0 in)
; adjust text height part #

(setvar "cmdecho" cmd)
(setvar "osmode" osm)
(princ)
)
(prompt "\nType < bn > to start Balloon with counter")

; Original version by Mr Randy
; This version by Rick Stanich


Any help, hints and or tips is appreciated.

paulmcz
2009-07-18, 03:01 PM
For what you want, you'd be better off with my "numbering.lsp" (attached) routine's "nmc" function but if you insist on fixing this one, here:

;ANY QUESTIONS or REQUESTS: paulmcz@yahoo.com
;
;*************************************************************************
; Size of balloon depends on dimscale setting *
; Looks best with 3 digits for part and sheet numbers *
; If part number starts with number, next increment is 1+ that number *
; If you want to increment any number, start with that number *
; You can overwrite the numbers any time on prompt *
; Typed in part number overwrite defaults *
;*************************************************************************

(defun incr ()
(progn (setq inn2 (atoi inn))
(setq inn3 (1+ inn2))
(setq inn (itoa inn3))
)
(setq sl (strlen inn))
(cond
((= sl 1) (setq inn (strcat "" inn)))
((= sl 2) (setq inn (strcat "" inn)))
(T nil)
)
)

(defun c:bn (/ in)

(setq cmd (getvar "cmdecho")
osm (getvar "osmode")
)
(setvar "cmdecho" 0)
(setq cc (getpoint "\n Center point of balloon: "))
(if inn
()
(setq inn "1")
)
(incr)
;enter to accept or enter a numeric value
(princ "\n Start Number < ")
(princ inn)
(princ " >? :")
(setq in (getstring))
(if (= in "")
(setq in inn)
)
(setq ds (getvar "dimscale"))
(setq th (getvar "dimtxt"))
(setq cd (* th 4.0))
(setq dia (* cd ds))
(setq txt (* th ds))
(setq rad (/ dia 2))
(setq ptl1 (list (- (car cc) rad) ))

(setq ptl2 (list (+ (car cc) rad) (cadr cc)))

(setq ptt1 (list (car cc) (+ (cadr cc) (* 0.8 txt))))

(setq ptt2 (list (car cc) (- (cadr cc) (* 0.8 txt))))

(setvar "osmode" 0)
(command "circle" cc rad)
;(command ".line" ptl1 ptl2 "")
;(command ".text" "m" ptt1 (* txt 0.8) 0 in)
; adjust text height part #
(entmake (list (cons 0 "TEXT")
(cons 10 cc)
(cons 11 cc)
(cons 1 in) ; actual text
(cons 7 (getvar "TEXTSTYLE"))
(cons 40 txt)
(cons 72 4)
)
)

(setvar "cmdecho" cmd)
(setvar "osmode" osm)
(princ)
)
(prompt "\nType < bn > to start Balloon with counter")

; Original version by Mr Randy
; This version by Rick Stanich

Rick Stanich
2009-07-20, 04:12 PM
Thank you Paul, your numbering.lsp routine covers quite a few options, very nice.