Setvar 設定系統變數
This function sets an AutoCAD system variable to a given value and returns that value. The variable name must be in double quotes.( 要設定的系統變數 , 必須在“ “ 裡面 )
(setvar "blipmode" 0) returns 0
Will switch blipmode off. 1 would switch it on again. ( 0 是關閉 ,1 是打開 )
Doing arithmetic( 運算式 )
(+ 1 1) returns 2
(- 2 1) returns 1
(* 2 2) returns 4
(/ 2 1) returns 2
(1+ 1) returns 2 (Incremented, 加 1)
(1- 2) returns 1 (Decremented, 減 1)
Polar 求極座標點的座標值
This function returns the point at an angle (in radians) and distance from a point.
(polar pntl angl distl)
Inters 求兩直線上的四個點所形成的交點
Examines two lines and returns the point where they intersect even if they do not cross one another.
如果 pnt1 和 pnt2 所構成的直線與 pnt3 和 pnt4 所構成的直線未相交 , 而是在其延伸出去才相交的情況 , 則須在 pnt4 之後加上 nil , 才能求得虛擬的交點 .
(inters pntl pnt2 pnt3 pnt4) -> 僅能 回應實際的交點
(inters pntl pnt2 pnt3 pnt4 nil) -> 可 回實際的交點和應虛擬的交點
AutoCAD commands in AutoLISP
任何 AutoCAD command 都可以在 lisp 程式中使用 . 但是使用的順序必須正確 , 要和在 Auto CAD 中所執行的順序完全一樣才行 , 而且 command 的左右需用 Quotes ("") 括起來 . 如 :
(command "line" pnt1 pnt2 "") This will draw a line from pntl to pnt2 and the "" acts as a return to terminate your line command.
(graphscr) 切換到作圖模式的螢幕 .
(textscr) 切換到文字模式的螢幕 .