找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 590|回复: 0

[求助] [求助]:我是新手,请指教

[复制链接]
发表于 2006-5-19 18:00:41 | 显示全部楼层 |阅读模式

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

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

×
我有一段程序,开始运行起来没有错,但是运行第二次以后就会出错,只有重新启动cad才可以,,,一些图形会不能画出来,我用到了offset  说是通过的点无效,我想知道什么叫无效,有朋友说是变量上的问题,我改了之后还是不行,,还有可能是什么方面的问题 

程序如下:
;xinjian.lsp



(defun sum(lst / ii sum1)
     (setq sum1 0)
     (setq ii 0)
     (repeat (length lst)
       (setq sum1 (+ sum1 (nth ii lst)))
       (setq ii (+ ii 1))
       )
     (eval sum1)
)


(defun loaddlg()
  (setq dcl_id (load_dialog "dcl_zwdraw.dcl"))
  (if (not(new_dialog "dcl_zwdraw" dcl_id)) (exit) )
  (mode_tile "down" 2)
  (set_tile "zhouhaos" "1")
  (set_tile "zhouhaoc" "A")
  (action_tile "accept"  "(setto)(done_dialog)")
  (action_tile "cancel" "(done_dialog)")
  (start_dialog)
  (unload_dialog dcl_id)
)



(defun setto( / leftt rightt downn upp)

     (setq snumber (get_tile "zhouhaos"))
     (setq cnumber (get_tile "zhouhaoc"))
     (setq downn (get_tile "down"))
     (setq upp (get_tile "up"))
     (setq leftt (get_tile "left"))
     (setq rightt (get_tile "right"))
     (setq aa (read (strcat "("downn")")))
     (setq aaa (read (strcat "("leftt")")))
     (setq bb (read (strcat "("upp")")))
     (setq bbb (read (strcat "("rightt")")))

)


(defun draw( / x1 y1 y2 p1 i ll l pns tns x11 y11 i1)

   (setq x1 (car pp))
   (setq y1 (cadr pp))
   (setq y2 (+ y1 clength))
   (setq p1 (list x1 y2))
   (setq i 0)
   (command "line" pp p1 "")
   (setq ll (entlast))
   (setq l (entlast))
   (setq y1 (- y1 100))
   (setq pns (list x1 (- y1 100)))
   (command "circle" pns 80)
   (command "text" "m" pns 60 0 snumber)
   (setq snumber (atoi snumber))
   (repeat(length aa)
        (setq x1 (+ x1 (nth i aa)))
        (setq p1 (list x1  y1))
        (setq pns (list x1 (- y1 100)))
        (command "offset" "t" l p1 "")
        (setq l (entlast))
        (setq snumber (+ snumber 1))
        (setq tns (itoa snumber))
        (command "circle" pns 80)
        (command "text" "m" pns 60 0 tns)
        (setq i (+ i 1))
   )



   (setq x11 (car pp))
   (setq y11 (cadr pp))
   (setq y11 (+ y11 clength))
   (setq y11 (+ y11 100))
   (setq i1 0)
   (repeat(length bb)
        (setq x11 (+ x11 (nth i1 bb)))
        (setq p11 (list x11 (+ y11 150)))
        (command "offset" "t" ll p11 "")
        (setq ll (entlast))
        (setq i1 (+ i1 1))
   )
)




(defun ddraw( / xx1 yy1 ppp xx2 k pp1 jj j pnc tnc xx11 yy11 pp11 kk)
   (setq xx1 (car pp))
   (setq yy1 (cadr pp))
   (setq ppp (list xx1 yy1))
   (setq xx2 (+ xx1 slength))
   (setq pp1 (list xx2 yy1))
   (setq k 0)
   (command "line" ppp pp1 "")
   (setq xx1 (- xx1 100))
   (setq jj (entlast))
   (setq j (entlast))
   (setq pnc (list (- xx1 100) yy1))
   (command "circle" pnc 80)
   (command "text" "m" pnc 60 0 cnumber)
   (setq cnumber (ascii cnumber))
   (repeat(length aaa)
        (setq yy1 (+ yy1 (nth k aaa)))
        (setq pp1 (list (- xx1 150) yy1))
        (setq pnc (list (- xx1 100) yy1))     
        (command "offset" "t" j pp1 "")
        (setq j (entlast))
        (setq cnumber (+ cnumber 1))
        (setq tnc (chr cnumber))
        (command "circle" pnc 80)
        (command "text" "m" pnc 60 0 tnc)
        (setq k (+ k 1))
   )


   (setq yy11 (cadr pp))
   (setq xx11 (+ (car pp) slength))
   (setq xx11 (+ xx11 150))
   (setq kk 0)
   (repeat(length bbb)
        (setq yy11 (+ yy11 (nth kk bbb)))
        (setq pp11 (list xx11 yy11))     
        (command "offset" "t" jj pp11 "")
        (setq jj (entlast))
        (setq kk (+ kk 1))
   )
)




(defun C:xinjian( / a1 a2 a3 a4)
   

    (graphscr)
    (setq oce (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (loaddlg)
    (setq a1 (sum aa))
    (setq a2 (sum bb))
    (setq a3 (sum aaa))
    (setq a4 (sum bbb))
    (if (>= a1 a2)
       (setq slength a1)
       (setq slength a2)
    )
   
    (if (>= a3 a4)
       (setq clength a3)
       (setq clength a4)
    )

   
    (setq pp (getpoint "\n单击选择基点:"))
   
    (draw)
    (ddraw)
   
    (setvar "cmdecho" oce)
   
)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-9-23 12:24 , Processed in 0.320879 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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