[心得] AutoCAD 物件鎖點之鬼打牆事件…

看板Cad_Cae (電腦輔助設計)作者 (Θ.Θ)時間16年前 (2009/10/02 21:34), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
仍在迷惑當中的新手一點小小心得: 這篇文章原本是要來求助的,不過字打著打著,想起高老師有句原本讓我 以為無關緊要的話…一個動作,問題解決了八成。故事是這樣的:一星期 前三小時的課讓人了解到在 acad 中使用 lisp、script 配合高階語言的 魅力,所以趕緊買了書回來看。可是才剛練習寫個簡單的中心線的程式, 馬上就遇到鬼打牆。有興趣往下看的板友,可以先載入程式試試看。原先 用意是想在點擊圓後可以畫出突出圓周2單位長的十字線: (defun c:cline(/ dat rad cpt len ept wpt spt npt) (setvar "cmdecho" 0) (setq dat (entget (car (entsel "\nSelect a circle to draw centerlines...")))) (setq rad (cdr (assoc 40 dat))) (setq cpt (cdr (assoc 10 dat))) (setq rad (+ rad 2)) ; ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄here is still in modifying by ph. (setq ept (polar cpt 0 rad)) (setq wpt (polar cpt pi rad)) (setq spt (polar cpt (* pi 1.5) rad)) (setq npt (polar cpt (* pi 0.5) rad)) (command "line" ept wpt "" "line" spt npt "") (prin1) ) 仔細檢查過一切ok,可是執行的時侯卻只看到圓心上一個光點,並且回應 訊息:「建立了長度為零的線」。我取消區域變數宣告,把每個變數值都 查過了,想破了頭還是找不出問題。更離奇的是若在命令列下: (command "line" '(0 0 0) ept) 或 (command "circle" wpt [任意值]) 原本以為會出現在 ept wpt spt npt位置的,變成跑到圓心位置上。最後 索性把底線那一行改成 (setq rad (* rad 1.4)) 居然就可以執行。 用加的不行、用乘的就可以,一點道理也沒有…。忽然想起 sjgau 說過: 「有很多錯誤都是因為物件鎖點使用不當造成的」看見我的物件鎖點果然 開著,半信半疑地按了F3……BINGO!!! 雖然現在還是不曉得為什麼選了 鎖中心點會產生這樣的結果、也不曉得為什麼用乘的就可以執行,不過就 問題本身而言算是解決了。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.196.149 ※ 編輯: phragmite 來自: 61.228.196.149 (10/02 22:00)
文章代碼(AID): #1AnW5-SL (Cad_Cae)
文章代碼(AID): #1AnW5-SL (Cad_Cae)