home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / 圆方5.0 / SETUP / UNIT.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1998-04-07  |  8.5 KB  |  286 lines

  1. (defun plate_dialog ( data / x y c sta
  2.                     )
  3.  
  4.   (if (not (new_dialog "plate" dcl_id))
  5.     (exit)
  6.   )
  7.  
  8.   (action_tile "accept" "(plate_dialog_ok)")
  9.   (action_tile "std_h" "(set_h)")
  10.   (action_tile "std_w" "(set_w)")
  11.   (action_tile "color1" "(set_color 0)")
  12.   (action_tile "color2" "(set_color 1)")
  13.   (action_tile "color3" "(set_color 2)")
  14.   (action_tile "c01" "(set_color 0)")
  15.   (action_tile "c02" "(set_color 1)")
  16.   (action_tile "c03" "(set_color 2)")
  17.   (setq x (dimx_tile "image"))
  18.   (setq y (dimy_tile "image"))
  19.   (start_image "image")
  20.   (slide_image 0 0 x y "room(platevar)")
  21.   (end_image)
  22.  
  23.   (setq hb_std_h (list "1000.0" "1300.0" "1600.0" "1800.0")
  24.         hb_std_w (list "600.0" "700.0" "900.0"))
  25.   (start_list "std_h")
  26.   (foreach x hb_std_h (add_list x))
  27.   (end_list)
  28.   (start_list "std_w")
  29.   (foreach x hb_std_w (add_list x))
  30.   (end_list)
  31.  
  32.   (set_tile "height" (nth 0 data))
  33.   (set_tile "width"  (nth 1 data))
  34.   (set_tile "thick"  (nth 2 data))
  35.   (set_tile "h1"     (nth 3 data))
  36.   (set_tile "h2"     (nth 4 data))
  37.   (set_tile "h3"     (nth 5 data))
  38.   (set_tile "t"      (nth 7 data))
  39.   (if (= "y" (nth 6 data))
  40.     (set_tile "has_window" "1")
  41.     (set_tile "has_window" "0")
  42.   )
  43.   (setq colors (list  (cons 0 (atoi (nth 8 data)))
  44.                       (cons 1 (atoi (nth 9 data)))
  45.                       (cons 2 (atoi (nth 10 data)))))
  46.  
  47.   (setq c 0)
  48.   (repeat 3
  49.     (setq key (strcat "c0" (itoa (1+ c))))
  50.     (setq x (dimx_tile key))
  51.     (setq y (dimy_tile key))
  52.     (start_image key)
  53.     (fill_image 0 0 x y (cdr (nth c colors)))
  54.     (end_image)
  55.     (setq c (1+ c))
  56.   )
  57.  
  58.   (setq sta (start_dialog))
  59.  
  60.   (if (= sta 1)
  61.     (setq data new_data)
  62.     (setq data nil)
  63.   )
  64.  
  65. )
  66.  
  67. (defun set_h ( / )
  68.   (set_tile "height" (nth (atoi (get_tile "std_h")) hb_std_h))
  69. )
  70.  
  71. (defun set_w ( / )
  72.   (set_tile "width" (nth (atoi (get_tile "std_w")) hb_std_w))
  73. )
  74.  
  75. (defun plate_dialog_ok ( / flag )
  76.  
  77.   (setq flag (get_tile "has_window"))
  78.   (if (= flag "0")
  79.     (setq flag "n")
  80.     (setq flag "y")
  81.   )
  82.   (if ( > (+ (atof (get_tile "h1")) (atof (get_tile "h2")) (atof (get_tile "h3")))
  83.         (atof (get_tile "height")))
  84.     (setq flag "n"))
  85.  
  86.   (setq new_data (list  (get_tile "height")
  87.                         (get_tile "width")
  88.                         (get_tile "thick")
  89.                         (get_tile "h1")
  90.                         (get_tile "h2")
  91.                         (get_tile "h3")
  92.                         flag
  93.                         (get_tile "t")
  94.                         (itoa (cdr (nth 0 colors)))
  95.                         (itoa (cdr (nth 1 colors)))
  96.                         (itoa (cdr (nth 2 colors)))))
  97.  
  98.   (done_dialog 1)
  99. )
  100.  
  101. (defun set_color ( n / cl c x y key )
  102.  
  103.   (setq cl (sel_plate_cl))
  104.   (setq colors (subst (cons n cl) (assoc n colors) colors))
  105.  
  106.   (setq c 0)
  107.   (repeat 3
  108.     (setq key (strcat "c0" (itoa (1+ c))))
  109.     (setq x (dimx_tile key))
  110.     (setq y (dimy_tile key))
  111.     (start_image key)
  112.     (fill_image 0 0 x y (cdr (nth c colors)))
  113.     (end_image)
  114.     (setq c (1+ c))
  115.   )
  116. )
  117.  
  118. (defun sel_plate_cl ( / )
  119.  
  120.   (if (not (new_dialog "plate_color" dcl_id))
  121.     (exit)
  122.   )
  123.  
  124.   (action_tile "accept" "(done_dialog 233)")
  125.   (action_tile "c01" "(done_dialog 1)")
  126.   (action_tile "c02" "(done_dialog 253)")
  127.   (action_tile "c03" "(done_dialog 21)")
  128.   (action_tile "c04" "(done_dialog 233)")
  129.   (action_tile "c05" "(done_dialog 231)")
  130.   (action_tile "c06" "(done_dialog 133)")
  131.   (action_tile "c07" "(done_dialog 175)")
  132.   (action_tile "c08" "(done_dialog 245)")
  133.   (action_tile "c09" "(done_dialog 151)")
  134.   (action_tile "c10" "(done_dialog 7)")
  135.   (action_tile "other" "(setq c (acad_colordlg 233))
  136.                         (if (/= nil c) (done_dialog c) (done_dialog 233))")
  137.  
  138.   (start_dialog)
  139. )
  140.  
  141. (defun plate_1 ( pt l w h c h1 h2 h3 t color1 color2 color3
  142.                / x y z pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8
  143.              )
  144.  
  145.   (setq x (car pt) y (nth 1 pt) z (nth 2 pt))
  146.   (setq pt1 (list x y z)
  147.         pt2 (list (+ l x) y z )
  148.         pt3 (list (+ l x) (+ y w) z)
  149.         pt4 (list x (+ y w)  z )
  150.         pt5 (list x y (+ z h))
  151.         pt6 (list (+ l x) y (+ z h))
  152.         pt7 (list (+ l x) (+ y w) (+ z h))
  153.         pt8 (list x (+ y w) (+ z h))
  154.   )
  155.   (make_3dface pt5 pt6 pt7 pt8 "3D_MESH" 0 0)
  156.   (make_3dface pt2 pt6 pt7 pt3 "3D_MESH" 0 0)
  157.   (make_3dface pt5 pt8 pt4 pt1 "3D_MESH" 0 0)
  158.   (make_3dface pt1 pt2 pt3 pt4 "2D" 0 0)
  159.  
  160.   (setq pt5 (list x y (+ z h1))
  161.         pt6 (list (+ l x) y (+ z h1))
  162.         pt7 (list (+ l x) (+ y w) (+ z h1))
  163.         pt8 (list x (+ y w) (+ z h1))
  164.   )
  165.   (make_3dface pt1 pt2 pt6 pt5 "3D_MESH" color1 0)
  166.   (make_3dface pt4 pt3 pt7 pt8 "3D_MESH" color1 0)
  167.  
  168.   (if (< h (+ h1 h2 t t)) (setq h2 (- h h1)))
  169.   (setq pt1 (list x y (+ z h1 h2))
  170.         pt2 (list (+ l x) y (+ z h1 h2))
  171.         pt3 (list (+ l x) (+ y w) (+ z h1 h2))
  172.         pt4 (list x (+ y w) (+ z h1 h2))
  173.   )
  174.   (make_3dface pt1 pt2 pt6 pt5 "3D_MESH" color2 0)
  175.   (make_3dface pt4 pt3 pt7 pt8 "3D_MESH" color2 0)
  176.  
  177.   (if (> h (+ h1 h2 h3))
  178.     (progn
  179.       (setq pt5 (list x y (+ z (- h h3)))
  180.             pt6 (list (+ l x) y (+ z (- h h3)))
  181.             pt7 (list (+ l x) (+ y w) (+ z (- h h3)))
  182.             pt8 (list x (+ y w) (+ z (- h h3)))
  183.       )
  184.       (make_3dface pt1 pt2 pt6 pt5 "3D_MESH" color3 0)
  185.       (make_3dface pt4 pt3 pt7 pt8 "3D_MESH" color3 0)
  186.     ) ; progn
  187.   )  ; end if
  188.  
  189.   (if (> h (+ h1 h2 t t))
  190.     (progn
  191.       (if (= c "y")
  192.         (progn
  193.           (setq pt1 (list (+ t x) y (+ z (- h h3) t))
  194.                 pt2 (list (- (+ l x) t) y (+ z t (- h h3)))
  195.                 pt3 (list (- (+ l x) t) (+ y w) (+ z t (- h h3)))
  196.                 pt4 (list (+ t x) (+ y w) (+ z t (- h h3)))
  197.           )
  198.           (make_3dface pt1 pt2 pt6 pt5 "3D_MESH" 0 10)
  199.           (make_3dface pt4 pt3 pt7 pt8 "3D_MESH" 0 10)
  200.           (make_3dface pt1 pt2 pt3 pt4 "3D_MESH" 0 0)
  201.  
  202.           (setq pt2 (list x y (+ z h))
  203.                 pt3 (list (+ x t) y (- (+ z h) t))
  204.                 pt6 (list (+ x t) (+ y w) (- (+ z h) t))
  205.                 pt7 (list x (+ y w) (+ z h))
  206.           )
  207.           (make_3dface pt2 pt5 pt1 pt3 "3D_MESH" 0 10)
  208.           (make_3dface pt7 pt8 pt4 pt6 "3D_MESH" 0 10)
  209.           (make_3dface pt1 pt4 pt6 pt3 "3D_MESH" 0 0)
  210.  
  211.  
  212.           (setq pt1 (list (- (+ x l) t) y (- (+ z h) t))
  213.                 pt4 (list (+ x l) y (+ z h))
  214.                 pt5 (list (+ x l) (+ y w) (+ z h))
  215.                 pt8 (list (- (+ x l) t) (+ y w) (- (+ z h) t))
  216.           )
  217.           (make_3dface pt3 pt1 pt4 pt2 "3D_MESH" 0 10)
  218.           (make_3dface pt6 pt8 pt5 pt7 "3D_MESH" 0 10)
  219.           (make_3dface pt3 pt1 pt8 pt6 "3D_MESH" 0 0)
  220.  
  221.           (setq pt2 (list (- (+ x l) t) y (- (+ z h t) h3))
  222.                 pt3 (list (+ x l) y (- (+ z h) h3))
  223.                 pt6 (list (+ x l) (+ y w) (- (+ z h) h3))
  224.                 pt7 (list (- (+ x l) t) (+ y w) (- (+ z h t) h3))
  225.           )
  226.           (make_3dface pt1 pt2 pt3 pt4 "3D_MESH" 0 10)
  227.           (make_3dface pt8 pt7 pt6 pt5 "3D_MESH" 0 10)
  228.           (make_3dface pt8 pt7 pt2 pt1 "3D_MESH" 0 0)
  229.         )
  230.         (progn
  231.  
  232.           (setq pt1 (list x y (+ z h))
  233.             pt2 (list (+ l x) y (+ z h))
  234.             pt3 (list (+ l x) (+ y w) (+ z h))
  235.             pt4 (list x (+ y w) (+ z h))
  236.           )
  237.           (make_3dface pt1 pt2 pt6 pt5 "3D_MESH" color2 0)
  238.           (make_3dface pt4 pt3 pt7 pt8 "3D_MESH" color2 0)
  239.         )
  240.       )   ; end if
  241.     )  ; progn
  242.   ) ; end if
  243.  
  244. )
  245.  
  246. (defun plate ( data_inp / data pt h w t c color1 color2 color3 t1
  247.                ang
  248.               )
  249.  
  250.   (setq data (plate_dialog data_inp))
  251.  
  252.   (if (/= nil data)
  253.     (progn
  254.  
  255.       (setq pt      (list 0.0 0.0 0.0)
  256.             h       (atof (nth 0 data))
  257.             l       (atof (nth 1 data))
  258.             w       (atof (nth 2 data))
  259.             h1      (atof (nth 3 data))
  260.             h2      (atof (nth 4 data))
  261.             h3      (atof (nth 5 data))
  262.             c       (nth 6 data)
  263.             t       (atof (nth 7 data))
  264.             color1  (atoi (nth 8 data))
  265.             color2  (atoi (nth 9 data))
  266.             color3  (atoi (nth 10 data)))
  267.  
  268.       (blk_header pt)
  269.  
  270.       (plate_1 pt l w h c h1 h2 h3 t color1 color2 color3)
  271.  
  272.       (blk_end pt 0)
  273.  
  274.       (command "MOVE" (entlast) "" pt)
  275.       (princ MSG016) ; "\nInsert point:"
  276.       (command pause)
  277.       (setq pt (cdr (assoc 10 (entget (entlast)))))
  278.       (command "ROTATE" (entlast) "" pt)
  279.       (princ MSG030) ; "\nRotate angle:"
  280.       (command pause)
  281.   ) )
  282.  
  283.   (princ)
  284.  
  285. )
  286.