明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 609|回复: 4

[提问] 在这个循环中画的所有矩形,在循环外,整个程序结束前删除

[复制链接]
发表于 2018-11-11 08:58:03 | 显示全部楼层 |阅读模式
(while (and        (setq s1 (nth n ns))     ;取得第n点的坐标
                (setq s2 (vl-position s1 ns))     ;取得第n点坐标在交点坐标列表中的位置
                (setq s3 (nth (1+ s2) ns))           ;取得第n点下一个点的坐标
                (setq is (distance s1 s3))                ;取得相邻两个坐标点的距离
                (setq ps11(polar s1 (- k (* 0.5 pi)) (+ th 300)))
                (setq ps33(polar s3 (- k (* 0.5 pi)) (+ th 300)))
           )
      (if (> is 600)                                  ;如果相邻两个坐标点的距离大于600
          (progn
        (command "line" s1 ps11 "")     ;画线
        (command "line" s3 ps33 "")
        (command "rectang"  s1 ps33 "")
           )
          )
      (setq n (1+ n))
    )
这是整个程序中的一段,在这个循环中(command "rectang"  s1 ps33 "") 画的矩形,我想在整个程序结束前把它删除,这个怎么写


"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2018-11-11 09:35:51 | 显示全部楼层
(setq ssa (ssadd))
(while (and        (setq s1 (nth n ns))     ;取得第n点的坐标
                (setq s2 (vl-position s1 ns))     ;取得第n点坐标在交点坐标列表中的位置
                (setq s3 (nth (1+ s2) ns))           ;取得第n点下一个点的坐标
                (setq is (distance s1 s3))                ;取得相邻两个坐标点的距离
                (setq ps11(polar s1 (- k (* 0.5 pi)) (+ th 300)))
                (setq ps33(polar s3 (- k (* 0.5 pi)) (+ th 300)))
           )
      (if (> is 600)                                  ;如果相邻两个坐标点的距离大于600
          (progn
        (command "line" s1 ps11 "")     ;画线
        (command "line" s3 ps33 "")
        (command "rectang"  s1 ps33 "")
        (setq ssa (ssadd (entlast) ssa))
           )
          )
      (setq n (1+ n))
    )
    (command "_erase" ssa "")
发表于 2018-11-11 09:36:49 | 显示全部楼层
调用 SSAdd 函数
ref: http://bbs.mjtd.com/thread-178513-1-1.html

也可考量这个函数
(grdraw from to color [highlight])
 楼主| 发表于 2018-11-11 11:23:39 | 显示全部楼层
非常谢谢,问题解决
再问一下
(if (> is 600)  
  改成下面这样,当is=800.0,程序为啥不执行prong下面的command

(if (or (= is 700.0)(= is 800.0) (= is 900.0)(= is 1000.0))   
                              
       
发表于 2018-11-11 11:53:35 | 显示全部楼层
建议参考用 equal 函数
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-19 05:07 , Processed in 0.163478 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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