明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1931|回复: 11

[已解答] 请教各位高手关于这个循环的问题

[复制链接]
发表于 2015-4-17 08:07:24 | 显示全部楼层 |阅读模式
本帖最后由 幽默的armstrong 于 2015-4-17 08:33 编辑

(defun C:333(/ a b x y x1 y1 xx3 xx6 yy3 yy6)
  (graphscr)
  (setvar "cmdecho" 0)
  (setq a(list 100 100))
  (setq b(list 200 200) )
  (setq x (car a))
  (setq y (cadr a))
  (setq x1(+ x 1))
  (setq y1(+ y 1))
            (while  (< x1 (car b) )               
                        (if  (= 0 (rem x1 10 ))
                                  (while (< y1 (cadr b)))
                                        (setq xx3(list (- x1 3) y1))
                                         (setq xx6(list (+ x1 3 ) y1))
                                            (setq yy3(list x1 (- y1 3)))
                                         (setq yy6(list x1 (+ y1 3)))
                                                (if(= 0 (rem y1 10 ))
                                                (progn               
                                                (command "pline" xx3 xx6 "c" )
                                                (command "pline" yy3 yy6 "c" )
                                                 )
                                                )
                                                (setq y1(1+ y1))
                                )
                        )
                )
                (setq x1(1+ x1))
          )
)

怎么能把这个范围内(100,100) (200, 200)
用十字丝画满?
新人,先谢谢大家拉

本帖子中包含更多资源

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

x
发表于 2015-4-17 09:21:15 | 显示全部楼层
先绘制一个十字,再阵列吧。
发表于 2015-4-17 09:46:40 | 显示全部楼层
本帖最后由 ZZXXQQ 于 2015-4-17 15:31 编辑
  1. (defun C:333(/ a b x y x1 y1 xx3 xx6 yy3 yy6)
  2. (graphscr)
  3. (setvar "cmdecho" 0)
  4. (setq a (list 100 100))
  5. (setq b (list 200 200))
  6. (setq x (car a))
  7. (setq y (cadr a))
  8. (setq x1 (+ x 10))
  9. (setq y1 (+ y 10))
  10. (while (>= (abs (- (car b) x1)) 20)               
  11.   (while (>= (abs (- (cadr b) y1)) 20)
  12.    (setq xx3 (list (- x1 3) y1))
  13.    (setq xx6 (list (+ x1 3) y1))
  14.    (setq yy3 (list x1 (- y1 3)))
  15.    (setq yy6 (list x1 (+ y1 3)))
  16.    (command "line" xx3 xx6 "" "line" yy3 yy6 "")
  17.    (setq y1 (+ y1 10))
  18.   )
  19.   (setq y1 (+ y 10))
  20.   (setq x1 (+ x1 10))
  21. )
  22. )
  1. (defun C:333 (/ p1 p2 p0 e1 e2 _v vx vy ss)
  2. (if (and (setq p1 (getpoint "\nFirst Corner: "))
  3.           (setq p2 (getcorner p1 "\nOrther Corner: "))) (progn
  4.   (setq p0 (mapcar '+ p1 '(10 10 0))
  5.         e1 (entmakex
  6.             (list
  7.              '(0 . "LINE")
  8.              (cons 10 (mapcar '- p0 '(1.5 0 0)))
  9.              (cons 11 (mapcar '+ p0 '(1.5 0 0)))
  10.             )
  11.            )
  12.         e2 (entmakex
  13.             (list
  14.              '(0 . "LINE")
  15.              (cons 10 (mapcar '- p0 '(0 1.5 0)))
  16.              (cons 11 (mapcar '+ p0 '(0 1.5 0)))
  17.             )
  18.            )
  19.         _v (mapcar 'abs (mapcar '- p2 p1))
  20.         vx (fix (/ (car _v) 10))
  21.         vy (fix (/ (cadr _v) 10))
  22.   )
  23.   (vl-cmdf ".rectang" "_none" p1 "_none" p2)
  24.   (vl-cmdf ".array" e1 e2 "" "r" vy vx 10 10)
  25. ))
  26. (princ)
  27. )
 楼主| 发表于 2015-4-17 10:07:36 | 显示全部楼层
谢谢你的帮助,但是我需要那个判断语句,就是坐标值被10整除
你的语句把判断语句删除了,假如a 不是(100,100)是(91,91)画线命令也要画在(100,100) (110,110)(110,120)...

点评

楼上改了。  发表于 2015-4-17 15:32
 楼主| 发表于 2015-4-17 10:08:50 | 显示全部楼层
fl202 发表于 2015-4-17 09:21
先绘制一个十字,再阵列吧。

不行的,这只是一部分语句
 楼主| 发表于 2015-4-17 10:09:36 | 显示全部楼层
ZZXXQQ 发表于 2015-4-17 09:46

谢谢你的帮助,但是我需要那个判断语句,就是坐标值被10整除
你的语句把判断语句删除了,假如a 不是(100,100)是(91,91)画线命令也要画在(100,100) (110,110)(110,120)...
发表于 2015-4-17 11:15:59 | 显示全部楼层
本帖最后由 llsheng_73 于 2015-4-17 11:17 编辑

  1. (defun C:333(/ a b x1 y1)
  2.   (graphscr)
  3.   (setvar "cmdecho" 0)
  4.   (setq a(list 100 100))
  5.   (setq b(list 200 200) )
  6.   (command"rectangle"a b)
  7.   (setq x1(*(fix(/ (car a)10))10))
  8.   (repeat(1-(/(-(car b)(car a))10))
  9.     (setq x1(+ x1 10))
  10.     (setq y1 (*(fix(/ (cadr a)10))10))
  11.     (repeat(1-(/(-(cadr b)(cadr a))10))
  12.       (setq y1(+ y1 10))
  13.       (command "pline" (list (- x1 3) y1) (list (+ x1 3 ) y1) "" )
  14.       (command "pline" (list x1 (- y1 3)) (list x1 (+ y1 3)) "" )
  15.       )
  16.     )
  17. )
发表于 2015-4-17 11:50:11 | 显示全部楼层
(defun C:333 (/ p1 p2 p0 e1 e2 _v vx vy ss)
  (if (and (setq p1 (getpoint "\nFirst Corner: "))
           (setq p2 (getcorner p1 "\nOrther Corner: "))
      )
    (progn
      (setq p0 (mapcar '+ p1 '(10. 10. 0.))
            e1 (entmakex (list '(0 . "LINE")
                               (cons 10 (mapcar '+ p0 '(-1.5 0. 0.)))
                               (cons 11 (mapcar '+ p0 '(1.5 0. 0.)))
                         )
               )
            e2 (entmakex        (list '(0 . "LINE")
                              (cons 10 (mapcar '+ p0 '(0. -1.5 0.)))
                              (cons 11 (mapcar '+ p0 '(0. 1.5 0.)))
                        )
               )
            _v (mapcar '- p2 p1)
            vx (fix (/ (car _v) 10.))
            vy (fix (/ (cadr _v) 10.))
            ss (ssadd)
      )
      (ssadd e1 ss)
      (ssadd e2 ss)
      (vl-cmdf ".rectang" "_none" p1 "_none" p2)
      (vl-cmdf ".array" ss "" "r" vy vx 10 10)
    )
  )
  (princ)
)
 楼主| 发表于 2015-4-17 15:50:29 | 显示全部楼层
ZZXXQQ 发表于 2015-4-17 09:46

谢谢啦,虽然我没有看太懂,我还是学到了不少东西。谢谢
 楼主| 发表于 2015-4-17 15:51:25 | 显示全部楼层
llsheng_73 发表于 2015-4-17 11:15

谢谢了啊,学习了。收藏起来慢慢研究
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-22 03:57 , Processed in 0.182148 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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