找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1187|回复: 6

[文章]:大于1.1M画双开门,小于1.1M画单开门

[复制链接]
发表于 2007-3-1 07:56:38 | 显示全部楼层 |阅读模式

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

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

×
; Draw all size door
(defun c:dd(/ ds point1 point2 point3 point4 point5 point6 )
  (setq ds (getint "Please input door size:"))
  (command "-osnap" "INT")
  (setq point1 (getpoint "Pick the nearest point"))
  (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
  (setq point3 (list (nth 0 point1) (+ (* ds 100) (nth 1 point1))))
  (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
  (setq point5 (list (+ (- (* ds 100) 50) (nth 0 point4))
               (- (nth 1 point4) (- (* ds 100) 50))))
  (setq point6 (list (nth 0 point5) (- (nth 1 point5) 50 )))
  (command "pline" point1 "W" "0" "" point2 point3 point4 "arc" point5 "line" point6 "")
  (setq door (ssget "L"))
  (command "rectangle" point2 point4)
  (ssadd (entlast) door)
  (initget 1 "Rotate Mirror Quit")
  (setq input (getkword "Rotate\\Mirror\\Quit:"))
  (while (or (= input "Rotate")(= input "Mirror"))
   (cond
     ((= input "Rotate")
      (command "rotate" door "" point1 pause ))
     ((= input "Mirror")
      (command "mirror" door "" point1 pause "y"))
   )
   (initget "Rotate Mirror Quit")
   (setq input (getkword "Rotate\\Mirror\\Quit:")))
   (setvar "osmode" 33)
)

; Draw all size double door
(defun c:ddd(/ ds point1 point2 point3 point4 point5 point6 point7 point8 point9 )
  (setq ds (getint "Please input door size:"))
  (command "-osnap" "INT")
  (setq point1 (getpoint "Pick the nearest point"))
  (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
  (setq point3 (list (nth 0 point1) (+ (* ds 50) (nth 1 point1))))
  (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
  (setq point5 (list (+ (- (* ds 50) 50) (nth 0 point4)) (- (nth 1 point4)
               (- (* ds 50) 50))))
  (setq point6 (list (+ (- (* ds 50) 50) (nth 0 point5)) (+ (- (* ds 50) 50)
               (nth 1 point5))))
  (setq point7 (list (+ 50 (nth 0 point6)) (nth 1 point6)))
  (setq point8 (list (nth 0 point7) (- (nth 1 point7) (- (* ds 50) 50))))
  (setq point9 (list (nth 0 point8) (- (nth 1 point8) 50)))
  (command "pline" point1 "W" "0" "" point2 point3 point4 "arc" point5 "angle" "-90"
           point6 "line" point7 point8 point9 "")
  (setq d-door (ssget "L"))
  (command "rectangle" point2 point4 )
  (ssadd (entlast) d-door)
  (command "rectangle" point6 point8)
  (ssadd (entlast) d-door)
  (initget 1 "Rotate Mirror Quit")
  (setq input (getkword "Rotate\\Mirror\\Quit:"))
  (while (or (= input "Rotate")(= input "Mirror"))
   (cond
     ((= input "Rotate")
      (command "rotate" d-door "" point1 pause ))
     ((= input "Mirror")
      (command "mirror" d-door "" point1 pause "y"))
   )
   (initget "Rotate Mirror Quit")
   (setq input (getkword "Rotate\\Mirror\\Quit:"))
  )
)
这是从本论坛下载的两个画门的程序,一个画单开门,一个画双开门,我想把两个程序合并为一个程序,合并后的程序这样运行,当输入的门宽大于1.1M画双开门,小于1.1M画单开门
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 2个

财富等级: 恭喜发财

发表于 2007-3-1 11:30:03 | 显示全部楼层
按照楼主的要求,将两个函数合并后,如下:
[PHP]
(defun c:d (/ ds point1 point2 point3 point4 point5 point6 point7 point8 point9)
    (setq ds (getint "Please input door size:"))
    (command "-osnap" "INT")
    (setq point1 (getpoint "Pick the nearest point"))

    ;;判断部分
    (if        (< ds 110)
        ;; Draw all size door
        (progn
            (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
            (setq
                point3 (list (nth 0 point1)
                             (+ (* ds 100) (nth 1 point1))
                       )
            )
            (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
            (setq point5 (list (+ (- (* ds 100) 50) (nth 0 point4))
                               (- (nth 1 point4) (- (* ds 100) 50))
                         )
            )
            (setq point6 (list (nth 0 point5) (- (nth 1 point5) 50)))
            (command "pline"  point1   "W"        "0"         ""
                     point2   point3   point4        "arc"         point5
                     "line"   point6   ""
                    )
            (setq door (ssget "L"))
            (command "rectangle" point2 point4)
            (ssadd (entlast) door)
        )
        ;; Draw all size double door
        (progn
            (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
            (setq point3 (list (nth 0 point1)
                               (+ (* ds 50) (nth 1 point1))
                         )
            )
            (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
            (setq point5 (list (+ (- (* ds 50) 50) (nth 0 point4))
                               (- (nth 1 point4)
                                  (- (* ds 50) 50)
                               )
                         )
            )
            (setq point6 (list (+ (- (* ds 50) 50) (nth 0 point5))
                               (+ (- (* ds 50) 50)
                                  (nth 1 point5)
                               )
                         )
            )
            (setq point7 (list (+ 50 (nth 0 point6)) (nth 1 point6)))
            (setq point8
                     (list (nth 0 point7) (- (nth 1 point7) (- (* ds 50) 50)))
            )
            (setq point9 (list (nth 0 point8) (- (nth 1 point8) 50)))
            (command "pline"  point1   "W"        "0"         ""
                     point2   point3   point4        "arc"         point5
                     "angle"  "-90"    point6        "line"         point7
                     point8   point9   ""
                    )
            (setq door (ssget "L"))
            (command "rectangle" point2 point4)
            (ssadd (entlast) door)
            (command "rectangle" point6 point8)
            (ssadd (entlast) door)
        )
    )

    ;;编辑选项
    (initget 1 "Rotate Mirror Quit")
    (setq input (getkword "Rotate\\Mirror\\Quit:"))
    (while (or (= input "Rotate") (= input "Mirror"))
        (cond
            ((= input "Rotate")
             (command "rotate" door "" point1 pause)
            )
            ((= input "Mirror")
             (command "mirror" door "" point1 pause "y")
            )
        )
        (initget "Rotate Mirror Quit")
        (setq input (getkword "Rotate\\Mirror\\Quit:"))
    )
    (setvar "osmode" 33)
    (princ)
)
[/PHP]
另外:
1.尺寸选项最好设置一个默认选项,以方便交互;编辑选项亦是如此。
2.在计算点位坐标时,使用polar函数较好。
3.门窗桌椅之类,利用动态块插入的方法创建,更利于后续编辑修改。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-1 13:13:02 | 显示全部楼层
谢谢楼上的朋友,问题已解决
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 2个

财富等级: 恭喜发财

发表于 2007-3-1 13:54:36 | 显示全部楼层
试一试这个怎样?
[PHP]
(defun c:d (/ ds point1        point2 point3 point4 point5 point6 point7 point8
            point9)
    (setvar "CMDECHO" 0)
    (command "-osnap" "INT")
    (setq point1  (getpoint "点取第一点:")
          point11 (getpoint point1 "点取第二点:")
          ds          (/ (distance point1 point11) 100.0)
    )

    ;;判断部分
    (if        (<= ds 110)
        ;; Draw all size door
        (progn
            (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
            (setq
                point3 (list (nth 0 point1)
                             (+ (* ds 100) (nth 1 point1))
                       )
            )
            (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
            (setq point5 (list (+ (- (* ds 100) 50) (nth 0 point4))
                               (- (nth 1 point4) (- (* ds 100) 50))
                         )
            )
            (setq point6 (list (nth 0 point5) (- (nth 1 point5) 50)))
            (command "pline"  point1   "W"        "0"         ""
                     point2   point3   point4        "arc"         point5
                     "line"   point6   ""
                    )
            (setq door (ssget "L"))
            (command "rectangle" point2 point4)
            (ssadd (entlast) door)
        )
        ;; Draw all size double door
        (progn
            (setq point2 (list (nth 0 point1) (+ 50 (nth 1 point1))))
            (setq point3 (list (nth 0 point1)
                               (+ (* ds 50) (nth 1 point1))
                         )
            )
            (setq point4 (list (+ 50 (nth 0 point3)) (nth 1 point3)))
            (setq point5 (list (+ (- (* ds 50) 50) (nth 0 point4))
                               (- (nth 1 point4)
                                  (- (* ds 50) 50)
                               )
                         )
            )
            (setq point6 (list (+ (- (* ds 50) 50) (nth 0 point5))
                               (+ (- (* ds 50) 50)
                                  (nth 1 point5)
                               )
                         )
            )
            (setq point7 (list (+ 50 (nth 0 point6)) (nth 1 point6)))
            (setq point8
                     (list (nth 0 point7) (- (nth 1 point7) (- (* ds 50) 50)))
            )
            (setq point9 (list (nth 0 point8) (- (nth 1 point8) 50)))
            (command "pline"  point1   "W"        "0"         ""
                     point2   point3   point4        "arc"         point5
                     "angle"  "-90"    point6        "line"         point7
                     point8   point9   ""
                    )
            (setq door (ssget "L"))
            (command "rectangle" point2 point4)
            (ssadd (entlast) door)
            (command "rectangle" point6 point8)
            (ssadd (entlast) door)
        )
    )

    ;;处理选项
    (command "rotate" door "" point1 point11)
    (princ "\n宽度:")
    (princ ds)
    (initget "Yes No")
    (if        (= "Yes" (getkword "\n是否镜像?[是(Y)/否(N)] <N>:"))
        (command "mirror" door "" point1 point11 "y")
    )
    (setvar "osmode" 33)
    (princ)
)
[/PHP]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-1 14:31:36 | 显示全部楼层
非常好,不愧为高手
有点小问题,当在画门的位置有其它线段时,程序在画门时会出现错误,比如门的开启线弧度出现错误,可能是程序捕获了其它线段的点
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 2个

财富等级: 恭喜发财

发表于 2007-3-1 15:55:14 | 显示全部楼层
通过控制捕捉设置可以解决楼上的此类问题。改进后如下所示:
[PHP]
(defun c:d (/ ds point1        point2 point3 point4 point5 point6 point7 point8
            point9)
    ;;保存系统变量设置
    (setq old_OS  (getvar "OSMODE")
          old_CMD (getvar "CMDECHO")
    )
   
    (setvar "CMDECHO" 0)
    (command "-osnap" "INT")
    (if        (setq point1 (getpoint "点取第一点:"))
        (if (setq point11 (getpoint point1 "点取第二点:"))
            (progn
                (setq ds (/ (distance point1 point11) 100.0)
                )
                ;;判断部分
                (setvar "OSMODE" 0)
                (if (<= ds 110)
                    ;; Draw all size door
                    (progn
                        (setq point2 (list (nth 0 point1)
                                           (+ 50 (nth 1 point1))
                                     )
                        )
                        (setq
                            point3 (list (nth 0 point1)
                                         (+ (* ds 100) (nth 1 point1))
                                   )
                        )
                        (setq point4 (list (+ 50 (nth 0 point3))
                                           (nth 1 point3)
                                     )
                        )
                        (setq point5 (list (+ (- (* ds 100) 50)
                                              (nth 0 point4)
                                           )
                                           (- (nth 1 point4)
                                              (- (* ds 100) 50)
                                           )
                                     )
                        )
                        (setq point6 (list (nth 0 point5)
                                           (- (nth 1 point5) 50)
                                     )
                        )
                        (command "pline"  point1   "W"            "0"
                                 ""          point2   point3   point4
                                 "arc"          point5   "line"   point6
                                 ""
                                )
                        (setq door (ssget "L"))
                        (command "rectangle" point2 point4)
                        (ssadd (entlast) door)
                    )
                    ;; Draw all size double door
                    (progn
                        (setq point2 (list (nth 0 point1)
                                           (+ 50 (nth 1 point1))
                                     )
                        )
                        (setq
                            point3 (list (nth 0 point1)
                                         (+ (* ds 50) (nth 1 point1))
                                   )
                        )
                        (setq point4 (list (+ 50 (nth 0 point3))
                                           (nth 1 point3)
                                     )
                        )
                        (setq point5 (list (+ (- (* ds 50) 50)
                                              (nth 0 point4)
                                           )
                                           (- (nth 1 point4)
                                              (- (* ds 50) 50)
                                           )
                                     )
                        )
                        (setq point6 (list (+ (- (* ds 50) 50)
                                              (nth 0 point5)
                                           )
                                           (+ (- (* ds 50) 50)
                                              (nth 1 point5)
                                           )
                                     )
                        )
                        (setq point7 (list (+ 50 (nth 0 point6))
                                           (nth 1 point6)
                                     )
                        )
                        (setq point8
                                 (list (nth 0 point7)
                                       (- (nth 1 point7) (- (* ds 50) 50))
                                 )
                        )
                        (setq point9 (list (nth 0 point8)
                                           (- (nth 1 point8) 50)
                                     )
                        )
                        (command "pline"  point1   "W"            "0"
                                 ""          point2   point3   point4
                                 "arc"          point5   "angle"  "-90"
                                 point6          "line"   point7   point8
                                 point9          ""
                                )
                        (setq door (ssget "L"))
                        (command "rectangle" point2 point4)
                        (ssadd (entlast) door)
                        (command "rectangle" point6 point8)
                        (ssadd (entlast) door)
                    )
                )

                ;;处理选项
                (command "rotate" door "" point1 point11)
                (princ "\n宽度:")
                (princ ds)
                (initget "Yes No")
                (if (= "Yes"
                       (getkword "\n是否镜像?[是(Y)/否(N)] <N>:")
                    )
                    (command "mirror" door "" point1 point11 "y")
                )
                (princ "\n成功完成!")
            )
        )
    )
    ;;恢复系统变量设置
    (setvar "CMDECHO" old_CMD)
    (setvar "OSMODE" old_OS)
    (princ)
)
[/PHP]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2007-3-3 22:13:39 | 显示全部楼层
刚开始学,还不是看的很明白。。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 11:19 , Processed in 0.263810 second(s), 43 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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