明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1118|回复: 4

[已解答] 相同的函数怎么整合在一起?

[复制链接]
发表于 2015-11-2 14:53:31 | 显示全部楼层 |阅读模式
  1. (defun c:30 (/ GR LST PT)
  2.   (setq  lst
  3.    (entget
  4.      (entmakex
  5.        (list
  6.          '(0 . "LINE")
  7.          (cons 8 (getvar "CLAYER"))
  8.          (cons 10
  9.          (setq pt (getpoint "\n Specify the first point  "))
  10.          )
  11.          (cons 11 pt)
  12.        )
  13.      )
  14.    )
  15.   )
  16.   (princ "\n Specify the second point  ")
  17.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  18.     (entmod
  19.       (subst
  20.   (cons 11 (polar pt (/ pi 6) (distance pt (cadr gr))))
  21.   (assoc 11 lst)
  22.   lst
  23.       )
  24.     )
  25.     (entupd (cdr (assoc -1 lst)))
  26.   )
  27. )

  28. (defun c:45 (/ GR LST PT)
  29.   (setq  lst
  30.    (entget
  31.      (entmakex
  32.        (list
  33.          '(0 . "LINE")
  34.          (cons 8 (getvar "CLAYER"))
  35.          (cons 10
  36.          (setq pt (getpoint "\n Specify the first point  "))
  37.          )
  38.          (cons 11 pt)
  39.        )
  40.      )
  41.    )
  42.   )
  43.   (princ "\n Specify the second point  ")
  44.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  45.     (entmod
  46.       (subst
  47.   (cons 11 (polar pt (/ pi 4) (distance pt (cadr gr))))
  48.   (assoc 11 lst)
  49.   lst
  50.       )
  51.     )
  52.     (entupd (cdr (assoc -1 lst)))
  53.   )
  54. )

  55. (defun c:60 (/ GR LST PT)
  56.   (setq  lst
  57.    (entget
  58.      (entmakex
  59.        (list
  60.          '(0 . "LINE")
  61.          (cons 8 (getvar "CLAYER"))
  62.          (cons 10
  63.          (setq pt (getpoint "\n Specify the first point  "))
  64.          )
  65.          (cons 11 pt)
  66.        )
  67.      )
  68.    )
  69.   )
  70.   (princ "\n Specify the second point  ")
  71.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  72.     (entmod
  73.       (subst
  74.   (cons 11 (polar pt (/ pi 3) (distance pt (cadr gr))))
  75.   (assoc 11 lst)
  76.   lst
  77.       )
  78.     )
  79.     (entupd (cdr (assoc -1 lst)))
  80.   )
  81. )

  82. (defun c:120 (/ GR LST PT)
  83.   (setq  lst
  84.    (entget
  85.      (entmakex
  86.        (list
  87.          '(0 . "LINE")
  88.          (cons 8 (getvar "CLAYER"))
  89.          (cons 10
  90.          (setq pt (getpoint "\n Specify the first point  "))
  91.          )
  92.          (cons 11 pt)
  93.        )
  94.      )
  95.    )
  96.   )
  97.   (princ "\n Specify the second point  ")
  98.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  99.     (entmod
  100.       (subst
  101.   (cons 11 (polar pt (/ pi 1.5) (distance pt (cadr gr))))
  102.   (assoc 11 lst)
  103.   lst
  104.       )
  105.     )
  106.     (entupd (cdr (assoc -1 lst)))
  107.   )
  108. )

  109. (defun c:150 (/ GR LST PT)
  110.   (setq  lst
  111.    (entget
  112.      (entmakex
  113.        (list
  114.          '(0 . "LINE")
  115.          (cons 8 (getvar "CLAYER"))
  116.          (cons 10
  117.          (setq pt (getpoint "\n Specify the first point  "))
  118.          )
  119.          (cons 11 pt)
  120.        )
  121.      )
  122.    )
  123.   )
  124.   (princ "\n Specify the second point  ")
  125.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  126.     (entmod
  127.       (subst
  128.   (cons 11 (polar pt (/ pi 1.2) (distance pt (cadr gr))))
  129.   (assoc 11 lst)
  130.   lst
  131.       )
  132.     )
  133.     (entupd (cdr (assoc -1 lst)))
  134.   )
  135. )
发表于 2015-11-2 15:47:20 | 显示全部楼层
  1. (defun c:test (/ GR LST PT)
  2.    (if (= (setq jdz (getint "\n角度[30/60/45/120/150]<30>:")) nil)
  3.        (setq jdz 30)
  4.    )
  5.    (setq hjdz (* pi (/ jdz 180.0)))
  6.    (setq  lst
  7.       (entget
  8.          (entmakex
  9.             (list
  10.                   '(0 . "LINE")
  11.                    (cons 8 (getvar "CLAYER"))
  12.                    (cons 10
  13.                       (setq pt (getpoint "\n Specify the first point  "))
  14.                   )
  15.                   (cons 11 pt)
  16.            )
  17.         )
  18.      )
  19.   )
  20.   (princ "\n Specify the second point  ")
  21.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  22.     (entmod
  23.       (subst
  24.            (cons 11 (polar pt hjdz (distance pt (cadr gr))))
  25.            (assoc 11 lst)
  26.            lst
  27.       )
  28.     )
  29.     (entupd (cdr (assoc -1 lst)))
  30.   )
  31. )
 楼主| 发表于 2015-11-2 15:51:49 | 显示全部楼层
本帖最后由 说了谁懂721 于 2015-11-2 15:59 编辑
yshf 发表于 2015-11-2 15:47

非常感谢!最好能保留角度命令,这样可以直接输入。
           (defun c:30 ())
           (defun c:45 ())
           (defun c:60 ())
           (defun c:120 ())
           .
           .
           .
           .

发表于 2015-11-2 17:59:27 | 显示全部楼层
  1. (defun FixAngLine (ang / gr lst pt)
  2.   (setq  lst
  3.    (entget
  4.      (entmakex
  5.        (list
  6.          '(0 . "LINE")
  7.          (cons 8 (getvar "CLAYER"))
  8.          (cons 10
  9.          (setq pt (getpoint "\n Specify the first point  "))
  10.          )
  11.          (cons 11 pt)
  12.        )
  13.      )
  14.    )
  15.   )
  16.   (princ "\n Specify the second point  ")
  17.   (while (and (setq gr (grread 5)) (= (car gr) 5))
  18.     (entmod
  19.       (subst
  20.   (cons 11 (polar pt (/ pi ang) (distance pt (cadr gr))))
  21.   (assoc 11 lst)
  22.   lst
  23.       )
  24.     )
  25.     (entupd (cdr (assoc -1 lst)))
  26.   )
  27.   (princ)
  28. )
  29. (defun c:30 () (FixAngLine 6))
  30. (defun c:45 () (FixAngLine 4))
  31. (defun c:60 () (FixAngLine 3))
  32. (defun c:120 () (FixAngLine 1.5))
  33. (defun c:150 () (FixAngLine 1.2))

评分

参与人数 1金钱 +20 收起 理由
说了谁懂721 + 20 很给力!

查看全部评分

发表于 2015-11-2 19:26:19 | 显示全部楼层
保留角度命令,那就改为:
  1. (defun c:test1()
  2.     (if (= (setq jdz (getint "\n角度[30/45/60/120/150]<30>:")) nil)
  3.         (setq jdz 30)
  4.     )
  5.     (eval (read (strcat "(c:" (itoa jdz) ")")))
  6.     (princ)
  7. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-10-29 12:49 , Processed in 0.162593 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表