;| SphericalPointShell.lsp Spherical Point Shell SPS generates random 3D points equidistant from a user-specified center. v 1.01: Jan 25 2011 (c) 2011 by Bill Gilliss bill [atttt] realerthanreal [dotttt] com Comments and suggestions always welcome. ===================================================================== |; (defun c:SPS ( / num radius center orig pt vector unitvector) ;; pseudo-random number generator returns reals between 0 and 1 (defun rand (/ modulus multiplier increment random) (if (not seed) (setq seed (getvar "DATE")) ) (setq modulus 65536 multiplier 25173 increment 13849 seed (rem (+ (* multiplier seed) increment) modulus) random (/ seed modulus) ) ) ;; randomSign retuns random 1 or -1 (defun randomSign () (if (> 0.5 (rand)) 1 -1 ) ) (arxload "geomcal") (setq num (getint "\nNumber of points: ")) (setq radius (getdist "\nRadius of sphere: ")) (initget 0) (setq center (getpoint (strcat "\nCenter of sphere <0,0,0>: "))) (if (null center) (setq center '(0 0 0))) ;;current UCS (setvar 'cmdecho 0) (vl-cmdf "._undo" "_begin") (setq orig '(0 0 0)) (repeat num (setq vector (list (* (rand) (randomsign)) ;;between -1 and 1 (* (rand) (randomsign)) (* (rand) (randomsign)) ) ) (setq unitvector (c:cal "vec1(orig,vector)")) (setq pt (c:cal "center + (radius*unitvector)")) (entmake (list (cons 0 "POINT") (cons 10 (trans pt 1 0)) ) ) );repeat (vl-cmdf "._undo" "_end") (setvar 'cmdecho 1) (princ) );defun (princ "SphericalPointShell loaded. Enter SPS to use.") (princ)