Files
lisp-scr/randomRotate.lsp
2018-11-26 22:23:22 +01:00

63 lines
1.5 KiB
Common Lisp

(defun C:randRot (/ ss i il imax maxDeg currElem currRotList currRot currRotDeg randomNumber newRotDeg newRot newRotList newElem)
;variables:
(setq i 0);counter to zero
(setq imax 1);while variable
(graphscr)
(prompt "\nselect entities to be rotated: ")
(setq ss (ssget));asks for selection
(setq il (sslength ss));length of selection
(setq maxDeg (getreal "\nMaximum degrees :"))
(while imax
(print i)
(setq currElem (entget (ssname ss i) ))
(setq currRotList (assoc 50 currElem))
(setq currRot (cdr currRotList))
(setq currRotDeg (rtd currRot))
(setq randomNumber (- (fix(* (* 2 maxDeg) (rnd))) maxDeg))
(setq newRotDeg (+ randomNumber currRotDeg))
(setq newRot (dtr newRotDeg))
(setq newRotList(cons 50 newRot))
(setq newElem(subst newRotList currRotList currElem))
;; (print currElem)
;; (print newElem)
(entmod newElem)
;while specific:
(setq i (1+ i));increments i
(if (= i il) (setq imax nil));finish function if i equals il
)
(terpri)
(setq ss nil)
)
(defun rnd (/ 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)
)
)
(defun dtr (a)
(* pi (/ a 180))
)
(defun rtd (a)
(/ (* a 180) pi)
)