;;; Draw Grass at Elevation
;;; Created by Ronjonp: https://www.theswamp.org/index.php?topic=52989.0
(defun c:gr(/ grass bpt d h intensity p1 p2 tilt top)
;; RJP - 04.28.2017
(defun getrandnum (minnum maxnum / randnum)
;; Getrandnum returns a real number between minNum and maxNum.
;;
;; By: Stig Madsen
(defun randnum (/ modulus multiplier increment random)
;; Randnum.lsp
;; Returns a random number.
;; Written by Paul Furman, 1996.
;; Based on algorithm by Doug Cooper, 1982.
(if (not seed)
(setq seed (getvar "DATE"))
)
(setq modulus 65536
multiplier 25173
increment 13849
seed (rem (+ (* multiplier seed) increment) modulus)
random (/ seed modulus)
)
)
(if (not (< minnum maxnum))
(progn (setq tmp minnum
minnum maxnum
maxnum tmp
)
)
)
(setq random (+ (* (randnum) (- maxnum minnum)) minnum))
)
(defun grass (p1 p2 / w)
(setq w -0.1)
(entmake (list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(67 . 0)
'(8 . "Grass")
'(100 . "AcDbPolyline")
'(90 . 4)
'(70 . 128)
'(43 . 0.0)
'(38 . 0.0)
'(39 . 0.0)
(cons 10 p1)
'(40 . 0.0)
'(41 . 0.0)
(cons 42 (getrandnum w (+ w w)))
'(91 . 0)
(cons 10 p2)
'(40 . 0.0)
'(41 . 0.0)
'(42 . 0.1)
'(91 . 0)
(cons 10 p1)
'(40 . 0.0)
'(41 . 0.0)
(cons 42 (getrandnum w (+ w w)))
'(91 . 0)
(cons 10 p2)
'(40 . 0.0)
'(41 . 0.0)
'(42 . -11.5)
'(91 . 0)
)
)
)
(setq intensity 25)
(setq tilt 0.2)
(if (and (or (setq h (getdist "\nEnter maximum grass height : ")) (setq h 0.5))
(setq p1 (getpoint "\nSpecify first point: "))
(setq d (getdist p1 "\nSpecify second point: "))
)
(repeat (fix (/ (* d intensity) h))
(setq bpt (list (getrandnum (car p1) (+ d (car p1))) (cadr p1)))
(setq top (list (getrandnum (car bpt) (+ (getrandnum (- tilt) tilt) (car bpt)))
(getrandnum (cadr bpt) (+ h (cadr bpt)))
)
)
(grass bpt top)
)
)
(princ)
)
(c:gr)

Advertisements