明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1388|回复: 17

[提问] 知道所有边长自动生成图形高人给实现思路

[复制链接]
发表于 2019-4-24 19:06:24 | 显示全部楼层 |阅读模式
知道所有边长自动生成图形默认转角都是90度

本帖子中包含更多资源

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

x

点评

条件不充分,转角90度是一个面,就算限定了某平面,也还有两种可能性。  发表于 2019-4-25 10:20
伪命题!  发表于 2019-4-24 23:31
 楼主| 发表于 2019-4-25 21:13:18 | 显示全部楼层
  1. (defun c:tt ()
  2.   (setq p1 (getpoint "画图起始位置"))
  3.   (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:1水平右 2水平左 3直角右 4直角左"))
  5. (if (=1 jd 1)  (setq jd 0))
  6.   (if (=2 jd 2)  (setq jd 180))
  7.   (if (=3 jd 3)  (setq jd 90))
  8.   (if (=4 jd 4)  (setq jd -90))
  9.   (setq ang (* (/ jd 180) 3.1415926))
  10.   (setq p2 (polar p1 ang w))
  11.   (command "line" p1 p2 "")
  12.   (setq x 0)
  13.   (while (and (setq px p2)
  14.               (setq w (getdist "\n距离:"))
  15.               (setq jd (getdist "\n角度:"))
  16.               (setq jd (getdist "\n角度:1水平右 2水平左 3直角右 4直角左"))
  17. (if (=1 jd 1)  (setq jd 0))
  18.   (if (=2 jd 2)  (setq jd 180))
  19.   (if (=3 jd 3)  (setq jd 90))
  20.               (setq ang (* (/ jd 180) 3.1415926))
  21.               (setq p2 (polar px ang w))
  22.               (command "line" px p2 "")
  23.          )
  24.   )
  25. )
代码测试好像有点不行,没有找到问题
 楼主| 发表于 2019-4-24 19:44:08 | 显示全部楼层
youyou3810 发表于 2019-4-24 19:20
不能连续输入宽度及角度

  1. (defun c:tt ()
  2.   (setq p1 (getpoint "画图起始位置"))

  3.   (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:"))
  5.   (setq p2 (polar p1 jd w))
  6.   (command "line" p1 p2 "")
  7.   (function3 p2)
  8.   (defun function3 (px)
  9.     (setq w (getdist "\n距离:"))
  10.     (setq jd (getdist "\n角度:"))
  11.     (setq p2 (polar px jd w))
  12.     (command "line" px p2 "")
  13.     (function3 p2)
  14.   )
  15. )
代码有问题但是我觉得是这个思路
 楼主| 发表于 2019-4-24 20:23:08 | 显示全部楼层
  1. (defun c:tt ()
  2.   (setq p1 (getpoint "画图起始位置"))

  3.   (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:"))
  5.   (setq ang (* (/ jd 180) 3.1415926))
  6.   (setq p2 (polar p1 ang w))
  7.   (command "line" p1 p2 "")
  8.   (loop
  9.     (setq px p2)
  10.     (setq w (getdist "\n距离:"))
  11.     (setq jd (getdist "\n角度:"))
  12.     (setq ang (* (/ jd 180) 3.1415926))
  13.     (setq p2 (polar px ang w))
  14.     (command "line" px p2 "")
  15.     )
  16. )

现在循环出现了问题,看看怎么处理这个循环
 楼主| 发表于 2019-4-24 19:20:40 | 显示全部楼层
本帖最后由 youyou3810 于 2019-4-24 19:24 编辑

  1. (defun c:tt ()
  2.     (setq p1(getpoint"画图起始位置"))
  3.    (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:"))
  5. (setq p2(polar p1 jd w))
  6. (command "line" p1 p2 "")

  7. )


不能连续输入宽度及角度
 楼主| 发表于 2019-4-24 19:59:30 | 显示全部楼层
  1. (defun c:tt ()
  2.   (setq p1 (getpoint "画图起始位置"))

  3.   (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:"))
  5.   (setq p2 (polar p1 jd w))
  6.   (command "line" p1 p2 "")
  7.   (loop
  8. (setq px(p2))
  9.     (setq w (getdist "\n距离:"))
  10.     (setq jd (getdist "\n角度:"))
  11.     (setq p2 (polar px jd w))
  12.     (command "line" px p2 "")
  13. )


(setq px(p2)) 这个赋值不成功,看看这个怎么赋值
 楼主| 发表于 2019-4-24 22:19:28 | 显示全部楼层
  1. (defun c:tt ()
  2.   (setq p1 (getpoint "画图起始位置"))

  3.   (setq w (getdist "\n距离:"))
  4.   (setq jd (getdist "\n角度:"))
  5.   (setq ang (* (/ jd 180) 3.1415926))
  6.   (setq p2 (polar p1 ang w))
  7.   (command "line" p1 p2 "")
  8.   (setq x 0)
  9. (while (and
  10.     (setq px p2)
  11.     (setq w (getdist "\n距离:"))
  12.     (setq jd (getdist "\n角度:"))
  13.     (setq ang (* (/ jd 180) 3.1415926))
  14.     (setq p2 (polar px ang w))
  15.     (command "line" px p2 "")
  16.     ))
  17. )

大功告成
发表于 2019-4-24 23:03:18 来自手机 | 显示全部楼层
角度如何判断
 楼主| 发表于 2019-4-25 00:31:05 | 显示全部楼层
目前 就是自己输入角度
发表于 2019-4-25 08:53:20 | 显示全部楼层
如果转角都是90度,那就不用输入角度值。
发表于 2019-4-25 08:55:55 | 显示全部楼层
youyou3810 发表于 2019-4-24 19:59
(setq px(p2)) 这个赋值不成功,看看这个怎么赋值

试试(setq px (list (car p2) (cadr p2)))
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-18 20:47 , Processed in 0.215801 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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