找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 620|回复: 3

[LISP程序]:一个可用但是有问题的lisp程序请高手予以更正

[复制链接]
发表于 2003-6-12 21:38:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
这是我编制的一个用来标注墙、柱号,索引号的程序。可以显示以下功能:
1、设置不同的对齐方式对齐编号
2、墙、柱号,索引号的字母由程序自动转换为大写
3、在连续编号时,自动进行累加
4、自行设置所标注符号的大小。
    尽管程序可以实现上述功能,但是运行中也出现了一个我百思不得其解的问题。也就是在该程序界面中写上的第二条说明。每次运行程序必须要先运行第四种标注形式,然后才能正常运行其他标注形式。否则,程序无法连续标注。
    由于本人水平所在无法解决。不得已只能在界面上写上第二条说明。希望能够得到高人的指正。如果,有人觉得还可以用的话,就拿去用吧。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2003-6-12 21:44:02 | 显示全部楼层
lisp程序如下

  1. (defun c:zhsy( / zhsy_id ola osm ocm mark BG scl ptype userzhsy userscl x y pt0 pt1 pt2 pt3
  2.                 cpt rad ss n en ent a rang cc oora loop)
  3.    (defun do_zhsy1()
  4.       (setq ptype 1)
  5.       (setvar "useri2" ptype)
  6.       (mode_tile mark 4)
  7.       (mode_tile "zhsy1" 4)
  8.       (setq mark "zhsy1")
  9.       (mode_tile "th" 1)
  10.       (set_tile "jdh" "A")
  11.    )
  12.    (defun do_zhsy2()
  13.       (setq ptype 2)
  14.       (setvar "useri2" ptype)
  15.       (mode_tile mark 4)
  16.       (mode_tile "zhsy2" 4)
  17.       (setq mark "zhsy2")
  18.       (mode_tile "th" 0)
  19.       (set_tile "jdh" "A")
  20.       (set_tile "th" "-")     
  21.    )
  22.    (defun do_zhsy3()
  23.       (setq ptype 3)
  24.       (setvar "useri2" ptype)
  25.       (mode_tile mark 4)
  26.       (mode_tile "zhsy3" 4)
  27.       (setq mark "zhsy3")
  28.       (set_tile "jdh" "A")
  29.       (mode_tile "th" 1)
  30.    )
  31.    (defun do_zhsy4()
  32.       (setq ptype 4)
  33.       (setvar "useri2" ptype)
  34.       (mode_tile mark 4)
  35.       (mode_tile "zhsy4" 4)
  36.       (setq mark "zhsy4")
  37.       (mode_tile "th" 1)
  38.       (set_tile "jdh" "1")
  39.    )
  40.   
  41.   (defun do_ok()
  42.       (setq scl (read (get_tile "scl")))
  43.       (setvar "userr1" scl)
  44.       (setq jdh (strcase (get_tile "jdh")))
  45.       (setvar "users2" jdh)
  46.       (setq th (get_tile "th"))
  47.    )
  48.    (setq temperr *error*)
  49.    (setq *error* trap1)
  50.    (setq ola (getvar "clayer"))
  51.    (setq osm (getvar "OSMODE"))
  52.    (setq ocm (getvar "CMDECHO"))
  53.    (setvar "CMDECHO" 1)
  54.    (setvar "OSMODE" 512)

  55.    (if (and (< (setq zhsy_id (load_dialog "\\XPCAD\\lsp\\zhsy")) 0)(not zhsy_id)) (exit))
  56.    (if (not (new_dialog "zhsy" zhsy_id))
  57.       (exit)
  58.    )
  59.    (setq x (dimx_tile "zhsy1") y (dimy_tile "zhsy1"))
  60.    (start_image "zhsy1")
  61.    (fill_image 0 0 x y 0)
  62.    (slide_image 0 0 x y "zhsy1")
  63.    (end_image)
  64.    (setq x (dimx_tile "zhsy2") y (dimy_tile "zhsy2"))
  65.    (start_image "zhsy2")
  66.    (fill_image 0 0 x y 0)
  67.    (slide_image 0 0 x y "zhsy2")
  68.    (end_image)
  69.    (setq x (dimx_tile "zhsy3") y (dimy_tile "zhsy3"))
  70.    (start_image "zhsy3")
  71.    (fill_image 0 0 x y 0)
  72.    (slide_image 0 0 x y "zhsy3")
  73.    (end_image)
  74.    (setq x (dimx_tile "zhsy4") y (dimy_tile "zhsy4"))
  75.    (start_image "zhsy4")
  76.    (fill_image 0 0 x y 0)
  77.    (slide_image 0 0 x y "zhsy4")
  78.    (end_image)
  79.    (princ (getvar "users1"));;*************
  80.    (setq xs "s")
  81.    (setq ptype (getvar "useri2"))
  82.    (if (or (= ptype 0) (> ptype 4))
  83.       (setq ptype 1 mark (strcat "zhsy" (itoa ptype)))
  84.       (setq mark (strcat "zhsy" (itoa ptype)))
  85.    )
  86.    (mode_tile mark 4)   
  87.    (cond ((= ptype 1) (do_zhsy1))
  88.          ((= ptype 2) (do_zhsy2))
  89.          ((= ptype 3) (do_zhsy3))
  90.          ((= ptype 4) (do_zhsy4))         
  91.    )
  92.       (setq userzhsy (getvar "users2"))
  93.       (set_tile "jdh" userzhsy);;;************
  94.    (setq userscl (getvar "userr1"))
  95.    (if (> userscl 0)
  96.       (set_tile "scl" (rtos userscl 2 1))
  97.    )
  98.   
  99.    
  100.    (action_tile "zhsy1" "(do_zhsy1)")
  101.    (action_tile "zhsy2" "(do_zhsy2)")
  102.    (action_tile "zhsy3" "(do_zhsy3)")
  103.    (action_tile "zhsy4" "(do_zhsy4)")
  104.    (action_tile "sp" "(setq choi "1") (setvar "users1" choi)");;*********
  105.    (action_tile "cz" "(setq choi "2") (setvar "users1" choi)");;*********
  106.    (action_tile "ry" "(setq choi "3") (setvar "users1" choi)");;*********
  107.    (action_tile "accept" "(do_ok) (done_dialog 1)")
  108.    (action_tile "cancel" "(done_dialog 0) (exit)")
  109.    (action_tile "help" "(help "E:/XPCAD/exe/gmlsp.hlp" "zhsy")")
  110.    (start_dialog)
  111.    (unload_dialog zhsy_id)
  112.    (command "layer" "s" "0" "")
  113.         (setq pt0 (getpoint "\n指定标注基点"))
  114.         (setq pt0x (car pt0))
  115.         (setq pt0y (car(cdr pt0)))
  116.         (setq bl (getvar "dimlfac"))
  117.         (setq p1 (car pt0))

  118.    (setq choi (getvar "users1"))
  119.    (if (or (= choi "1") (= choi "2") (= choi "3"))
  120.       (progn
  121.              (if (= choi "1")
  122.                (progn
  123.                (setq xs "s")
  124.                (set_tile "sp" "1")
  125.                )
  126.              )
  127.              (if (= choi "2")
  128.                (progn
  129.                (setq xs "c")
  130.                (set_tile "cz" "1")
  131.                )
  132.              )
  133.              (if (= choi "3")
  134.                (progn
  135.                (setq xs "r")
  136.                (set_tile "ry" "1")
  137.                )
  138.              )
  139.      )
  140.      (progn
  141.        (setq choi "1")
  142.        (setq xs "s")
  143.        (set_tile "sp" "1")
  144.      )
  145. )
  146.         (progn
  147.                  (if (= ptype 1)
  148.                      (progn
  149.                         (command "layer" "s" "0" "")

  150.                         (command "circle" pt0 (* 7 scl) "")
  151.                          (command "text" "m" pt0 (* 10 scl) 0 jdh)
  152.                         (setq jdh00 jdh)
  153.                       )
  154.                   )
  155.                 (if (= ptype 2)
  156.                      (progn
  157.                         (command "layer" "s" "0" "")
  158.                         (setq p01 (polar pt0 (* 1 pi) (* 7 scl)))
  159.                         (setq p02 (polar pt0 (* 0 pi) (* 7 scl)))
  160.                         (command "circle" pt0 (* 8 scl) "")
  161.                         (command "line" p01 p02 "")      
  162.                         (command "layer" "s" "0" "")
  163.                         (command "circle" pt0 (* 7 scl) "")
  164.                         (command "layer" "s" "0" "")
  165.                          (command "text" "m" (polar pt0 (* 0.49 pi) (* 2.76 scl)) (* 5.6 scl) 0 jdh)
  166.                         (command "text" "m" (polar pt0 (* 1.5 pi) (* 2.76 scl)) (* 5.6 scl) 0 th)
  167.                         (setq jdh00 jdh)
  168.                      )
  169.                  )
  170.                  (if (= ptype 3)
  171.                      (progn
  172.                         (command "layer" "s" "0" "")
  173.                         (setq p01 (polar pt0 (* 1 pi) (* 7 scl)))
  174.                         (setq p02 (polar pt0 (* 0 pi) (* 7 scl)))
  175.                         (command "circle" pt0 (* 8 scl) "")
  176.                         (command "layer" "s" "0" "")
  177.                         (command "circle" pt0 (* 7 scl) "")
  178.                         (command "layer" "s" "0" "")
  179.                          (command "text" "m" pt0 (* 10 scl) 0 jdh)
  180.                         (setq jdh00 jdh)
  181.                       )
  182.                   )
  183.                 (if (= ptype 4)
  184.                      (progn
  185.                         (command "layer" "s" "0" "")
  186.                         (command "circle" pt0 (* 7 scl) "")
  187.                          (command "text" "m" pt0 10 0 jdh)
  188.                         (setq I (atoi jdh))
  189.                      )
  190.                  )
  191.           )
  192.         (setq loop t)
  193.         (while loop
  194.           (setq pt0 (getpoint "\n指定下一标注点<按鼠标右键结束>"))
  195.           (setq pp pt0)
  196.           (setq p1x (car pt0))
  197.           (setq P1Y (car(cdr pt0)))
  198.           (if (= xs "c") (setq pt0 (list pt0x p1y)))
  199.           (if (= xs "s") (setq pt0 (list p1x pt0y)))
  200.           (if (or (= p1x nil)(= p1y nil))(setq pt0 nil))
  201.           (if (= JdH00 "A") (setq jdh "B"))
  202.           (if (= JdH00 "B") (setq jdh "C"))
  203.           (if (= JdH00 "C") (setq jdh "D"))
  204.           (if (= JdH00 "D") (setq jdh "E"))
  205.           (if (= JdH00 "E") (setq jdh "F"))
  206.           (if (= JdH00 "F") (setq jdh "G"))
  207.           (if (= JdH00 "G") (setq jdh "H"))
  208.           (if (= JdH00 "H") (setq jdh "I"))
  209.           (if (= JdH00 "I") (setq jdh "J"))
  210.           (if (= JdH00 "J") (setq jdh "K"))
  211.           (if (= JdH00 "K") (setq jdh "L"))
  212.           (if (= JdH00 "L") (setq jdh "M"))
  213.           (if (= JdH00 "M") (setq jdh "N"))
  214.           (if (= JdH00 "N") (setq jdh "P"))
  215.           (if (= JdH00 "P") (setq jdh "Q"))
  216.           (if (= JdH00 "Q") (setq jdh "R"))
  217.           (if (= JdH00 "R") (setq jdh "S"))
  218.           (if (= JdH00 "S") (setq jdh "T"))
  219.           (if (= JdH00 "T") (setq jdh "U"))
  220.           (if (= JdH00 "U") (setq jdh "V"))
  221.           (if (= JdH00 "V") (setq jdh "W"))
  222.           (if (= JdH00 "W") (setq jdh "X"))
  223.           (if (= JdH00 "X") (setq jdh "Y"))
  224.           (if (= JdH00 "Y") (setq jdh "Z"))
  225.           (if (= jdH00 "Z") (setq jdh "A"))
  226.           (setq I (+ I 1))
  227.           (setq I0 (itoa I))
  228.           (if pt0
  229.               (progn
  230.                  (if (= ptype 1)
  231.                      (progn
  232.                         (command "layer" "s" "0" "")
  233.                         (command "circle" pt0 (* 7 scl) "")
  234.                          (command "text" "m" pt0 (* 10 scl) 0 jdh)
  235.                         (setq jdh00 jdh)
  236.                       )
  237.                    )
  238.                  (if (= ptype 2)
  239.                    (progn
  240.                         (command "layer" "s" "0" "")
  241.                         (setq p01 (polar pt0 (* 1 pi) (* 7 scl)))
  242.                         (setq p02 (polar pt0 (* 0 pi) (* 7 scl)))
  243.                         (command "circle" pt0 (* 8 scl) "")
  244.                         (command "line" p01 p02 "")      
  245.                         (command "layer" "s" "0" "")
  246.                         (command "circle" pt0 (* 7 scl) "")
  247.                         (command "layer" "s" "0" "")
  248.                          (command "text" "m" (polar pt0 (* 0.49 pi) (* 2.76 scl)) (* 5.6 scl) 0 jdh)
  249.                         (command "text" "m" (polar pt0 (* 1.5 pi) (* 2.76 scl)) (* 5.6 scl) 0 th)
  250.                         (setq jdh00 jdh)
  251.                      )
  252.                   )
  253.                  (if (= ptype 3)
  254.                      (progn
  255.                         (command "layer" "s" "0" "")
  256.                         (setq p01 (polar pt0 (* 1 pi) (* 7 scl)))
  257.                         (setq p02 (polar pt0 (* 0 pi) (* 7 scl)))
  258.                         (command "circle" pt0 (* 8 scl) "")
  259.                         (command "layer" "s" "0" "")
  260.                         (command "circle" pt0 (* 7 scl) "")
  261.                         (command "layer" "s" "0" "")
  262.                          (command "text" "m" pt0 (* 10 scl) 0 jdh)
  263.                         (setq jdh00 jdh)
  264.                       )
  265.                   )
  266.                 (if (= ptype 4)
  267.                      (progn
  268.                         (command "layer" "s" "0" "")
  269.                         (command "circle" pt0 (* 7 scl) "")
  270.                          (command "text" "m" pt0 (* 10 scl) 0 I0)

  271.                        )
  272.                  )
  273.              )
  274.             (setq loop nil)
  275.            )
  276.     )
  277.    
  278. (command "layer" "s" ola "")
  279. (setvar "osmode" osm)
  280. (setvar "cmdecho" ocm)
  281. (princ)
  282. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-6-14 08:03:24 | 显示全部楼层
錯誤由於 I 起始值未設
...............................................
(end_image)
   (princ (getvar "users1"));;*************
   (setq xs "s" I 0)
   (setq ptype (getvar "useri2"))
.................................................................
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-6-14 10:23:57 | 显示全部楼层
谢谢你的关心。我改了以后已经能够正常运行。再次感谢您的赐教。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 19:16 , Processed in 0.188791 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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