- 积分
- 6552
- 明经币
- 个
- 注册时间
- 2012-11-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2013-1-7 18:55:02
|
显示全部楼层
本帖最后由 阿然 于 2013-1-7 18:56 编辑
给个lee大的函数
参数是图元表(vla-object)
返回包围框的左下角和右上角点坐标
 -
- ;;------------------=={ List BoundingBox }==------------------;;
- ;; ;;
- ;; Returns the coordinates of a rectangle framing all ;;
- ;; objects in a supplied list ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright ?2010 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; lst - list of VLA-Objects to process ;;
- ;;------------------------------------------------------------;;
- ;; Returns: coordinates of rectangle framing objects ;;
- ;;------------------------------------------------------------;;
- (defun LM:ListBoundingBox ( lst / ll ur bb )
- ;; ?Lee Mac 2010
- (foreach obj lst (vla-getBoundingBox obj 'll 'ur)
- (setq bb (cons (vlax-safearray->list ur)
- (cons (vlax-safearray->list ll) bb))
- )
- )
- (mapcar
- (function
- (lambda ( operation )
- (apply (function mapcar) (cons operation bb))
- )
- )
- '(min max)
- )
- )
- ;;----------------=={ BoundingBox -> List }==-----------------;;
- ;; ;;
- ;; Returns the coordinates of a rectangle from the ;;
- ;; coordinates of the lower-left and upper-right corners ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright ?2010 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; bbox - list of lower-left and upper-right coordinates ;;
- ;;------------------------------------------------------------;;
- ;; Returns: coordinates of rectangle ;;
- ;;------------------------------------------------------------;;
- (defun LM:BBox->List ( bbox )
- (mapcar
- (function
- (lambda ( funcs )
- (mapcar
- (function
- (lambda ( func ) ((eval func) bbox))
- )
- funcs
- )
- )
- )
- '((caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr))
- )
- )
|
|