明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1407|回复: 4

我写的小程序有问题

[复制链接]
发表于 2006-11-15 08:54 | 显示全部楼层 |阅读模式

我第一次用lisp写了一个画楼梯踏步的程序,就是实现以下:功能输入楼梯踏步宽,步数,以及高度就可以把那条折线画出来,写完了加载后应用起来有问题,有时能成功,有时不行,请高手帮忙看一下怎么回事?程序代码如下:

;LTTB.LSP
;楼梯踏步

   (defun c:lttb (/ oce p1 p3 a1 a2 p2 x1 x2 y1 s1 h1 h2 n1)
      (graphscr)
      (setq oce (getvar "cmdecho") )
      (setvar "cmdecho" 0)

      (setq
          p1 (getpoint "\nThe start point of The stair: ")
          n1 (getint "\nThe number of The stair: ")
          s1 (getint "\nThe width of The stair: ")
          h1 (getint "\nThe total-heigth of the stair: ")
          n1 (+ n1 1)
          h2 (/ h1 n1 1.0)
          h2 (* h2 2.0)
          s1 (* s1 2)
          x2 (car p1)   
      )
     
      (while (< (car p1) (+ x2 (* n1 s1) ) )
         (setq
               x1 (car p1)
               y1 (cadr p1)
               p2 (list x1 (+ y1 h2) )
               p3 (list (+ x1 s1)  (cadr p2) )
         )
         (command ".pline" p1 "w" 0 "" p2 p3 "")
         (setq p1 p3)
     )
    
     (setq
         x1 (car p1)
         y1 (cadr p1)
         p1 (list (- x1 (* n1 s1 ) ) (- y1 (* h1 2.0) ) )
         a1 (entlast)
         a2 (ssget "w" p1 p3)
     )

     (command ".pedit" a1 "j" a2 "" "" )

     (setvar "cmdecho" oce)
     (princ)

   )

发表于 2006-11-15 16:39 | 显示全部楼层
把捕捉关了再试试。
发表于 2006-11-15 20:28 | 显示全部楼层

对呀

我们在做绘图时候,最好把捕捉关掉

 

 楼主| 发表于 2006-11-16 08:42 | 显示全部楼层

谢谢,我试试看

这里真的有很多的高手,一语惊醒梦中人!

 楼主| 发表于 2006-11-17 08:45 | 显示全部楼层

我试完了,还真的有效

程序写的很罗嗦,不太好意思,这是我的第一个程序!

在(setvar "cmdecho" 0)后加一行以下程序

      (setvar "osmode" 0)

谢谢高手的指点,象他们学习!

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

本版积分规则

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

GMT+8, 2024-5-11 20:34 , Processed in 0.143425 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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