明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 963|回复: 4

[已解答] 求助:一个程序,有些可以运行,有些不可以

[复制链接]
发表于 2013-7-15 22:16 | 显示全部楼层 |阅读模式
一个画螺孔的程序,我想改成可以指定螺孔规格的,但M3却变成了M2,M5变成了M4,而且这两个的中心线也有问题,
其它规格的就可以,不懂是哪里错了,恳请路过的大师帮看看,谢谢了。

;绘制螺(孔邹锋 2013.5.10 http://bbs.mjtd.com/thread-100947-3-1.html
(defun zlk()
(command "undo" "be")
(setq la (getvar"clayer"))
(command "layer" "m" "螺纹" "c" "53" "" "lw" "0.13" "" "l" "Continuous" "" ""
"layer" "m" "3中心线" "c" "1" "" "lw" "0.13" "" "l" "CENTER" "" "" "clayer" la)
;  (if (= a nil)
;    (setq a 8)
;  )
;  (princ "\n请输入螺孔规格(M")
;  (princ (fix a))
;  (princ "):")
;  (setq x (getreal))
;  (setq x 8)
;  (cond        ((= nil (numberp x)) (setq x a))
;        ((= T (numberp x)) (setq a x))
;  )
  (setq pb (getpoint "\n请指定放置位置:"))
  (setq        m  (/ a 2)
        m1 (* 0.85 m)
        p1 (polar pb pi m)
        p2 (polar pb (* pi 1.5) m)
  )
  (command "arc" p2 "e" p1 pb)
(command "chprop" (entlast) "" "P" "la" "螺纹" "c" "byl" "lw" "byl" "lt" "byl" "")
  (setq l1 (ssget "l"))
  (command "circle" pb m1)
(command "chprop" (entlast) "" "P" "la" "0" "c" "byl" "lw" "byl" "lt" "byl" "")
  ;*********************
;计算两条直线四个点
  (setq chklty (tblsearch "LTYPE" "CENTER"))
(if (= chklty nil)
   (entmake (list '(0 . "LTYPE") '(100 . "AcDbSymbolTableRecord")  '(100 . "AcDbLinetypeTableRecord")
      (cons 2 "CENTER")

;  '(3 . "CENTER ____ _ ____ _ ____ _ ____ _ ____ _ ____")
;      '(70 . 0)  '(73 . 2) '(40 . 15.0) '(49 . 10.0)  '(74 . 0) '(49 . -5.0) '(74 . 0)

       )
      )
   )

  (setq xk (* a 0.5))
  (setq pt1 (polar pb 0 (* 1.2 (/ a 2))))
  (setq pt3 (polar pb pi (* 1.2 (/ a 2))))
  (setq pt2 (polar pb (* 0.5 pi) (* 1.2 (/ a 2))))
  (setq pt4 (polar pb (* 1.5 pi) (* 1.2 (/ a 2))))
  (entmake (list (cons 0 "LINE")
                 (CONS 62 1)
                 (cons 6  "CENTER")
                 (cons 48 xk)
                 (cons 10 pt1)
                 (cons 11 pt3)
           )
  )
(command "chprop" (entlast) "" "P" "la" "3中心线" "c" "byl" "lw" "byl" "lt" "byl" "")
  (setq en2 (entlast))
  (entmake (list (cons 0 "LINE")
                 (CONS 62 1)
                 (cons 48 xk)
                 (cons 6  "CENTER")
                 (cons 10 pt2)
                 (cons 11 pt4)
           )
  )
(command "chprop" (entlast) "" "P" "la" "3中心线" "c" "byl" "lw" "byl" "lt" "byl" "")
(command "undo" "e")
(princ))


(defun c:3`()(setq a 3)(zlk)(princ))
(defun c:4`()(setq a 4)(zlk)(princ))
(defun c:5`()(setq a 5)(zlk)(princ))
(defun c:6`()(setq a 6)(zlk)(princ))
(defun c:8`()(setq a 8)(zlk)(princ))
(defun c:10`()(setq a 10)(zlk)(princ))
(defun c:12`()(setq a 12)(zlk)(princ))
(defun c:14`()(setq a 14)(zlk)(princ))
(defun c:16`()(setq a 16)(zlk)(princ))
(defun c:18`()(setq a 18)(zlk)(princ))
(defun c:20`()(setq a 20)(zlk)(princ))
(defun c:22`()(setq a 22)(zlk)(princ))
(defun c:24`()(setq a 24)(zlk)(princ))

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-7-15 22:30 | 显示全部楼层
程序还可以这样写呀,不知道你的lisp怎么学的
 楼主| 发表于 2013-7-15 22:49 | 显示全部楼层

RE: 求助:一个程序,有些可以运行,有些不可以

pzweng 发表于 2013-7-15 22:30
程序还可以这样写呀,不知道你的lisp怎么学的

我英文只考了几十分,一直都读不懂字母,非常惭愧。
发表于 2013-7-15 23:20 | 显示全部楼层
;直径整除了。
  1. ;绘制螺(孔邹锋 2013.5.10 http://bbs.mjtd.com/thread-100947-3-1.html)
  2. (defun zlk()
  3. (command "undo" "be")
  4. (setq la (getvar "clayer"))
  5. ;  (if (= a nil) (setq a 8))
  6. ;  (setq x (getreal (strcat "\n请输入螺孔规格(M" (rtos (fix a) 2) "):")))
  7. ;  (or x (setq x 8))
  8. ;  (cond
  9. ;   ((= nil (numberp x)) (setq x a))
  10. ;   ((= T (numberp x)) (setq a x))
  11. ;  )
  12. (setq pb (getpoint "\n请指定放置位置:"))
  13. (setq m  (/ a 2.0)
  14.        m1 (* 0.85 m)
  15.        p1 (polar pb pi m)
  16.        p2 (polar pb (* pi 1.5) m))
  17. (command "layer" "m" "螺纹" "c" "53" "" "lw" "0.13" "" "")
  18. (command "arc" p2 "e" p1 pb)
  19. (command "layer" "m" "3中心线" "c" "1" "" "lw" "0.13" "" "lt" "CENTER" "" "")
  20. (command "circle" pb m1)
  21. (setvar "clayer" la)
  22.   ;*********************
  23. ;计算两条直线四个点
  24. (setq pt1 (polar pb 0 (* 1.2 m)))
  25. (setq pt3 (polar pb pi (* 1.2 m)))
  26. (setq pt2 (polar pb (* 0.5 pi) (* 1.2 m)))
  27. (setq pt4 (polar pb (* 1.5 pi) (* 1.2 m)))
  28. (entmake (list (cons 0 "LINE") (cons 8 "3中心线") (cons 10 pt1) (cons 11 pt3)))
  29. (entmake (list (cons 0 "LINE") (cons 8 "3中心线") (cons 10 pt2) (cons 11 pt4)))
  30. (command "undo" "e")
  31. (princ)
  32. )
  33. (defun c:3 ()(setq a 3)(zlk))
  34. (defun c:4 ()(setq a 4)(zlk))
  35. (defun c:5 ()(setq a 5)(zlk))
  36. (defun c:6 ()(setq a 6)(zlk))
  37. (defun c:8 ()(setq a 8)(zlk)))
  38. (defun c:10 ()(setq a 10)(zlk))
  39. (defun c:12 ()(setq a 12)(zlk))
  40. (defun c:14 ()(setq a 14)(zlk))
  41. (defun c:16 ()(setq a 16)(zlk))
  42. (defun c:18 ()(setq a 18)(zlk))
  43. (defun c:20 ()(setq a 20)(zlk))
  44. (defun c:22 ()(setq a 22)(zlk))
  45. (defun c:24 ()(setq a 24)(zlk))

评分

参与人数 1明经币 +1 收起 理由
669423907 + 1 非常感谢Z版热情帮助

查看全部评分

 楼主| 发表于 2013-7-15 23:27 | 显示全部楼层
非常感谢Z版帮忙,手机上,明天用上
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 21:03 , Processed in 0.221839 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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