本帖最后由 x_s_s_1 于 2019-12-21 21:15 编辑
试试- ;;;默认前提,当前标注样式为需要的标注样式
- ;;;默认前提,图层列表中有图层6
- (defun c:test (/ sc h d oldos oldla ss lst n obj minx miny maxx maxy pt1
- pt2 pt3)
- (setq sc (getvar "dimscale"))
- (setq h (getvar "dimtxt"))
- (setq d (getvar "dimgap"))
- (setq oldos (getvar "osmode"))
- (setq oldla (getvar "clayer"))
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (setvar "clayer" "6")
- (prompt "\n选择需标注的门窗:")
- (setq ss (ssget))
- (repeat (setq n (sslength ss))
- (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
- (vla-getboundingbox obj 'x 'y)
- (setq lst (cons (vlax-safearray->list y)
- (cons (vlax-safearray->list x) lst)
- )
- )
- )
- (setq minx (car (vl-sort (mapcar 'car lst) '<))
- miny (car (vl-sort (mapcar 'cadr lst) '<))
- maxx (car (vl-sort (mapcar 'car lst) '>))
- maxy (car (vl-sort (mapcar 'cadr lst) '>))
- )
- (setq pt1 (list minx miny))
- (setq pt2 (list maxx miny))
- (setq pt3 (list maxx maxy))
- (command "dimlinear"
- pt1
- pt2
- (polar pt1 (+ (* -0.5 pi) (angle pt1 pt2)) (* sc (+ d h h)))
- )
- (command "dimlinear"
- pt2
- pt3
- (polar pt2 (+ (* -0.5 pi) (angle pt2 pt3)) (* sc (+ d h h)))
- )
- (setvar "osmode" oldos)
- (setvar "clayer" oldla)
- (setvar "cmdecho" 1)
- (princ)
- )
|