Advertisement
Guest User

4 Lab code

a guest
Apr 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CAD Lisp 12.11 KB | None | 0 0
  1. (defun c:q ()
  2.   (setq X "0" Y "0" w_n 2 a 4 r 0 r1 0 r2 "0" slo "0" rt 0 isp "" prov "" data_isp "" data_prov "" naz "" kod "" mas "" listt "" mesto "" listov "")
  3.   (setq dcl_id (load_dialog "d:\\q.dcl"))
  4.   (while (> w_n 0) (run))
  5.   (start_dialog)
  6.   (unload_dialog dcl_id)
  7. )
  8.  
  9. (defun w ()
  10.   (if(not(new_dialog "w" dcl_id)) (exit))
  11.   (action_tile "file" "(stamp)")
  12.   (action_tile "isp" "(setq isp $value)")              (set_tile "isp" isp)
  13.   (action_tile "prov" "(setq prov $value)")            (set_tile "prov" prov)
  14.   (action_tile "data_isp" "(setq data_isp $value)")    (set_tile "data_isp" data_isp)
  15.   (action_tile "data_prov" "(setq data_prov $value)")  (set_tile "data_prov" data_prov)
  16.   (action_tile "kod" "(setq kod $value)")              (set_tile "kod" kod)
  17.   (action_tile "mas" "(setq mas $value)")              (set_tile "mas" mas)
  18.   (action_tile "listt" "(setq listt $value)")          (set_tile "listt" listt)
  19.   (action_tile "listov" "(setq listov $value)")        (set_tile "listov" listov)
  20.   (action_tile "mesto" "(setq mesto $value)")          (set_tile "mesto" mesto)
  21.   (action_tile "naz" "(setq naz $value)")              (set_tile "naz" naz)
  22.   (start_dialog)
  23. )
  24.  
  25. (defun run ()
  26.   (if (not (new_dialog "q" dcl_id) ) (exit))
  27.  
  28.   (action_tile "stamp" "(w)")
  29.  
  30.   (action_tile "bt_ok" "(done_dialog 1)")
  31.   (action_tile "bt_cancel" "(exit)")
  32.  
  33.   (action_tile "color" "(done_dialog 3)")
  34.  
  35.   (action_tile "dot" "(done_dialog 4)")
  36.   (action_tile "edx" "(setq X $value)")
  37.   (action_tile "edy" "(setq Y $value)")
  38.   (set_tile "edx" X)
  39.   (set_tile "edy" Y)
  40.  
  41.   (action_tile "a0" "(setq A 0)")  (if (= A 0) (set_tile "a0" "1"))
  42.   (action_tile "a1" "(setq A 1)")  (if (= A 1) (set_tile "a1" "1"))
  43.   (action_tile "a2" "(setq A 2)")  (if (= A 2) (set_tile "a2" "1"))
  44.   (action_tile "a3" "(setq A 3)")  (if (= A 3) (set_tile "a3" "1"))
  45.  
  46.  
  47.   (setq n_sloi (tblnext "LAYER" T))
  48.   (setq rt 1)
  49.   (while  (not (= (setq ent (tblnext "layer")) nil))
  50.   (setq rt (+ rt 1))  
  51.   )
  52.  
  53.   (setq n_sloi (tblnext "LAYER" T))
  54.   (setq a_sloi (nth 1 n_sloi))
  55.   (setq name_sloi (cdr a_sloi))
  56.   (setq list_sloi (list name_sloi))
  57.  
  58.   (repeat (- rt 1)
  59.   (setq n_sloi (tblnext "LAYER"))
  60.   (setq a_sloi (nth 1 n_sloi))
  61.   (setq name_sloi (cdr a_sloi))
  62.   (setq list_sloi (cons name_sloi list_sloi))
  63.   )
  64.  
  65.   (setq list_sloi (reverse list_sloi))
  66.  
  67.   (setq k 0)  
  68.   (start_list "sloi")
  69.  
  70.   (repeat rt
  71.   (add_list (nth k list_sloi))
  72.   (setq k (+ k 1))
  73.   )
  74.  
  75.   (end_list)  
  76.  
  77.   (action_tile "sloi" "(setq slo $value)")  (set_tile "sloi" slo)
  78.  
  79.  
  80.   (action_tile "stamp1" "(or (if (= r 0) (setq r 1)) (if (= r 1) (setq r 0)))")              (if (= r 1) (set_tile "stamp1" "1"))
  81.   (action_tile "spec" "(or (if (= r1 0) (setq r1 1)) (if (= r1 1) (setq r1 0)))")            (if (= r1 1) (set_tile "spec" "1"))
  82.   (action_tile "ramka" "(and (setq r2 $value) (mode_tile \"format\" (- 1 (atoi $value))))")  (cond
  83.                                                                                                ((= r2 "0") (and (set_tile "ramka" "0") (mode_tile "format" 1)))
  84.                                                                                                ((= r2 "1") (and (set_tile "ramka" "1") (mode_tile "format" 0)))
  85.                                                                                              )
  86.  
  87.   (setq w_n (start_dialog))
  88.   (cond
  89.   ((= w_n 4) (tochka))
  90.   ((= w_n 1) (progn
  91.                (setq slo1 (atoi slo))
  92.                (setq slo2 (nth slo1 list_sloi))
  93.                (command "_layer" "_set" slo2)
  94.                (command *cancel*)
  95.                (if (= r 1) (progn
  96.                              (draw_stamp)
  97.                              (draw_text)
  98.                            ))
  99.                (if (= r1 1) (draw_spec))
  100.                (if (= r2 "1") (draw_ramka))
  101.                (setq w_n 0)
  102.              ))
  103.   ((= w_n 3) (getcolor))
  104.   )
  105. )
  106.  
  107.  
  108. (defun tochka ()
  109.   (setq pt (getpoint "\n Укажите точку на экране \n"))
  110.   (setq X (rtos (car pt) 2 3))
  111.   (setq Y (rtos (cadr pt) 2 3))
  112. )
  113. (defun getcolor ()
  114.   (setq num_color (atoi (getvar "cecolor")))
  115.   (setq num_color (acad_colordlg num_color))
  116.   (command "_color" num_color)
  117. )
  118.  
  119. (defun stamp ()
  120.   (setq f (open "d:\\e.txt" "r"))
  121.  
  122.   (setq isp (read-line f))        (set_tile "isp" isp)
  123.   (setq prov (read-line f))       (set_tile "prov" prov)
  124.   (setq data_isp (read-line f))   (set_tile "data_isp" data_isp)
  125.   (setq data_prov (read-line f))  (set_tile "data_prov" data_prov)
  126.   (setq kod (read-line f))        (set_tile "kod" kod)
  127.   (setq mas (read-line f))        (set_tile "mas" mas)
  128.   (setq listt (read-line f))       (set_tile "listt" listt)
  129.   (setq listov (read-line f))     (set_tile "listov" listov)
  130.   (setq mesto (read-line f))      (set_tile "mesto" mesto)
  131.   (setq naz (read-line f))        (set_tile "naz" naz)
  132.  
  133.   (close f)
  134. )
  135.  
  136. (defun draw_ramka ()
  137.   (setq z1 (list (atoi x) (atoi y)))
  138.   (cond
  139.   ((= a 0)  (command "_.rectang" z1 "@1189,841"))
  140.   ((= a 1)  (command "_.rectang" z1 "@841,594"))
  141.   ((= a 2)  (command "_.rectang" z1 "@594,420"))
  142.   ((= a 3)  (command "_.rectang" z1 "@420,297"))
  143.   )
  144.   (setq w_n 0)
  145. )
  146.  
  147. (defun draw_text ()
  148.   (cond
  149.   ((= a 0) (setq v (+ (atoi x) 1022) b (+ (atoi y) 26) n (+ (atoi x) 1059) m (+ (atoi y) 21) c (+ (atoi x) 1080) k (+ (atoi y) 31) t (+ (atoi x) 1096) t1 (+ (atoi y) 44) u (+ (atoi x) 1175) u1 (+ (atoi x) 1139) l (+ (atoi x) 1142) l1 (+ (atoi y) 5) ff (+ (atoi x) 1177) ff1 (+ (atoi y) 16) ) )
  150.   ((= a 1) (setq v (+ (atoi x) 674) b (+ (atoi y) 26) n (+ (atoi x) 711) m (+ (atoi y) 21) c (+ (atoi x) 732) k (+ (atoi y) 31) t (+ (atoi x) 748) t1 (+ (atoi y) 44) u (+ (atoi x) 827) u1 (+ (atoi x) 791) l (+ (atoi x) 794) l1 (+ (atoi y) 5) ff (+ (atoi x) 829) ff1 (+ (atoi y) 16) ) )
  151.   ((= a 2) (setq v (+ (atoi x) 427) b (+ (atoi y) 26) n (+ (atoi x) 464) m (+ (atoi y) 21) c (+ (atoi x) 485) k (+ (atoi y) 31) t (+ (atoi x) 501) t1 (+ (atoi y) 44) u (+ (atoi x) 580) u1 (+ (atoi x) 544) l (+ (atoi x) 547) l1 (+ (atoi y) 5) ff (+ (atoi x) 582) ff1 (+ (atoi y) 16) ) )
  152.   ((= a 3) (setq v (+ (atoi x) 253) b (+ (atoi y) 26) n (+ (atoi x) 290) m (+ (atoi y) 21) c (+ (atoi x) 311) k (+ (atoi y) 31) t (+ (atoi x) 327) t1 (+ (atoi y) 44) u (+ (atoi x) 406) u1 (+ (atoi x) 370) l (+ (atoi x) 373) l1 (+ (atoi y) 5) ff (+ (atoi x) 408) ff1 (+ (atoi y) 16) ) )
  153.   ((= a 4) (setq v (+ (atoi x) 18) b (+ (atoi y) 26) n (+ (atoi x) 55) m (+ (atoi y) 21) c (+ (atoi x) 76) k (+ (atoi y) 31) t (+ (atoi x) 92) t1 (+ (atoi y) 44) u (+ (atoi x) 171) u1 (+ (atoi x) 135) l (+ (atoi x) 138) l1 (+ (atoi y) 5) ff (+ (atoi x) 173) ff1 (+ (atoi y) 16) ) )
  154.   )
  155.   (setq isp1 (list v b))
  156.   (setq data_isp1 (list n b))
  157.   (setq prov1 (list v m))
  158.   (setq data_prov1 (list n m))
  159.   (setq naz1 (list c k))
  160.   (setq kod1 (list t t1))
  161.   (setq mas1 (list u b))
  162.   (setq listt1 (list u1 b))
  163.   (setq mesto1 (list l l1))
  164.   (setq listov1 (list ff ff1))
  165.  
  166.   (command "_.text" isp1 "2.5" "0" isp)
  167.   (command "_.text" data_isp1 "2.5" "0" data_isp)
  168.   (command "_.text" prov1 "2.5" "0" prov)
  169.   (command "_.text" data_prov1 "2.5" "0" data_prov)
  170.   (command "_.text" naz1 "5" "0" naz)
  171.   (command "_.text" kod1 "7" "0" kod)
  172.   (command "_.text" mas1 "4" "0" mas)
  173.   (command "_.text" listt1 "4" "0" listt)
  174.   (command "_.text" mesto1 "4" "0" mesto)
  175.   (command "_.text" listov1 "3.5" "0" listov)
  176.   (setq w_n 0)
  177. )
  178.  
  179. (defun draw_stamp ()
  180.   (cond
  181.   ((= a 0) (setq j (+ (atoi x) 1004) j1 (+ (atoi x) 1005) j2 (+ (atoi y) 26) j3 (+ (atoi y) 21) j4 (+ (atoi y) 31) b1 (+ (atoi x) 1139) b2 (+ (atoi y) 36) b3 (+ (atoi y) 16) ) )
  182.   ((= a 1) (setq j (+ (atoi x) 656) j1 (+ (atoi x) 657) j2 (+ (atoi y) 26) j3 (+ (atoi y) 21) j4 (+ (atoi y) 31) b1 (+ (atoi x) 791) b2 (+ (atoi y) 36) b3 (+ (atoi y) 16) ) )
  183.   ((= a 2) (setq j (+ (atoi x) 409) j1 (+ (atoi x) 410) j2 (+ (atoi y) 26) j3 (+ (atoi y) 21) j4 (+ (atoi y) 31) b1 (+ (atoi x) 544) b2 (+ (atoi y) 36) b3 (+ (atoi y) 16) ) )
  184.   ((= a 3) (setq j (+ (atoi x) 235) j1 (+ (atoi x) 236) j2 (+ (atoi y) 26) j3 (+ (atoi y) 21) j4 (+ (atoi y) 31) b1 (+ (atoi x) 370) b2 (+ (atoi y) 36) b3 (+ (atoi y) 16) ) )
  185.   ((= a 4) (setq j (atoi x) j1 (+ (atoi x) 1) j2 (+ (atoi y) 26) j3 (+ (atoi y) 21) j4 (+ (atoi y) 31) b1 (+ (atoi x) 135) b2 (+ (atoi y) 36) b3 (+ (atoi y) 16) ) )
  186.   )
  187.   (setq s1 (list j (atoi y)))
  188.  
  189.   (setq raz (list j1 j2))
  190.   (setq prover (list j1 j3))
  191.   (setq word (list j1 j4))
  192.   (setq word1 (list b1 b2))
  193.   (setq word2 (list b1 b3))
  194.   (command "_.text" raz "2.5" "0" "Разраб.")
  195.   (command "_.text" prover "2.5" "0" "Пров.")
  196.   (command "_.text" word "2.5" "0" "Изм. Лист  № докум.       Подп.     Дата")
  197.   (command "_.text" word1 "2.5" "0" " Лит.      Масса      Масштаб")
  198.   (command "_.text" word2 "2.5" "0" " Лист         Листов")
  199.  
  200.   (command "_.rectang" s1 "@185,55")
  201.   (command "_.rectang" s1 "@65,5")
  202.   (command "_.rectang" s1 "@65,10")
  203.   (command "_.rectang" s1 "@65,15")
  204.   (command "_.rectang" s1 "@65,20")
  205.   (command "_.rectang" s1 "@65,25")
  206.   (command "_.rectang" s1 "@65,30")
  207.   (command "_.rectang" s1 "@65,35")
  208.   (command "_.rectang" s1 "@65,40")
  209.   (command "_.rectang" s1 "@65,45")
  210.   (command "_.rectang" s1 "@65,50")
  211.   (command "_.rectang" s1 "@65,55")
  212.   (command "_.rectang" s1 "@17,55")
  213.   (command "_.rectang" s1 "@40,55")
  214.   (command "_.rectang" s1 "@55,55")
  215.   (command "_.rectang" s1 "@65,55")
  216.   (command "_.rectang" s1 "@185,15")
  217.   (command "_.rectang" s1 "@185,40")
  218.   (command "_.rectang" s1 "@135,40")
  219.   (command "_.line" s1 "@0,55" "@7,0" "@0,-25" "@-7,0" "_c")
  220.   (command "_.line" s1 "@135,0" "@0,20" "@50,0" "@0,20" "@-50,0" "@0,-20" "@20,0" "@0,-5" "@30,0" "@0,20" "@-50,0" "@5,0" "@0,-15" "@5,0" "@0,15" "@5,0" "@0,5" "@0,-20" "@17,0" "@0,20" "@18,0" "@0,-40" "_c")
  221.   (setq w_n 0)
  222. )
  223.  
  224. (defun draw_spec ()
  225.   (cond
  226.   ((= a 0) (setq g (+ (atoi x) 1219) h (+ (atoi y) 40)) )
  227.   ((= a 1) (setq g (+ (atoi x) 871) h (+ (atoi y) 40)) )
  228.   ((= a 2) (setq g (+ (atoi x) 624) h (+ (atoi y) 40)) )
  229.   ((= a 3) (setq g (+ (atoi x) 450) h (+ (atoi y) 40)) )
  230.   ((= a 4) (progn
  231.              (if (= r 1) (setq g (+ (atoi x) 215) h (+ (atoi y) 40)) )
  232.              (if (= r 0) (setq g (atoi x) h (+ (atoi y) 40)) )
  233.            ))
  234.   )  
  235.   (setq d1 (list g h))
  236.   (command "_.rectang" d1 "@185,8")
  237.   (command "_.rectang" d1 "@185,16")
  238.   (command "_.rectang" d1 "@185,24")
  239.   (command "_.rectang" d1 "@185,32")
  240.   (command "_.rectang" d1 "@185,40")
  241.   (command "_.rectang" d1 "@185,48")
  242.   (command "_.rectang" d1 "@185,56")
  243.   (command "_.rectang" d1 "@185,64")
  244.   (command "_.rectang" d1 "@185,72")
  245.   (command "_.rectang" d1 "@185,80")
  246.   (command "_.rectang" d1 "@185,88")
  247.   (command "_.rectang" d1 "@185,96")
  248.   (command "_.rectang" d1 "@185,104")
  249.   (command "_.rectang" d1 "@185,112")
  250.   (command "_.rectang" d1 "@185,120")
  251.   (command "_.rectang" d1 "@185,128")
  252.   (command "_.rectang" d1 "@185,136")
  253.   (command "_.rectang" d1 "@185,144")
  254.   (command "_.rectang" d1 "@185,152")
  255.   (command "_.rectang" d1 "@185,160")
  256.   (command "_.rectang" d1 "@185,168")
  257.   (command "_.rectang" d1 "@185,176")
  258.   (command "_.rectang" d1 "@185,184")
  259.   (command "_.rectang" d1 "@185,192")
  260.   (command "_.rectang" d1 "@185,200")
  261.   (command "_.rectang" d1 "@185,208")
  262.   (command "_.rectang" d1 "@185,216")
  263.   (command "_.rectang" d1 "@185,224")
  264.   (command "_.rectang" d1 "@185,232")
  265.   (command "_.rectang" d1 "@185,240")
  266.   (command "_.rectang" d1 "@185,255")
  267.   (command "_.rectang" d1 "@140,255")
  268.   (command "_.rectang" d1 "@130,255")
  269.   (command "_.rectang" d1 "@20,255")
  270.   (command "_.rectang" d1 "@65,-5")
  271.   (command "_.rectang" d1 "@65,-10")
  272.   (command "_.rectang" d1 "@65,-15")
  273.   (command "_.rectang" d1 "@65,-20")
  274.   (command "_.rectang" d1 "@65,-25")
  275.   (command "_.rectang" d1 "@65,-30")
  276.   (command "_.rectang" d1 "@65,-35")
  277.   (command "_.rectang" d1 "@65,-40")
  278.   (command "_.rectang" d1 "@55,-40")
  279.   (command "_.rectang" d1 "@40,-40")
  280.   (command "_.rectang" d1 "@17,-40")
  281.   (command "_.rectang" d1 "@7,-15")
  282.   (command "_.rectang" d1 "@185,-15")
  283.   (command "_.rectang" d1 "@185,-40")
  284.   (command "_.line" d1 "@185,0" "@0,-20" "@-50,0" "@0,-5" "@5,0" "@0,5" "@5,0" "@0,-5" "@-5,0" "@10,0" "@0,10" "@15,0" "@0,-10" "@20,0" "@-50,0" "@0,10" "@0,-25" "@-135,0" "_c")
  285.   (setq w_n 0)
  286. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement