伊莉討論區
標題:
AUTO LISP幫忙debug
[打印本頁]
作者:
a4520343
時間:
2015-1-4 09:01 PM
標題:
AUTO LISP幫忙debug
各位大大幫幫我 想寫一個AutoCAD LISP
是希望她可以畫出梯子 可是不知道為何一直都有錯誤~
幫幫我看看是程式碼哪裡有問題~~
[attach]106277950[/attach]
<程式>
(defun c:ladder()
(setq pa (getpoint "請輸入左下角點:"))
(setq ww (getdist "\n 請輸入梯子的寬度:"))
(setq hh (getdist "\n 請輸入梯子的高度:"))
(setq n (getint "\n 請輸入梯子的階數:"))
(setq pb (polar pa (/ pi 2) hh))
(setq pc (polar pb 0 ww))
(setq pd (polar pa 0 ww))
(command "line" pa pb pc pd "")
(setq dw ww)
(setq dh (/ hh n))
(setq pp pa)
(repeat n
(setq p1 (polar pp (/ pi 2) dh))
(setq p2 (polar p1 0 dw))
(setq p3 (polar pp 0 dw))
(command "line" pp p1 p2 p3 "")
(setq pp p1)
)
(prin1)
(prompt "\n 《用lisp繪製梯子》")
(prin1)
)
作者:
chaoanne
時間:
2015-1-6 11:41 AM
你的鎖點要關掉,不然line指令會鎖到臨近點
增加一行指令(在第一行)
(command "onsap" "off" )
作者:
al2008
時間:
2015-1-6 08:55 PM
原程式修改下
請參考
(defun c:ladder()
(setq pa (getpoint "請輸入左下角點:"))
(setq ww (getdist "
請輸入梯子的寬度:"))
(setq hh (getdist "
請輸入梯子的高度:"))
(setq n (getint "
請輸入梯子的階數:"))
(setq pb (polar pa (/ pi 2) hh))
(setq pc (polar pb 0 ww))
(setq pd (polar pa 0 ww))
(command "line" pa pb "")
(command "line" pc pd "")
(setq dw ww)
(setq dh (/ hh n))
(setq pp pa)
(repeat n
(setq p1 (polar pp (/ pi 2) dh))
(setq p2 (polar p1 0 dw))
;;(setq p3 (polar pp 0 dw))
(command "line" p1 p2 "")
(setq pp p1)
)
(command "line" pa pd "")
(prompt "
《用lisp繪製梯子》")
(prin1)
)
補充內容 (2015-1-6 09:08 PM):
你寫(repeat n數量的第一點是重原點+dh開始畫,故最後一階會重覆,所以pa,pb,pc,pd須取消pb畫到pc,最後補階梯的底線,p3看起來多餘的
歡迎光臨 伊莉討論區 (http://741107.eyny.com/)
Powered by Discuz!