cxs259 发表于 2010-5-20 21:43:00

<p>测试成功,感谢古大侠!</p>

cxs259 发表于 2010-5-20 22:08:00

本程序若改为三线方便吗?这样画角钢投影线就方便多了

gufeng 发表于 2010-5-21 09:32:00

;;; 执行命令3L
(defun c:3L ()
(setq wwdy (getint "\n请输入宽度:"))
(if (= wwdy nil)
    (setq wwdy 240)
)
(prompt (strcat "\nnow dline width is: " (rtos wwdy 2 2)))
(setq dis1 (* 0.5 wwdy))
;;;(setq dis2 (getint (strcat "\n输入离两边线的距离,不能大于"
;;;      (rtos (* 0.5 wwdy) 2 0)
;;;      ":<"
;;;      (rtos (* 0.5 wwdy) 2 0)
;;;      ">"
;;;       )
;;;      )
;;;);_如果需要画5线请去掉这行注释
;;;(if dis2
;;;    (setq dis2 (- (* 0.5 wwdy) dis2))
;;;    (setq dis2 (* 0.25 wwdy))
;;;);_如果需要画5线请去掉这行注释
(setq pt1 (getpoint "\n enter start point:"))
(setq pt2 (getpoint pt1 "\n enter next point:"))
(setq ag1 (angle pt1 pt2))
(setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
(setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
(setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
(setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
(setq pt1d (polar pt1 (- ag1 1.5708) dis1))
(setq pt11d (polar pt1 (- ag1 1.5708) dis2))
(setq pt2d (polar pt2 (- ag1 1.5708) dis1))
(setq pt22d (polar pt2 (- ag1 1.5708) dis2))
(command "pline" "non" pt1 "non" pt2 "")
(command "pline" "non" pt1u "non" pt2u "")
;;;(command "pline" "non" pt11u "non" pt22u "");_如果需要画5线请去掉这行注释
(command "pline" "non" pt1d "non" pt2d "")
;;;(command "pline" "non" pt11d "non" pt22d "");_如果需要画5线请去掉这行注释
(repeat 100
    (setq pt1 pt2)
    (if (and pt1 pt2)
      (progn
(setq pt2 (getpoint pt1 "\n enter next point:"))
(if pt2
   (progn
   (setq dis1 (* 0.5 wwdy))
   (setq ag1 (angle pt1 pt2))
   (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
   (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
   (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
   (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
   (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
   (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
   (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
   (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
   (command "pline" "non" pt1 "non" pt2 "")
   (command "pline" "non" pt1u "non" pt2u "")
;;;   (command "pline" "non" pt11u "non" pt22u "");_如果需要画5线去掉这行注释
   (command "pline" "non" pt1d "non" pt2d "")
;;;   (command "pline" "non" pt11d "non" pt22d "");_如果需要画5线去掉这行注释
   )
)
      )
    )
)
(princ)
)

cxs259 发表于 2010-5-21 12:11:00

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

gufeng 发表于 2010-5-22 10:18:00


(defun c:3L ()
(setq wwdy (getint "\n请输入宽度:"))
(if (= wwdy nil)
    (setq wwdy 240)
)
(prompt (strcat "\nnow dline width is: " (rtos wwdy 2 2)))
(setq dis1 (* 0.5 wwdy))
(setq dis2 (getint (strcat "\n输入距离,不能大于"
      (rtos wwdy 2 0)
      ":<"
      (rtos (* 0.5 wwdy) 2 0)
      ">"
       )
      )
)
(if dis2
    (setq dis2 (- (* 0.5 wwdy) dis2))
    (setq dis2 0)
)
(setq pt1 (getpoint "\n enter start point:"))
(setq pt2 (getpoint pt1 "\n enter next point:"))
(setq ag1 (angle pt1 pt2))
(setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
(setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
(setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
(setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
(setq pt1d (polar pt1 (- ag1 1.5708) dis1))
(setq pt11d (polar pt1 (- ag1 1.5708) dis2))
(setq pt2d (polar pt2 (- ag1 1.5708) dis1))
(setq pt22d (polar pt2 (- ag1 1.5708) dis2))
(command "pline" "non" pt1u "non" pt2u "")
(command "pline" "non" pt11u "non" pt22u "")
(command "pline" "non" pt1d "non" pt2d "")
(repeat 100
    (setq pt1 pt2)
    (if (and pt1 pt2)
      (progn
(setq pt2 (getpoint pt1 "\n enter next point:"))
(if pt2
   (progn
   (setq dis1 (* 0.5 wwdy))
   (setq ag1 (angle pt1 pt2))
   (setq pt1u (polar pt1 (+ ag1 1.5708) dis1))
   (setq pt11u (polar pt1 (+ ag1 1.5708) dis2))
   (setq pt2u (polar pt2 (+ ag1 1.5708) dis1))
   (setq pt22u (polar pt2 (+ ag1 1.5708) dis2))
   (setq pt1d (polar pt1 (- ag1 1.5708) dis1))
   (setq pt11d (polar pt1 (- ag1 1.5708) dis2))
   (setq pt2d (polar pt2 (- ag1 1.5708) dis1))
   (setq pt22d (polar pt2 (- ag1 1.5708) dis2))
   (command "pline" "non" pt1u "non" pt2u "")
   (command "pline" "non" pt11u "non" pt22u "")
   (command "pline" "non" pt1d "non" pt2d "")
   )
)
      )
    )
)
(princ)
)

cxs259 发表于 2010-5-22 12:15:00

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

cxs259 发表于 2010-5-31 15:56:00

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

gufeng 发表于 2010-6-1 15:01:00

<p>在3L与4L文件中 替换 getint 为 getreal 就可以了</p>
<p>&nbsp; 方法:用记事本打开文件,替换.</p>

cxs259 发表于 2010-6-1 15:17:00

<p>已替换,谢谢!</p>

bai2000 发表于 2013-1-6 22:18:01

能不能改线性????
页: 1 [2] 3
查看完整版本: 请教版主,能否调整下面的LISP,把双线改为四线,其中中间两条线可以按参数输入离两