明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1273|回复: 2

[求助]帮忙改进

[复制链接]
发表于 2005-3-6 22:32:00 | 显示全部楼层 |阅读模式



功能是:生成简易房的程序。


谢谢

本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2005-3-7 20:42:00 | 显示全部楼层
应增加高度控制:
  1. ;;;生成简易房的程序
  2. (defun c:jyf ()
  3.    (setvar "osmode" 1)
  4.    (setq  ename (car (entsel "\n选择实体 : "))
  5.   no1     (ureal 1 "" "\n墙高" no1)
  6.    )
  7.    (mkla "jmd" 1)
  8.    (setq dy 0)
  9.    (if ename
  10.        (progn
  11.            (setq d   nil
  12.          lb (entget ename)
  13.          bh (cdr (assoc 70 lb))
  14.            )
  15.            (setq b (cdr (assoc 0 lb)))
  16.            (if (= b "POLYLINE")
  17.   (progn
  18.      (command "change" ename "" "p" "la" "jmd" "thickness"  NO1 "")
  19.      (setq sut (entnext ename))
  20.      (while (/= (cdr (assoc 0 (entget sut))) "SEQEND")
  21.          (setq pt   (cdr (assoc 10 (entget sut)))
  22.        x1   (nth 0 pt)
  23.        y1   (nth 1 pt)
  24.        z1   (list x1 y1)
  25.        d     (cons z1 d)
  26.        sut (entnext sut)
  27.          )
  28.      )        ;end while   
  29.      (setq dy (length d))
  30.      (if (= dy 4)
  31.          (progn
  32.              (setq xy1   (nth 0 d)
  33.            xy11 (nth 2 d)
  34.            a1   (angle xy1 xy11)
  35.              )
  36.              (if (> a1 3.14)
  37.     (setq a1 (- 7.85 a1))
  38.              )
  39.              (setq xy2   (nth 1 d)
  40.            xy12 (nth 3 d)
  41.            a2   (angle xy2 xy12)
  42.              )
  43.              (if (> a2 3.14)
  44.     (setq a2 (- 7.85 a2))
  45.              )
  46.              (setq xy3   (nth 2 d)
  47.            xy13 (nth 0 d)
  48.            a3   (angle xy3 xy13)
  49.              )
  50.              (if (> a3 3.14)
  51.     (setq a3 (- 7.85 a3))
  52.              )
  53.              (setq xy4   (nth 3 d)
  54.            xy14 (nth 1 d)
  55.            a4   (angle xy4 xy14)
  56.              )
  57.              (if (> a3 3.14)
  58.     (setq a3 (- 7.85 a3))
  59.              )
  60.              (setq minvale (min a1 a2 a3 a4))
  61.              (cond ((= minvale a1) (command "line" (nth 0 d) (nth 2 d)))
  62.            ((= minvale a2) (command "line" (nth 1 d) (nth 3 d)))
  63.            ((= minvale a3) (command "line" (nth 2 d) (nth 0 d)))
  64.            ((= minvale a4) (command "line" (nth 3 d) (nth 1 d)))
  65.              )
  66.              (command "")
  67.              (command "change"
  68.                  (entlast)
  69.                  ""
  70.                  "p"
  71.                  "la"
  72.                  "jmd"
  73.                  "thickness"
  74.                  no1
  75.                  ""
  76.              )
  77.          )
  78.      )
  79.      (if (/= dy 4)
  80.          (progn
  81.              (setq point1 (getpoint "\n第一点:"))
  82.              (setq point2 (getpoint "\n第二点:"))
  83.              (command "line" point1 point2 "")
  84.              (command "change"
  85.                  (entlast)
  86.                  ""
  87.                  "p"
  88.                  "la"
  89.                  "jmd"
  90.                  "thickness"
  91.                  no1
  92.                  ""
  93.              )
  94.          )
  95.      )
  96.   )
  97.            )
  98.            (if (or (= b "LINE") (= b "LWPOLYLINE"))
  99.   (alert "错: LINE or lwpolyline ")
  100.            )
  101.        )
  102.    )
  103. )
  104. (defun ureal (bit kwd msg def / inp)
  105.    (if def
  106.        (setq msg (strcat "\n" msg "<" (rtos def 2) ">: ")
  107.                    bit (* 2 (fix (/ bit 2)))
  108.        )
  109.        (setq msg (strcat "\n" msg ": "))
  110.    )
  111.    (initget bit kwd)
  112.    (setq inp (getreal msg))
  113.    (if inp inp def)
  114. )
  115. (defun mkla (name color)
  116.    (If (= (Tblsearch "layer" name) nil)
  117.        (Command "layer" "m" name "c" color name "")
  118.        (Command "layer" "t" name "s" name "c" color name "")
  119.    )
  120. )
发表于 2012-12-3 04:58:05 | 显示全部楼层
xyp1964前辈,测绘的简易房表示很简单,就是房屋边上中间加条对角线,不存在高度控制.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-4 03:40 , Processed in 0.198067 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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