;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; ;;;; Copyright (c) Jun. 1996 by Takehiko Nagakura. ;;;; ;;;; All rights reserved. ;;;; ;;;; ;;;; ;;;; Do not copy, use, modify or distribute this software ;;;; ;;;; without written permission by Nagakura. Nagakura will ;;;; ;;;; not be responsible for any consequence of its use. ;;;; ;;;; ;;;; ;;;; Takehiko Nagakura (e-mail: takehiko@mit.edu) ;;;; ;;;; Massachusetts Institute of Technology ;;;; ;;;; 77 Massachusetts Ave. 10-472M, Cambridge, MA 02139 ;;;; ;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Last updated Feb 2, 2001 by TN ;;;; ; This file defines functions to draw parametric bathroom stools. ; ; Use of functions ; ; (stool xpos ypos rot tank_width tank_height) ; (c:demo) ; Before I start, do this just to avoid a sticky problem. (command "osnap" "off") ; First, I set up the 2 layers I need. These 2 lines will be ; processed only once when this file is loaded. (command "layer" "new" "axis" "color" "red" "axis" "") (command "layer" "new" "outline" "color" "white" "outline" "") ; This function allows a parametric stool to be drawn at ; a specified location and rotation in world coordinate system. ; Notice that I am using 3 local variables, hw_tan, hw_jnt ; and h_mid. (defun stool (xpos ypos rot width hight tank_hight seat_radius / hw_tan hw_jnt h_mid) ; 0) set up local parameters (setq hw_tan (/ width 2.0)) ; half width of tank. Use 2.0 to get real. (setq hw_jnt (- hw_tan 5)) ; half width of joint between seat and tank (setq h_mid (- hight tank_hight seat_radius)) ; height of linear portion of seat ; 1) set up local coordinate system (command "ucs" "world") (command "ucs" "origin" (list xpos ypos 0)) (command "ucs" "z" rot) ; 2) Axis is drawn on layer "axis" (command "layer" "set" "axis" "") (command "line" (list -25 0) (list 25 0) "") (command "line" (list 0 -50) (list 0 35) "") ; 3) Outline of the stool is drawn on layer "outline" (command "layer" "set" "outline" "") ; draw tank (command "line" (list (- hw_tan) (- h_mid)) (list hw_tan (- h_mid)) (list hw_tan (- (+ h_mid tank_hight))) (list (- hw_tan) (- (+ h_mid tank_hight))) "c") ; draw seat (command "pline" (list (- hw_jnt) (- h_mid)) (list (- seat_radius) 0) "arc" (list seat_radius 0) "line" (list hw_jnt (- h_mid)) "") ; 4) reset the ucs to avoid side effect. (command "ucs" "world") ) ; end of defun ; (stool 0 0 0 40 60 15 20) ; Now I test the function defined above with various ; parameter values. ; You can call this function from Autocad command line prompt, too. ; Setting up zooming area just for the sake of showing my demo neatly. ; A function named with c:xxx can be used in Autocad by just typing ; xxx as well as (c:xxx). It cannot take any argments, though. (defun c:demo () (command "plan" "") (command "zoom" (list -150 -100) (list 380 380)) (command "ucsicon" "off") (stool -80 0 0 30 100 30 30) (stool 0 0 0 40 40 8 20) (stool 80 0 0 60 100 30 25) (stool 180 0 0 100 100 15 20) (stool -80 130 30 30 100 30 30) (stool 0 130 30 40 40 8 20) (stool 80 130 30 60 100 30 25) (stool 180 130 30 100 100 15 20) (stool -80 240 150 30 100 30 30) (stool 0 240 150 40 40 8 20) (stool 80 240 150 60 100 30 25) (stool 180 240 150 100 100 15 20) (redraw) ) ; When this file is loaded, I will print its usage for the users. (prompt "(stool xpos ypos rot width hight tank_hight seat_radius) (c:demo)") ; Below prevents "nil" to be printed at then end of loading. (princ)