(defun c:dif (/ usrcmd size_h size_w p1 bang bdiag layer_setup)

(defun layer_setup (lyr Clr ltype)
(if (tblsearch "LAYER" lyr)
(command "._Layer" "_Thaw" lyr "_On" lyr "_UnLock" lyr "_Set" lyr "")
(command "._Layer" "_Make" lyr "_Color" (if (= Clr "") "_White" Clr) lyr
"LT" (if (= ltype "") "Continuous" ltype) lyr "")
)
)

(setq usrcmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(layer_setup "_diffuser" "1" "")

(if (and
(setq size_h (getdist "\nHeight: "))
(setq size_w (getdist "\nWidth: "))
)
(progn
(setq p1 (getvar "viewctr")
bang (atan size_h size_w)
bdiag (* (/ 1 (cos bang)) size_w)
)
(command "_.rectangle" p1 (polar p1 bang bdiag))
(prompt "\nPick Insertion Point: ")
(command "._move" (entlast) "" p1 pause)
(prompt "\nPick Angle: ")
(command "._rotate" (entlast) "" (getvar "lastpoint") pause)
)
)
(setvar "cmdecho" usrcmd)
(princ)
)
(prompt "\nDiffuser Loaded, Enter DIF to run.")
(princ)
(c:dif)

Advertisements