本帖最后由 Gu_xl 于 2014-7-18 13:15 编辑
- ;;(gxl-GetCurveBox curve) 精确取得曲线实体外矩形框对角点
- ;;2014.07.18 修正1阶SPLINE的错误
- (defun gxl-GetCurveBox (curve / obj p1 p2 p3 p4 lst pts)
- (if (= 'ename (type curve))
- (setq obj (vlax-ename->vla-object curve))
- (setq obj curve)
- )
- (if (and (= "AcDbSpline" (vla-get-objectname obj))
- (< (vla-get-Degree obj) 2)
- )
- (progn
- (setq pl (vlax-safearray->list
- (vlax-variant-value (vla-get-ControlPoints obj))
- )
- )
- (while pl
- (setq pts (cons (list (car pl) (cadr pl) (caddr pl)) pts)
- pl (cdddr pl)
- )
- )
- (setq p1 (apply 'mapcar (cons 'min pts))
- p3 (apply 'mapcar (cons 'max pts))
- p2 (list (car p1) (cadr p3) (caddr p1))
- p4 (list (car p3) (cadr p1) (caddr p1))
- )
- )
- (progn
- (vla-GetBoundingBox obj 'p1 'p3)
- (setq p1 (vlax-safearray->list p1)
- p3 (vlax-safearray->list p3)
- p2 (list (car p1) (cadr p3) (caddr p1))
- p4 (list (car p3) (cadr p1) (caddr p1))
- )
- )
- )
- (SETQ lst
- (mapcar '(lambda (a b)
- (vlax-curve-getClosestPointToProjection curve a b t)
- )
- (list p1 p2 p3 p4)
- '((1.0 0 0) (0 -1.0 0) (-1.0 0 0) (0 1.0 0))
- )
- )
- (list
- (apply 'mapcar (cons 'min lst))
- (apply 'mapcar (cons 'max lst))
- )
- )
|