;;;This program divides a linear distance into a pattern ;;;of A_B_A_B_A where the user specifies one of the intervals ;;;and the number of divisions. It draws nodes at the appropriate ;;;intervals which can be used to create snapping reference ;;;for any number of layout type functions. ; ; www.michaelbulatovich.ca (defun C:DVDR () (setq dcl_id (load_dialog "dvdr.dcl")) (new_dialog "dvdr" dcl_id) ;(if (not (new_dialog "dvdr" dcl_id "" '(-1 -1))) (exit)) (action_tile "A" "(progn(mode_tile \"a\" (- 1 (atoi $value))) (mode_tile \"b\" (atoi $value))(set_tile \"B\" \"0\"))" ) (action_tile "B" "(progn(mode_tile \"b\" (- 1 (atoi $value))) (mode_tile \"a\" (atoi $value))(set_tile \"A\" \"0\"))" ) (action_tile "Ano" "(setq Ano (atoi (get_tile \"Ano\")))") (action_tile "accept" "(done_dialog 1)") (action_tile "pickpoints" "(done_dialog 4)") (if (not (null b)) (set_tile "b" (rtos b)) ) (if (not (null A)) (set_tile "a" (rtos A)) ) (if (not (null Ano)) (set_tile "Ano" (itoa Ano)) ) (if (= choice "A") (progn (set_tile "A" "1") (set_tile "B" "0") (mode_tile "b" 1) ) ) (if (= choice "b") (progn (set_tile "A" "0") (set_tile "B" "1") (mode_tile "a" 1) ) ) ;(set_tile "b" (rtos b)) ;(set_tile "a" (rtos A)) ;(set_tile "Ano" (itoa Ano)) (setq what_next (start_dialog)) (cond ((= what_next 4) (getpnts) ) ((= what_next 0) (prompt "\nuser cancelled dialog") ) ) (unload_dialog dcl_id) ) (defun getpnts () (setq 1stpt (getpoint "Select two points defining the distance to be divided. First point:" ) ) (setq 2ndpt (getpoint "Second point:")) (if (equal choice "A") (findb) (findA) ) ) (defun findb () (setq dist (distance 1stpt 2ndpt)) (setq b (/ (- dist (* A Ano)) (- Ano 1))) (godraw) ) (defun finda (/ dist) (setq dist (distance 1stpt 2ndpt)) (setq A (/ (- dist (* b (- Ano 1))) Ano 1)) (godraw) ) (defun godraw (/ ang Acount counter Next) (setvar "cmdecho" 0) (setq snaps (getvar "osmode")) (setvar "osmode" 0) (setq ang (angle 1stpt 2ndpt)) (setq Acount 0) (setq counter 0) (setq Next 0) (while (< Acount Ano) (command "point" (polar 1stpt ang Next)) (setq counter (1+ counter)) (if (= 1 (rem counter 2)) (setq next (+ next a)) (progn (setq next (+ next b)) (setq acount (1+ acount)) ) ) ) (setvar "osmode" snaps) )