嗨,luctifo,
请阅读适用于我网站上所有代码的使用条款,并在使用我的代码的地方保留我的代码标题。
对于您的程序,只需按如下方式调用我的函数:
- (defun c:tblimits ( / box sel )
- (if (setq sel (ssget "_X" '((0 . "LINE") (8 . "_TB"))))
- (progn
- (setq box (LM:SSBoundingBox sel))
- (setvar 'limmin (mapcar '+ (car box) '(0 0)))
- (setvar 'limmax (mapcar '+ (cadr box) '(0 0)))
- )
- )
- (princ)
- )
- (vl-load-com) (princ)
- ;;--------------=={ SelectionSet BoundingBox }==--------------;;
- ;; ;;
- ;; Returns the lower-left and upper-right points of a ;;
- ;; rectangle bounding all objects in a supplied SelectionSet ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; ss - SelectionSet for which to return the BoundingBox ;;
- ;;------------------------------------------------------------;;
- ;; Returns: Point List decribing BoundingBox (in WCS) ;;
- ;;------------------------------------------------------------;;
- (defun LM:SSBoundingBox ( ss / i l1 l2 ll ur )
- (repeat (setq i (sslength ss))
- (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'll 'ur)
- (setq l1 (cons (vlax-safearray->list ll) l1)
- l2 (cons (vlax-safearray->list ur) l2)
- )
- )
- (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list l1 l2))
- )
|