作者sjgau (sjgau)
看板Cad_Cae
標題Re: [問題] autolisp 畫鋸齒狀
時間Sat May 5 07:41:10 2012
幫你改好
測試 OK
請提供你的 測試意見
麻煩 幫我 案個讚
http://www.csie.ntu.edu.tw/train/teacher_display.php?num=18
; file: NG0713.LSP
(defun c:gear( / )
(setq p1 (getpoint "\n get P1: "))
(setq p2 (getpoint "\n get P2: "))
(setq ni (getint "\n ni= "))
(setq ni (- ni 1))
(setq x1 (car p1) y1 (cadr p1))
(setq x2 (car p2) y2 (cadr p2))
(setq dx (- x2 x1) dy (- y2 y1))
(setq x3 (+ x1 dx) y3 y1
p3 (list x3 y3))
(command "pline" p1 p2 p3)
(repeat ni
(progn
(setq x1 x3 y1 y3
p1 (list x1 y1)
x2 (+ x1 dx)
p2 (list x2 y2)
x3 x2 y3 y1
p3 (list x3 y3)
)
(command p2 p3)
)
)
(command "")
(princ)
); end of gear()
(princ "\n do the GEAR \n")
(princ)
; end of file
※ 引述《skyconquer (梅郭曲)》之銘言:
: 大家好,我寫了一個簡單的autolisp程式想畫一個像是螺旋彈簧側面圖的鋸齒狀線圖,
: 以下是我的程式碼:
: (defun c:test5 (/ p1 p2 dist ni dist2)
: (setq
: p1 (getpoint "\n input the first point : ")
: p2 (getpoint "\n input the seconf point : ")
: p3 (list (car p2) (cadr p1))
: dist (distance p1 p3)
: ni (getint "\ninput the times of drawing : ")
: dist2 (* 2.0 dist)
: ) ; end setq1
: (command "pline" p1 p2 p3)
: (repreat ni
: (setq
: p1 (polar p1 0.0 dist2)
: p2 (polar p2 0.0 dist2)
: p3 (polar p3 0.0 dist2)
: )
: (command p1)
: ) ; end of repeat
: (command "")
: ) ;end of program
: 現在遇到的問題是:不管我ni輸入多少,圖形就是只會畫一次,就是只畫出一個鋸齒
: 的意思。
: 不太知道這樣的寫法有哪裡不行,想請教各位高手,謝謝。
--
e-mail:
[email protected]
我的課程介紹網頁:
http://www.csie.ntu.edu.tw/train/teacher_display.php?num=18
AutoCAD 台灣地區菁英講師獲選
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.233.188
1F:→ sjgau:是否正確?是否有達到目的?請回報一下!感恩 05/05 21:50
2F:推 skyconquer:用推文回報可以嗎?有達到目的,謝謝!! 05/13 14:47