jiegousheng 发表于 2011-7-5 19:30 
各位大侠:如果想实现批量将已有矩形外扩一定距离,原矩形可以保留,但外扩后的矩形最好在另外一个图层上。 ... 
- (defun c:tt ()
- (if (setq
- dis
- (getreal
- (strcat "\n输入偏移距离<" (rtos (getvar "offsetdist")) ">:")
- )
- )
- (setvar "offsetdist" dis)
- (setq dis (getvar "offsetdist"))
- )
- (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
- (progn
- (setq k 0)
- (if (= (TBLOBJNAME "LAYER" "NEW-RECTANG") nil)
- (command "layer" "m" "NEW-RECTANG" "c" "3" "" "")
- )
- (repeat (sslength ss)
- (setq ent (ssname ss k))
- (setq pt_lst
- (mapcar
- 'cdr
- (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))
- )
- )
- (setq pt1 (nth 0 pt_lst)
- pt2 (nth 2 pt_lst)
- )
- (setq pt3 (polar pt2 (angle pt1 pt2) 1.))
- (command "offset" dis ent "non" pt3 "")
- (setq ent1 (entlast))
- (command "change" ent1 "" "p" "la" "NEW-RECTANG" "")
- (setq k (1+ k))
- )
- )
- )
- (princ)
- )
|