Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Simple Balloon Lisp and Ellipse

78 views
Skip to first unread message

cnbetts

unread,
Jan 27, 2005, 1:57:07 PM1/27/05
to
I am pretty sure your problem is your Object Snap environment variable setting. Sometimes pt3 or pt4 are too close to the leader and they are snapping back to pt2 when trying to draw the ellipse. Just add (setvar "osmode" 0) and it should work fine.

Chris Betts
http://softwarengineering.com

Rogerio_Brazil

unread,
Jan 27, 2005, 2:30:23 PM1/27/05
to
Hi, try it:

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 :)

thebbbrain

unread,
Jan 27, 2005, 2:44:58 PM1/27/05
to
Thanks I used your idea and created this, which works!
Set osmode to 0 just before picking the center point. I need them on when selecting the first pickpoint. Thanks again!

;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

Kent Cooper, AIA

unread,
Jan 27, 2005, 2:38:29 PM1/27/05
to
Better yet, have your routine check for *and save* the value of OSMODE
before you do the (setvar "osmode" 0) thing, and set it back again at the
end. If you just do (setvar "osmode" 0), without saving the value and later
resetting it, that's like calling up the Osnap dialog box and clearing all
the modes. You'd have to bring it up again to reset them if you have a
preferred combination that you usually run.

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...

0 new messages