Search the Community
Showing results for tags 'fun'.
-
Hello people! Today I realized that AutoCAD is just waiting on my hard disc, so I started it and I wrote a short Lisp program. If someone wants to play: load the lisp and start it by typing TESTME in the command line. Probable you will have to double click with the wheel to get the zoom to the right place. You should see a caliper open at a random dimension. All you have to do is to read the caliper and enter the value. The command line should show at least 3 lines to see the result. Want to play again? Press enter. While AutoCAD waits for your input, you may use the mouse to zoom/pan. Or if you want to cheat, you can measure the opening of the caliper and enter the measured value. Have fun! (defun c:TestMe() (if (not (tblsearch "BLOCK" "SublerA")) (MakeBlockA)) (if (not (tblsearch "BLOCK" "SublerB")) (MakeBlockB)) (if (not (ssget "X" (list '(0 . "INSERT") '(2 . "SublerA")))) (entmake (list '(0 . "INSERT") '(2 . "SublerA") '(10 0 0 0)))) (if (not (ssget "X" (list '(0 . "INSERT") '(2 . "SublerB")))) (entmake (list '(0 . "INSERT") '(2 . "SublerB") '(10 0 0 0)))) (setq measured (/ (rem (getvar "millisecs") 1500) 10.0)) (setq entl (entget (entlast))) (setq entl (subst (list 10 measured 0 0) (assoc 10 entl) entl)) (entmod entl) (setq entered (getreal "Enter measured value ")) (princ (if (= measured entered) "Ok " (strcat " Not Ok! The answer is " (rtos measured) ))) (princ) ) (defun MakeBlockA() (entmake (list '(0 . "BLOCK") '(2 . "SublerA") '(10 0.0 0.0 0.0)'(70 . 0))) (setq i 0) (repeat 151 (cond ((= (* 5 (/ i 5)) i) (progn (setq m 0.5) (entmake (list '(0 . "text") (list 10 i 2.6 0) (cons 1 (itoa i)) '(40 . 1.4) (cons 50 0.7))) ) ) ) (entmake (list '(0 . "LINE") (list 10 i 0 0) (list 11 i (+ 1.5 m) 0))) (setq i (1+ i) m 0) ) (setq points (list '(-3 0 0) '(170 0 0) '(170 8 0) '(-10 8 0) '(-10 -15 0) '(-5 -25 0) '(-5 -30 0) '(-3 -30 0))) (setq p1 (list -3 -30 0)) (foreach p points (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p))) (setq p1 p) ) (entmake (list '(0 . "ENDBLK"))) ) (defun MakeBlockB() (entmake (list '(0 . "BLOCK") (cons 2 "SublerB") (list 10 0.0 0.0 0.0)'(70 . 0))) (setq i 0) (repeat 11 (cond ((= i (* 5 (/ i 5))) (progn (setq n -0.5) (entmake (list '(0 . "text") (list 10 (- (* 0.9 i) 0.5) -5 0) (cons 1 (itoa i)) '(40 . 1.4) (cons 50 0)(cons 62 1))) ))) (entmake (list '(0 . "LINE") (list 10 (* 0.9 i) 0 0) (list 11 (* 0.9 i) (+ -2 n) 0)(cons 62 1))) (setq i (1+ i) n 0) ) (setq p1 '(-3 -30 0)) (setq points (list '(-3 0 0) '(15 0 0) '(15 -7 0) '(4 -7 0) '(4 -15 0) '(-1 -25 0) '(-1 -30 0) '(-3 -30 0))) (foreach p points (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p))) (setq p1 p) ) (entmake (list '(0 . "ENDBLK"))) )