Chris Betts
http://softwarengineering.com
BALLOON.LSP
;Balloon Lisp
(defun c:balloon (/ pt1 pt2 pt3 pt4 dx dy val ts om cl x1 x2 y1 y2 dimsc)
;(defun c:balloon ()
(setq olderr *error* *error* err)
(setvar "cmdecho" 0)
(setq om (getvar "orthomode"))
(setvar "orthomode" 0)
(setq cl (getvar "clayer"))
(setq ts (* (getvar "dimscale") 0.125))
(setq dimsc (getvar "dimscale"))
(command "-style" "standard" "romans" "0" "1" "0" "n" "n" "n")
(setq pt1 (getpoint "\nStart point of Arrow: "))
(setq pt2 (getpoint "\nCenter of Balloon: "))
(setq val (getstring "\nBalloon Text: "))
(command "dim" "lea" pt1 pt2 ^c "exit");generates leader from pt1 to pt2
(setq dx 0.25);sets change in x value
(setq dy 0.1875);sets change in y value
(setq x1 (+ (car pt2) dx));gets original x value of pt2 and adds dx
(setq x2 (car pt2));gets original x value
(setq y1 (+ (cadr pt2) dy));gets original y value and adds dy
(setq y2 (cadr pt2));gets original y value
(setq pt3 (list x1 y2 0.0));creates list using computed values for pt3
(setq pt4 (list x2 y1 0.0));creates list using computed values for pt4
(command "ellipse" "c" pt2 pt3 pt4);generates ellipse
(command "scale" "l" "" pt2 dimsc);scales generated ellipse by dimscale
;;;(command "trim" "l" "" pt2 "");trims generated leader to ellipse edge
(command "trim" "p" "" pt2 "");;changed here.....
(command "text" "m" pt2 ts "0" val);adds text val to center of ellipse
(princ);exits command cleanly
(setvar "cecolor" "bylayer");returns to previous state
(command "layer" "s" cl "");returns to previous state
(setvar "orthomode" om);returns to previous state
(setvar "cmdecho" 1);returns to previous state
(setq *error* olderr);returns to previous state
(princ)
)
Rogério :)
;Balloon Lisp
;Copyright 2005 by Brian Wallace
;A program that draws part callout balloons
(defun c:balloon(/ pt1 pt2 pt3 pt4 dx dy val ts om cl x1 x2 y1 y2 dimsc)
;Program initialize
(setq olderr *error* *error* err)
(setvar "cmdecho" 0)
(setq om (getvar "orthomode"))
(setvar "orthomode" 0)
(setq cl (getvar "clayer")
ts (* (getvar "dimscale") 0.125) ;Text size???
dimsc (getvar "dimscale")
os (getvar "osmode")
)
(command "-style" "standard" "romans" "0" "1" "0" "n" "n" "n")
;Get user input
(setq pt1 (getpoint "\nStart point of Arrow: ")
(setvar "osmode" 0)
setq pt2 (getpoint "\nCenter of Balloon: ")
val (getstring "\nBalloon Text: ")
)
;Generates leader from pt1 to pt2
(command "dim" "lea" pt1 pt2 ^c "exit")
;Calculate values for ellipse
(setq dx 0.25 ;sets change in x value, ellipse width
dy 0.1875 ;sets change in y value, ellipse height
x1 (+ (car pt2) dx) ;gets original x value of pt2 and adds dx
x2 (car pt2) ;gets original x value
y1 (+ (cadr pt2) dy) ;gets original y value and adds dy
y2 (cadr pt2) ;gets original y value
pt3 (list x1 y2) ;creates list using computed values for pt3
pt4 (list x2 y1) ;creates list using computed values for pt4
)
(command "ellipse" "c" pt2 pt3 pt4) ;generates ellipse
(command "scale" "l" "" pt2 dimsc) ;scales generated ellipse by dimscale
(command "trim" "l" "" pt2 "") ;trims generated leader to ellipse edge
(command "text" "m" pt2 ts "0" val) ;adds text val to center of ellipse
(princ) ;exits command cleanly
(setvar "cecolor" "bylayer") ;returns to previous state
(command "layer" "s" cl "") ;returns to previous state
(setvar "orthomode" om) ;returns to previous state
(setvar "osmode" os)
(setvar "cmdecho" 1) ;returns to previous state
(setq *error* olderr) ;returns to previous state
(princ)
) ;end program
Alternatively, look into Help for OSMODE. Have your routine check for and
save the value of OSMODE, and if it's less than that biggest number (I
forget -- sixteen thousand and something), add that to it. That will be
equivalent to pressing F3, and will disable running Osnap *without* changing
your set combination of modes. Then if you want, you can have the routine
set OSMODE back when you're done, or leave it to the user to hit F3 if they
want them running again. But if you choose the latter, they'll still have
the combination of modes they had when the routine started.
You can also put some strategically spaced "NON" elements into the Lisp, to
disable any running Osnap modes for individual locations, without turning it
off altogether.
--
Kent Cooper, AIA
"cnbetts" wrote...