Re: [問題] Autolisp

看板Cad_Cae作者 (滿23篇了...)時間15年前 (2009/06/04 22:41), 編輯推噓3(304)
留言7則, 3人參與, 最新討論串4/4 (看更多)
※ 引述《jaifei (這樣子阿...)》之銘言: : 嗯嗯.我知道CAD原本就有AREA的計算功能 : 但是計算的是最後的總面積 : 而我需要的是連計算過程中的計算式OD都要寫出來 下面是算三角形面積的程式,有附列式功能,隨便啦 (defun c:AreaFormula() (prompt "\nFormula of a triangle area:") (setq pt1 (getpoint "1st point:")) (setq pt2 (getpoint "2nd point:")) (setq pt3 (getpoint "3rd point:")) ;(command "ucs" "m" pt1) (setq L1 (distance pt1 pt2)) (setq L2 (distance pt1 pt3)) (setq ang1(angle pt1 pt2)) (setq ang2(angle pt1 pt3)) (setq h (abs(*(sin(- ang2 ang1))L2))) (setq area(*(*L1 h)0.5)) (setq str (strcat "\n(Bottom " (rtos L1) ")*(High " (rtos h) ")/2=(Area " (rtos area) ")" ) ) (command "text" pt1 (/ h 10)(*(/ ang1 pi)180)str) (princ str) (princ) ) sorry 沒有 debug 好就丟出來 紅字部份為修正 1. (command "ucs" "m" pt1) 多此一舉 2. abs 是為了順鐘向取點得負值 text字高就會出錯 3. (- ang2 ang1) 忘了減ang1是致命錯 若三角形底非水平則出錯 4. /2 漏寫 謝謝 camelot1123 5. (*(/ ang1 pi)180) 忘了徑度轉角度 6. (princ str) 謝謝 Egriawei -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.169.206.137 ※ 編輯: suny999 來自: 118.169.206.137 (06/04 22:47)

06/04 22:59, , 1F
妳的最後text列式只有底乘高沒有除已2 @@"
06/04 22:59, 1F

06/05 01:05, , 2F
大大大感恩阿!!!!
06/05 01:05, 2F

06/05 01:16, , 3F
但是好像....有問題...到了輸入文字的時候就也沒列出來
06/05 01:16, 3F

06/06 13:40, , 4F
osnap記得關掉,另外也可以試試海龍公式
06/06 13:40, 4F

06/06 13:42, , 5F
最後那個也可用pinrc就好,不用特地弄個text
06/06 13:42, 5F

06/06 13:42, , 6F
princ
06/06 13:42, 6F

06/06 13:43, , 7F
這程式應該沒什麼問題(y)
06/06 13:43, 7F
※ 編輯: suny999 來自: 118.169.192.153 (06/06 20:23)
文章代碼(AID): #1A9zqrWL (Cad_Cae)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):
問題
文章代碼(AID): #1A9zqrWL (Cad_Cae)