Auto Lisp 快速上手 - 003

  • Share this:

Input Commands 輸入指令 -( 由 user 輸入來取得資訊的指令 )

getpoint - 須要 user 在螢幕上選取一點以取得點資料 .

getint – 取得整數值 Integer, 例如 : 1

getreal - 取得實數值 real number , 例如 : 10.00

getcorner – 由螢幕上的第一點為基礎 , 選取第二點 , 以便畫出矩形 .

getstring - 取得文字字串 .

getdist – 可由螢幕選取 , 或由鍵盤輸入 , 以取得距離值 .

getangle - 取得角度值 , 回傳值為弳度值 ( radians ).

getkword – 從 user 輸入 , 取得關鍵字 ( keyword ).

getvar - 取得 AutoCAD 系統變數 ( system variable ) 的值 .

initget – 建立各種選項的規範 , 須放在 GET XXX function 之前 .

getorient - 類似 GETANGLE 指令 , 但受到 0 度基準和方向的影響很大 . 它總是以東方為基準 0 度的絶對角度值回應 .

Input Command Examples 輸入指令的範例

1. (getpoint "n Pick POINT on the screen:")

n - n 必須是小寫字母 ( lower case ), n 是跳到下一行 ( the next line ) 指令 .

你的提示語 prompt 必須寫在 " " (Quotes) 的中間 , 然後選取一點 , 回傳為點的座標值 .

2. (getint "Enter your age :") 輸入一整數值 , AutoLisp 會回應整數值 .

3. (getreal "nEnter a number:") 輸入 real number 如 10.51 , AutoLisp 回應 10.51.

4. (getcorner pntl "n Pick second point:") 由變數 pntl 取得矩形的對角點 .

5. (getstring 1 "What is the day today ?:") 由 user 取得字串 .

6. (getdist "nHow long is the line ?:") 由 選取兩點或輸入長度 , 以取得距離值 .

7. (getangle "nWhat is the angle ?:") 選取角度的兩點或輸入角度值 , 回應值為弳度 ( radians ).

8. (initget 1 "Yes No")

(getkword "nAre you going? ("Yes or NO):") Initget 將會控制隨後的 getxxx function, getkword 將只會接受一個字 . initget 設定成只接受輸入的字為 Yes 或 No.

9. (getvar "FILLETRAD") 將回應倒圓角 ( fillet ) 的半徑值 ( radius ). 如 : 0. 5

Initget Bits

1 Disallow null input 不允許空回應 , ( 未輸入 , 直接按 [enter])

2 Disallow zero values 不允許輸入 0 值

4 Disallow negative values 不允許負值

8 DO not check limits, even if LIMCHECK is on. 不檢查作圖的極限值 .

16 Return 3D points rather than 2D points. 回應 3D 點座標 .

32 Use dashed lines when drawing rubber band or box. (initget (+ 1 2 4)) (getint "nHow old are you?:") 設定為只接受大於 0 的整數 , 如 : 21

(getorient "nWhat is the angle?:") 選取角度的兩座標點或輸入角度值 , AutoLisp 將回傳以向東為 0 度座標系統的角度弳度值 .


Tags: