Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defun Point(x y z)
  2.     (list x y z)
  3. )
  4.  
  5. (defun Line (from to)
  6.  
  7.     (entmakex
  8.         (list
  9.             (cons 0 "line")
  10.             (cons 10 from)
  11.             (cons 11 to)
  12.         )
  13.     )
  14.    
  15. )
  16.  
  17. (defun Polygon (points / curr_point)
  18.  
  19.     (entmakex
  20.         (list
  21.             (cons 0 "POLYLINE")
  22.             (cons 10 '(0 0 0))
  23.         )
  24.     )
  25.  
  26.     (while (setq curr_point (car points))
  27.         (entmakex
  28.             (list
  29.                 (cons 0 "VERTEX")              
  30.                 (cons 10 curr_point)
  31.             )
  32.         )
  33.         (setq points (cdr points))
  34.     )
  35.  
  36.     (entmakex
  37.         (list (cons 0 "SEQEND"))
  38.     )
  39.    
  40. )
  41.  
  42. (defun connect_polygons(f_polygon s_polygon)
  43.  
  44.     (mapcar '(lambda (f_point s_point)
  45.             (Line f_point s_point)
  46.         )
  47.         f_polygon
  48.         s_polygon
  49.     )
  50.    
  51. )
  52.  
  53. (defun draw_cone(polygon point)
  54.  
  55.     (mapcar '(lambda (polygon_point)
  56.             (Line polygon_point point)
  57.         )
  58.         polygon
  59.     )
  60.    
  61. )
  62.  
  63. (defun draw_cylinder(cylinder_b1 cylinder_b2)
  64.  
  65.     (Polygon cylinder_b1)
  66.     (Polygon cylinder_b2)
  67.    
  68.     (connect_polygons cylinder_b1 cylinder_b2)
  69.    
  70. )
  71.  
  72. (defun CIRLCE_BASE(base_point radius vert_count z_value / polygon base_angle curr_point i)
  73.  
  74.     (setq base_angle (/ (* 2 pi) vert_count))
  75.    
  76.     (setq i 1)
  77.     (setq curr_point (polar base_point 0 radius))
  78.     (setq curr_point (POINT (car curr_point) (cadr curr_point) z_value))
  79.     (setq polygon (list curr_point))
  80.    
  81.     (repeat vert_count
  82.         (setq curr_point (polar base_point (* base_angle i) radius))
  83.         (setq curr_point (Point (car curr_point) (cadr curr_point) z_value))
  84.         (setq polygon (append polygon (list curr_point)))
  85.         (setq i (+ i 1))
  86.     )
  87.    
  88.     (setq polygon polygon)
  89.    
  90. )
  91.  
  92. (defun c:draw(/ i)
  93.    
  94.     (setq cylinder_b1 (CIRLCE_BASE '(0 0 0) 20 10 0))
  95.     (setq cylinder_b2 (CIRLCE_BASE '(0 0 0) 20 10 40))
  96.    
  97.     (setq cone_b (CIRLCE_BASE '(0 0 0) 20 10 40))
  98.  
  99.     (setq cone_b2 (CIRLCE_BASE '(0 0 0) 20 10 0))
  100.    
  101.     (Polygon cylinder_b1)
  102.     (Polygon cylinder_b2)
  103.    
  104.     (connect_polygons cylinder_b1 cylinder_b2)
  105.    
  106.     (draw_cone cone_b (Point 0 0 70))
  107.  
  108.     (draw_cone cone_b2 (Point 0 0 -40))
  109.    
  110. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement