直接从我的工具箱里。。。
- (defun c:SQ (/ foo p1 pt w h p2 ent)
- ;; Draw square polygon at specified height and width (with option to rotate)
- ;; Alan J. Thompson
- (defun foo (p) (list 10 (car p) (cadr p)))
- (if (and (setq p1 (getpoint "\nSpecify NorthWest corner of rectangle: "))
- (setq w (getdist "\nSpecify width: "))
- (setq h (cond ((getdist (strcat "\nSpecify height <" (rtos w) ">: ")))
- (w)
- )
- )
- )
- (progn
- (setq p2 (polar (setq pt (trans p1 1 0)) 0. w))
- (if (setq ent (entmakex
- (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")
- '(90 . 4) '(70 . 1)
- )
- (mapcar 'foo
- (list pt p2 (polar p2 (* 1.5 pi) h) (polar pt (* 1.5 pi) h))
- )
- )
- )
- )
- (command "_.rotate" ent "" "_non" p1 "_r" "_non" p1 "_non" (trans p2 0 1))
- )
- )
- )
- (princ)
- )
|