TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MP on December 15, 2008, 08:56:41 PM
-
In short, the function uses grvecs to draw a multi colored sphere at the specified point, using the radius and colors1 and 2 if supplied. The radius value, if provided, is treated like the pdsize variable. The colors are treated per the grvecs function. If passed nils for radius, color1 and color2 it resorts to defaults, which are 1/100 screen size, red and green respectively.
Why: I needed visual confirmation of points generated by a program I was writing, but I didn't want to create any temporary entities. So I quickly bashed this out (hasn't been optimized yet).
Quick examples:
;; default 1/100 screensize, default red, default green
(grpoint (getpoint "Pick a point: ") nil nil nil)
;; default 1/100 screensize, yellow, blue
(grpoint (getpoint "Pick a point: ") nil 2 5)
;; 1/200 screensize, yellow, yellow
(grpoint (getpoint "Pick a point: ") -0.5 2 2)
(defun GrPoint ( point radius color1 color2 / i j k angles )
(setq radius
(if (numberp radius)
(if (minusp radius)
(* (/ (abs radius) 100.0) (getvar "viewsize"))
radius
)
(* 0.01 (getvar "viewsize"))
)
)
(setq
color1 (if (eq 'int (type color1)) color1 1)
color2 (if (eq 'int (type color2)) color2 3)
j 0.05
k (/ j 2.0)
i (- j)
)
(repeat (fix (/ 1.0 j))
(setq angles
(cons
(+ k (* 0.5 pi (setq i (+ i j))))
angles
)
)
)
(mapcar
'(lambda ( args / point color start_angle angles )
(setq
point (car args)
color (cadr args)
start_angle (caddr args)
angles (cadddr args)
)
(grvecs
(apply 'append
(mapcar
'(lambda ( incr_angle )
(list
color
point
(polar
point
(+ start_angle incr_angle)
radius
)
)
)
(cadddr args)
)
)
)
)
(list
(list point color1 (* 0.0 pi) angles)
(list point color2 (* 0.5 pi) angles)
(list point color1 (* 1.0 pi) angles)
(list point color2 (* 1.5 pi) angles)
)
)
point ;; return the original point to the caller
)
Sorry, don't have time to document this better or clean up the local vars. Will do down the road when I've more time.
Later dudes.
-
Nice job!!! Did something similar a few years ago, but this is better.
-
Nicely bashed together Michael.
-
Thanks guys, dirty but did the job.
-
Thanks guys, dirty but did the job.
I'm hope someday to write "dirty" code like you :-P
-
{shrug} Thanks Ron, I've got nothing on you. :)
Except maybe 50 lbs. :(
-
Except maybe 50 lbs. :(
Put your head on his shoulder? :-D
-
Except maybe 50 lbs.
Put your head on his shoulder?
would take a LOT of tequila to get me to that point (http://www.theswamp.org/screens/mp/oh.gif)
yes, I know what you meant: I can still get thru the door :P