CAD二次开发技术 命令符集合

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

;;;算术运算函数

(max 20.0 30.0 0.0)

(sqrt 16)

(expt 3 3)

;;;三角函数

(sin (/ pi 6))

;;;取整函数

(fix (/ pi 2))

;;;赋值函数

(setq aa (/ pi 2))

;;;quote应用

(setq aa(quote (- 2 1) ))

(setq aa ' (- 2 1) )

;;;自定义函数defun

(defun dtr ()

(setq a 40)

(setq b 40)

)

(defun sqrab (a b )

(setq c (+ (* a a)(* b b)))

(sqrt c)

)

;;;定义一个把度转换成弧度的函数(defun dtr (a)

(* a (/ pi 180.0))

)

;;;求45度的正弦值

(defun qsin ()

(sin (dtr 45))

)

;;;提取点(20.0 30.0 0.0)的X、Y、Z坐标(setq aa (list 20.0 30.0 0.0))

(car aa)

(cdr aa)

(cadr aa)

(caddr aa)

;;;提取表中第n个元素:

(setq bb '("大" "家" "好"))

(nth 0 bb)

(nth 1 bb)

(nth 2 bb)

;;;用append构造表

(setq aa (list 20.0 30.0 0.0))

(setq bb (list aa "AA"))

(setq ee (append aa bb))

;;;用cons构造坐标

(setq aa (list 20.0 30.0 0.0))

(setq bb (list 500.0 600.0 0.0))

(command "line" aa bb "")

(setq cc (cons 300.0 (cdr bb)))

(command "line" aa cc "")

;;;用cons构造点对

(setq aa (cons 'a "aaa"))

;;;reverse 应用

(setq aa (list 30.0 20.0 10.0))

(setq bb (REVERSE aa))

;;;assoc 应用

(setq aa (list '(a . rest) '(pt 30.0 20.0 10.0) '("O" 90)))

(setq bb (assoc "O" aa))

(setq cc (assoc 'pt aa))

;;;subst 应用

(setq aa (list '(a . rest) '(pt 30.0 20.0 10.0) '("O" 90)))

(setq bb (assoc "O" aa))

(setq cc (subst '(pt 80.0 60.0 40.0) '(pt 30.0 20.0 10.0) aa)) ;;;foreach应用

(foreach cir '((3 2 1) (4 4.5 0.5) (7 5 2))

(setq Ce (list (car cir) (cadr cir)))

(setq r (caddr cir))

(command "circle" Ce r)

)

;;;mapcar应用

(mapcar 'abs '(-2 -4 4.5 -0.5) )

;最高成绩

(setq xlcjb '("小李" 92 85 80 ))

(setq xzcjb '("小张" 81 90 88 ))

(setq xwcjb '("小王" 90 85 90 ))

(setq xl (nth 0 xlcjb) xlyw (nth 0 xlcjb)

xlsx (nth 0 xlcjb) xlwy (nth 0 xlcjb))

(setq ywjgcj (max xlyw xzyw xwyw));语文最高成绩

(setq sxjgcj (max xlsx xzsx xwsx));数学最高成绩

(setq wyjgcj (max xlwy xzwy xwwy));外语最高成绩;;;eval应用

(setq a 12)

(setq b a)

(eval b)

(setq a '(abs -22))

(setq b a)

(eval b)

;;;get类函数应用

(defun dcir ()

(setq pc (getpoint"\n圆心位置:"))

(setq r (getreal "\n圆半径:"))

(command "circle" pc r)

)

(defun xjgz ()

(setq pc (getpoint"\n写字位置:"))

(setq r (getstring "\n写的内容:"))

(command "text" pc 30 0 r)

;;"开心每一天!" "技术条件"

;;;polar函数应用

(defun hjx ();

(setq pt (getpoint"\n起点位置:"))

(setq l (getreal "\n矩形长:"))

(setq h (getreal "\n矩形高:"))

(setq pt1 (polar pt 0 l))

(setq pt2 (polar pt1 (/ pi 2) h))

(setq pt3 (polar pt2 pi l))

(command "line" pt pt1 pt2 pt3 pt "")

)

;;;getpoint,angle,distance,polar,command函数综合运用

(defun hjx1 ()

(setq pt (getpoint"\n起点位置:"))

(setq ptt (getpoint"\n绘制方向:" pt))

(command "line" pt ptt "")

(setq jxang (angle pt ptt))

(setq jxdis (distance pt ptt))

(setq pt1 (polar pt (+ jxang 0) (/ jxdis 2)))

(setq pt1 (polar pt1 (+ jxang (/ pi 2)) 50))

(setq pt2 (polar pt1 (+ jxang (/ pi 2)) 80))

(setq pt3 (polar pt1 (+ jxang (/ pi 4)) 60))

(setq pt4 (polar pt1 (+ jxang (* 3(/ pi 4))) 60))

(command "circle" pt1 50)

(command "circle" pt2 30)

(command "circle" pt3 10)

(command "circle" pt4 10)

)

(defun hjx11 ()

(command "erase" "all" "")

(setq pt (getpoint"\n起点位置:"))

(setq ptt (getpoint"\n绘制方向:" pt))

(command "line" pt ptt "")(setq ss2 (ssget "L"))

(setq jxang (angle pt ptt))

(setq jxdis (distance pt ptt))

相关文档
最新文档