本帖最后由 kkq0305 于 2021-8-26 12:26 编辑
- (defun c:tt (/ tk tklst apt bpt ty sc obj)
- (vl-load-com)
- (prompt "选择图框:")
- (setq tk (ssget))
- (setq
- apt
- (car
- (mapcar '(lambda (x)
- (vla-GetBoundingBox
- (vlax-ename->vla-object x)
- 'minpt
- 'maxpt
- )
- (list (vlax-safearray->list minpt)
- (vlax-safearray->list maxpt)
- )
- )
- (vl-remove-if-not
- '(lambda (x) (= 1 (cdr (assoc 62 (entget x)))))
- (setq tklst (vl-remove-if-not
- '(lambda (x) (= 'ENAME (type x)))
- (apply 'append (ssnamex tk))
- )
- )
- )
- )
- )
- )
- (prompt "\n选择需要套图框的图形:")
- (while (setq ty (ssget))
- (setq
- bpt (apply 'append
- (mapcar '(lambda (x)
- (vla-GetBoundingBox
- (vlax-ename->vla-object x)
- 'minpt
- 'maxpt
- )
- (list (mapcar '*
- '(1.0 1.0)
- (vlax-safearray->list minpt)
- )
- (mapcar '*
- '(1.0 1.0)
- (vlax-safearray->list maxpt)
- )
- )
- )
- (vl-remove-if-not
- '(lambda (x) (= 'ENAME (type x)))
- (apply 'append (ssnamex ty))
- )
- )
- )
- )
- (setq bpt (list (mapcar '- (apply 'mapcar (cons 'min bpt)) '(5 5))
- (mapcar '+ (apply 'mapcar (cons 'max bpt)) '(5 5))
- )
- )
- (setq sc (apply 'max
- (mapcar '/
- (apply 'mapcar (cons '- (reverse bpt)))
- (apply 'mapcar (cons '- (reverse apt)))
- )
- )
- )
- (foreach n tklst
- (setq obj (vla-copy (vlax-ename->vla-object n)))
- (vla-move obj
- (vlax-3D-point
- (mapcar '* '(0.5 0.5) (apply 'mapcar (cons '+ apt)))
- )
- (vlax-3D-point
- (mapcar '* '(0.5 0.5) (apply 'mapcar (cons '+ bpt)))
- )
- )
- (vla-ScaleEntity
- obj
- (vlax-3D-point
- (mapcar '* '(0.5 0.5) (apply 'mapcar (cons '+ bpt)))
- )
- sc
- )
- )
- (prompt "\n选择需要套图框的图形或[空格(退出)]:")
- )
- (princ)
- )
;图框中间矩形框为红色,才能识别。 |