- ;调用方法举例
- (defun C:HHH ()
- (setq pt1 (list 0 0))
- (setq pt2 (list 100 100))
- (YY004 pt1 pt2)
- )
- ;004函数功能:已知两对角点(方位无所谓,只要是对角点就行)画矩形
- (defun YY004 (004pt1 004pt2 / 004ptlist 004zxjd 004zsjd 004ysjd 004yxjd)
- (setvar "osmode" 0)
- ;-------以下为内嵌函数--------
- ;003函数功能:通过点表画多段线
- ;参数:点表
- (defun YY003 (003ptlst)
- (entmake
- (append
- (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")(cons 70 128)(cons 90 (length 003ptlst)))
- (mapcar '(lambda (pt) (cons 10 pt)) 003ptlst)
- )
- )
- )
- ;-------以下为内嵌函数--------
- (setq 004zxjd (list (min (car 004pt1) (car 004pt2)) (min (cadr 004pt1) (cadr 004pt2)))) ;左下角点
- (setq 004zsjd (list (min (car 004pt1) (car 004pt2)) (max (cadr 004pt1) (cadr 004pt2)))) ;左上角点
- (setq 004ysjd (list (max (car 004pt1) (car 004pt2)) (max (cadr 004pt1) (cadr 004pt2)))) ;右上角点
- (setq 004yxjd (list (max (car 004pt1) (car 004pt2)) (min (cadr 004pt1) (cadr 004pt2)))) ;右下角点
- (setq 004ptlist (LIST 004zxjd 004zsjd 004ysjd 004yxjd)) ;一定按照顺时针或逆时针方向存放,四个点即可,因为(cons 70 128)表示绘制封闭多段线
-
- ;(command "rectang" 004pt1 004pt2) ;COMMAND不要用,影响效率
- (YY003 004ptlist) ;调用内嵌函数画矩形
- (princ)
- )
|