大家好
我正在尝试更好地获得一个例程,它将帮助我获得一些对比度,以查看我在三维模型中的块(/层)定义是什么。
我的出发点是这段代码beneith,它将在1-255范围内为+1之后的层分配颜色。
该c值应在此范围内随机并四舍五入。这样,遵循逻辑部分的方式得到了更大的对比度(出于工程目的…)
有人有好的方法吗?
(编辑:使用LM的完整代码:…&ROY_043方法)
- ; random layer colors
- ;; Rand - Lee Mac
- ;; PRNG implementing a linear congruential generator with
- ;; parameters derived from the book 'Numerical Recipes'
- (defun LM:rand ( / a c m )
- (setq m 4294967296.0
- a 1664525.0
- c 1013904223.0
- $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
- )
- (/ $xn m)
- )
- ;; Random in Range - Lee Mac
- ;; Returns a pseudo-random integral number in a given range (inclusive)
- (defun LM:randrange ( a b )
- (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b))))))
- )
- (defun c:Lcolor ()
- (vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
- (if
- (and
- (= :vlax-false (vla-get-lock x))
- (= :vlax-false (vla-get-freeze x))
- (not (wcmatch (vla-get-name x) "*|*"))
- )
- (vla-put-color x (LM:randrange 10 249))
- )
- )
- (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
- (princ)
- )
- (vl-load-com) (princ)
|