明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2249|回复: 11

IF语句不起作用, 求助

[复制链接]
发表于 2012-11-20 17:04:23 | 显示全部楼层 |阅读模式
(defun c:xh ()
  (setvar "cmdecho" 0)   ;命令回显
  (setq tx (getint "\n起始数字:"))
  (if (= tx nil)(= tx 1))
  (setq yq (getdist "\n序号球直径:"))
  (if (= yq nil)(= yq 5))
  (while
    (setq os (getvar "osmode"))  ;系统变量
     (setq po (getpoint "\n引线起点:"))
     (setvar "osmode" 0)  ;设置系统变量
     (command "line" po pause "")
     (setq pt (cadr (grread pause)))
     (setq ang (angle po pt))
     (command "circle" "2p" pt (polar pt ang yq) "")
     (setq cir entlast)
     (setq cirdata (cdr (assoc 10 (entget (cir)))))
     (command "text" "j" "m" cirdata "" "" tx "")
     (setq tx (1+ tx))
     (setvar "osmode" os)
  )
)

两句IF语句不起作用,请求大家帮助.
发表于 2012-11-20 17:12:45 | 显示全部楼层
(if (= tx nil)(setq tx 1))
..........

(if (= yq nil)(setq yq 5))
 楼主| 发表于 2012-11-20 21:58:27 | 显示全部楼层
谢谢版主,没想到是这样,呵呵
发表于 2012-11-21 10:01:43 | 显示全部楼层
我也偷学了
发表于 2014-11-18 21:17:29 | 显示全部楼层
这个lsp不错,但是设置半径为5  和 设置半径为 50 ,球筐是放大了,但是字符并没有放大,如何解决??
 楼主| 发表于 2014-11-29 09:07:57 | 显示全部楼层
lengxiaxi 发表于 2014-11-18 21:17
这个lsp不错,但是设置半径为5  和 设置半径为 50 ,球筐是放大了,但是字符并没有放大,如何解决??

这个程式我已更新了,你看下能不能用
(defun c:xhq ( / gj tx yq)  
  (setvar "cmdecho" 0)
  (setvar "osmode"512)
  (setq tx (getint "\n起始值<1>:"))
  (if (= tx nil)(setq tx 1))
  (setq yq (getdist "\n文字高度:"))
  (if (= yq nil)(setq yq 5))
  (initget "p")
  (setq gj(getkword "\n[设置递增/递减(P)]<递增>:"))
  (if (= gj nil)(dz))
  (if (setq gj "P") (dj))
)
(defun dz()
  (while
     (setq po (getpoint "\n引线起点:"))
     (command "line" po pause "")
    (setq len entlast)
    (setq pt(cdr(assoc 11(entget(len)))))
     (setq ang (angle po pt))
     (command "circle" "2p" pt (polar pt ang (* 2 yq)))
     (setq cir entlast)
     (setq cirdata (cdr (assoc 10 (entget (cir)))))
    (command "text" "j" "mc" cirdata yq "" tx)
     (setq tx (1+ tx))

  ))
(defun dj()
  (while
     (setq po (getpoint "\n引线起点:"))
     (command "line" po pause "")
    (setq len entlast)
    (setq pt(cdr(assoc 11(entget(len)))))
     (setq ang (angle po pt))
     (command "circle" "2p" pt (polar pt ang (* 2 yq)))
     (setq cir entlast)
     (setq cirdata (cdr (assoc 10 (entget (cir)))))
     (command "text" "j" "mc" cirdata yq "" tx)
     (setq tx (1- tx))
  )
  )
  
发表于 2014-11-29 12:03:25 | 显示全部楼层
Comming 发表于 2014-11-29 09:07
这个程式我已更新了,你看下能不能用
(defun c:xhq ( / gj tx yq)  
  (setvar "cmdecho" 0)

嗯,可以用了。我此前也转发过你这个lsp,请版主修改了。效果和你这个一样。引脚如果能改为箭头就完美了。
 楼主| 发表于 2015-1-16 11:33:45 | 显示全部楼层
本帖最后由 Comming 于 2015-1-17 21:18 编辑
lengxiaxi 发表于 2014-11-29 12:03
嗯,可以用了。我此前也转发过你这个lsp,请版主修改了。效果和你这个一样。引脚如果能改为箭头就完美了。 ...

引脚改为箭头了,你用一下,看看还有什么问题需要改进!在我能力之内会帮你解决。
  1. (defun c:xhq (/ gj tx yq os)
  2.   (setq os (getvar "osmode"))
  3.   (setvar "cmdecho" 0)
  4.   (setq tx (getint "\n起始值<1>:"))
  5.   (if (= tx nil)
  6.     (setq tx 1)
  7.   )
  8.   (setq yq (getdist "\n文字高度:"))
  9.   (if (= yq nil)
  10.     (setq yq 5)
  11.   )
  12.   (initget "p")
  13.   (setq gj (getkword "\n[设置递增/递减(P)]<递增>:"))
  14.   (cond ((= gj nil) (dz))
  15. ((= gj "p") (dj)))
  16.   (princ)
  17. (setvar "osmode" os)
  18. )
  19. (defun dz ()
  20.   (while (>= tx tx)
  21.     (yx)
  22.     (setq tx (1+ tx))
  23.   )
  24. )
  25. (defun dj ()
  26.   (while (<= tx tx)
  27.     (yx)
  28.     (setq tx (1- tx))
  29.   )
  30. )
  31. (defun yx ()
  32.   (setvar "osmode" 512)
  33.   (setq apt (getpoint "\n引线起点:"))
  34.   (command "leader"apt(setq bpt (getpoint apt "\n引线终点:"))"""""n")
  35.   (setq ang (angle apt bpt))
  36.   (setvar "osmode" 0)
  37.   (command "circle" "2p" bpt (polar bpt ang (* 2.5 yq)))
  38.   (setq cir entlast)
  39.   (setq cirdata (cdr (assoc 10 (entget (cir)))))
  40.   (command "text" "j" "mc" cirdata yq "" tx)
  41. )
发表于 2015-1-16 14:34:34 | 显示全部楼层
Comming 发表于 2015-1-16 11:33
引脚改为箭头了,你用一下,看看还有什么问题需要改进!在我能力之内会帮你解决。

当中两句修改成(setq bpt (getpoint apt "\n引线终点:")),看起来会直观一点。
 楼主| 发表于 2015-1-17 21:05:29 | 显示全部楼层
ljpnb 发表于 2015-1-16 14:34
当中两句修改成(setq bpt (getpoint apt "\n引线终点:")),看起来会直观一点。

好主意,我已在8楼更新了程式。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-20 06:24 , Processed in 0.192711 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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