明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: cxs259

请教版主,能否调整下面的LISP,把双线改为四线,其中中间两条线可以按参数输入离两

  [复制链接]
 楼主| 发表于 2010-5-20 21:43:00 | 显示全部楼层

测试成功,感谢古大侠!

 楼主| 发表于 2010-5-20 22:08:00 | 显示全部楼层
本程序若改为三线方便吗?这样画角钢投影线就方便多了
发表于 2010-5-21 09:32:00 | 显示全部楼层
  1. ;;; 执行命令3L
  2. (defun c:3L ()
  3.   (setq wwdy (getint "\n请输入宽度:"))
  4.   (if (= wwdy nil)
  5.     (setq wwdy 240)
  6.   )
  7.   (prompt (strcat "\n  now dline width is: " (rtos wwdy 2 2)))
  8.   (setq dis1 (* 0.5 wwdy))
  9. ;;;  (setq dis2 (getint (strcat "\n输入离两边线的距离,不能大于"
  10. ;;;        (rtos (* 0.5 wwdy) 2 0)
  11. ;;;        ":<"
  12. ;;;        (rtos (* 0.5 wwdy) 2 0)
  13. ;;;        ">"
  14. ;;;       )
  15. ;;;      )
  16. ;;;  );_如果需要画5线请去掉这行注释
  17. ;;;  (if dis2
  18. ;;;    (setq dis2 (- (* 0.5 wwdy) dis2))
  19. ;;;    (setq dis2 (* 0.25 wwdy))
  20. ;;;  );_如果需要画5线请去掉这行注释
  21.   (setq pt1 (getpoint "\n enter start point:"))
  22.   (setq pt2 (getpoint pt1 "\n enter next point:"))
  23.   (setq ag1 (angle pt1 pt2))
  24.   (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
  25.   (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
  26.   (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
  27.   (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
  28.   (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
  29.   (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
  30.   (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
  31.   (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
  32.   (command "pline" "non" pt1 "non" pt2 "")
  33.   (command "pline" "non" pt1u "non" pt2u "")
  34. ;;;  (command "pline" "non" pt11u "non" pt22u "");_如果需要画5线请去掉这行注释
  35.   (command "pline" "non" pt1d "non" pt2d "")
  36. ;;;  (command "pline" "non" pt11d "non" pt22d "");_如果需要画5线请去掉这行注释
  37.   (repeat 100
  38.     (setq pt1 pt2)
  39.     (if (and pt1 pt2)
  40.       (progn
  41. (setq pt2 (getpoint pt1 "\n enter next point:"))
  42. (if pt2
  43.    (progn
  44.      (setq dis1 (* 0.5 wwdy))
  45.      (setq ag1 (angle pt1 pt2))
  46.      (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
  47.      (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
  48.      (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
  49.      (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
  50.      (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
  51.      (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
  52.      (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
  53.      (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
  54.      (command "pline" "non" pt1 "non" pt2 "")
  55.      (command "pline" "non" pt1u "non" pt2u "")
  56. ;;;     (command "pline" "non" pt11u "non" pt22u "");_如果需要画5线去掉这行注释
  57.      (command "pline" "non" pt1d "non" pt2d "")
  58. ;;;     (command "pline" "non" pt11d "non" pt22d "");_如果需要画5线去掉这行注释
  59.    )
  60. )
  61.       )
  62.     )
  63.   )
  64.   (princ)
  65. )

本帖子中包含更多资源

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

x
 楼主| 发表于 2010-5-21 12:11:00 | 显示全部楼层

请问画三线时,为什么总是居中,能否像四线一样可以输入参数,得到离边线的距离?

发表于 2010-5-22 10:18:00 | 显示全部楼层
  1. (defun c:3L ()
  2.   (setq wwdy (getint "\n请输入宽度:"))
  3.   (if (= wwdy nil)
  4.     (setq wwdy 240)
  5.   )
  6.   (prompt (strcat "\n  now dline width is: " (rtos wwdy 2 2)))
  7.   (setq dis1 (* 0.5 wwdy))
  8.   (setq dis2 (getint (strcat "\n输入距离,不能大于"
  9.         (rtos wwdy 2 0)
  10.         ":<"
  11.         (rtos (* 0.5 wwdy) 2 0)
  12.         ">"
  13.        )
  14.       )
  15.   )
  16.   (if dis2
  17.     (setq dis2 (- (* 0.5 wwdy) dis2))
  18.     (setq dis2 0)
  19.   )
  20.   (setq pt1 (getpoint "\n enter start point:"))
  21.   (setq pt2 (getpoint pt1 "\n enter next point:"))
  22.   (setq ag1 (angle pt1 pt2))
  23.   (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
  24.   (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
  25.   (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
  26.   (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
  27.   (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
  28.   (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
  29.   (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
  30.   (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
  31.   (command "pline" "non" pt1u "non" pt2u "")
  32.   (command "pline" "non" pt11u "non" pt22u "")
  33.   (command "pline" "non" pt1d "non" pt2d "")
  34.   (repeat 100
  35.     (setq pt1 pt2)
  36.     (if (and pt1 pt2)
  37.       (progn
  38. (setq pt2 (getpoint pt1 "\n enter next point:"))
  39. (if pt2
  40.    (progn
  41.      (setq dis1 (* 0.5 wwdy))
  42.      (setq ag1 (angle pt1 pt2))
  43.      (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
  44.      (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
  45.      (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
  46.      (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
  47.      (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
  48.      (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
  49.      (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
  50.      (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
  51.      (command "pline" "non" pt1u "non" pt2u "")
  52.      (command "pline" "non" pt11u "non" pt22u "")
  53.      (command "pline" "non" pt1d "non" pt2d "")
  54.    )
  55. )
  56.       )
  57.     )
  58.   )
  59.   (princ)
  60. )

本帖子中包含更多资源

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

x
 楼主| 发表于 2010-5-22 12:15:00 | 显示全部楼层

再次感谢古大侠的热心解答,祝福好人平安、快乐!

 楼主| 发表于 2010-5-31 15:56:00 | 显示全部楼层

请教古大侠,在应用过程中,有些不是整数的厚度,如“输入离两边线的距离,不能大于20:<20>5.5
需要整数值.”上面的3L,4L程序可以修改吗?

 

发表于 2010-6-1 15:01:00 | 显示全部楼层

在3L与4L文件中 替换 getint 为 getreal 就可以了

  方法:用记事本打开文件,替换.

 楼主| 发表于 2010-6-1 15:17:00 | 显示全部楼层

已替换,谢谢!

发表于 2013-1-6 22:18:01 | 显示全部楼层
能不能改线性????
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-27 14:17 , Processed in 0.156293 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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