AutoLisp学习
Lisp简介:lisp是解释性的语言,是人工智能语言。lisp程序类型扩展名*.lsp
AutoLisp有好多函数,IDL也有好多函数。
;用来注释
(setq x (+ 5 9))回车,输入! x来查x的值。
前缀表示法(即谓词表示法),""在程序文件中表示回车。
阵列命令:array打开对话框,-array在命令行界面设置。阵列
Command命令下:输入appload命令打开如下对话框
1 ;编程实例CH17-2.lsp 2 (defun C:DRAW1() 3 (setq pt (getpoint "Enter circle center:\n")) 4 (setq r1 3 r2 6 r3 9 r4 1.5) 5 (setq ptt (polar Pt 0 (+ r3 2))) 6 ;设置点划线所在层、颜色和线型 7 (command "layer" "m" "center" "c" "3" "" "LT" "center" "" "") 8 (set_ltscale 2) 9 (command "LINE" pt ptt "") 10 (command "select" pt "") 11 (command "ARRAY" "p" "" "P" pt 8 360 "y") 12 (command "CIRCLE" pt r2) 13 ;设置轮廓线所在层、颜色和线型 14 (command "layer" "m" "轮廓线" "c" "1" "" "") 15 (command "CIRCLE" pt r1) 16 (command "CIRCLE" pt r3) 17 (command "CIRCLE" (polar pt 0 r2) r4) 18 ;设置文字所在层、颜色和线型 19 (command "ARRAY" "L" "" "P" PT 8 360 "N") 20 (command "layer" "m" "文本层" "c" "4" "" "") 21 (setq stpt (getpoint "输入文字书写位置:\n")) 22 (command "-STYLE" "standard" "simsun.ttf" "" "" "" "" "") 23 (command "text" "j" "mc" stpt "3.5" "0" "AutoLISP绘图实例" "") 24 ;计算图形挖去圆孔后的面积 25 (setq area (* PI (- (* r3 r3) (* r1 r1) (* 8 r4 r4)))) 26 ;在屏幕显示面积的计算结果 27 (print "area value:") 28 (prin1 area) 29 (print \n) 30 ;在屏幕上最大范围显示图形 31 (command "zoom" "e") 32 ) 33 (defun set_ltscale(scale) 34 (command "ltscale" scale) 35 )
调用: