Hi Tom,
I just added the error handling function to reset the system variable OSMODE back as it was set to before invoking the program and rearranged the codes in a bit better way to avoid nil values and to exit safely if any of the inputs is not entered as required.
So please test the codes and let me know how you get on with the codes?
Code:
(defun c:vdiv (/ *error* os line disp divs l p1 p1x p1y p2 p2x p2y thik w)
;; moodified by Tharwat - 04.Jul.2017 ;;
(defun *error* (msg)
(and os (setvar 'OSMODE os))
(and msg (not (wcmatch (strcase msg) "*BREAK*,*EXIT*,*CANCEL*"))
(princ (strcat "\nError => " msg))
)
(princ)
)
;; ;;
(setq os (getvar 'OSMODE))
(setvar "osmode" 32)
(defun line (a b)
(entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
)
;; ;;
(and (setq p1 (getpoint "\nPick lower left corner: "))
(setq p2 (getpoint "\nPick upper right corner: "))
(setq divs (getint "\nNumber of dividers [2]: "))
(setq thik (getreal "\nDivision Thickness [3/4]: "))
(setq p1x (car p1) p1y (cadr p1) p2x (car p2) p2y (cadr p2))
(setq l (- p2y p1y))
(setq w (- p2x p1x))
(setq disp (/ (- l (* divs thik)) (+ divs 1)))
(repeat divs
(setq p1y (+ p1y disp))
(line (list p1x p1y) (list (+ p1x w) p1y))
(if (/= thik 0)
(line (list p1x (+ thik p1y)) (list (+ p1x w) (+ thik p1y)))
)
(setq p1y (+ p1y thik))
)
)
(*error* nil)
(princ)
)