实体是直线)。
{。
实体,transform by(wcs 2 UCS);。
tmpExtents3D,AddExtents(实体,几何范围);。
num++;。
}。
实体,dispose();。
}。
if (0 。
{。
结果,add(new typed value((int)lisp data type,Point3d,tmpExtents3D。min point));。
结果,add(new typed value((int)lisp data type,Point3d,tmpExtents3D。MaxPoint));。
}。
}。
运输,commit();。
返回结果;。
}。
}测试结果:
- (setq bbox (blkbox (car (entsel))))
- (command "_.rectang" "_non" (car bbox) "_non" (cadr bbox))
但这一切都可以直接用LISP完成,这里有个例子: - ;; gc:TMatrixFromTo
- ;; Returns the (4x4) transformation matrix from a coordinate system to another one
- ;; (same arguments type as 'trans')
- ;;
- ;; Arguments
- ;; from : source coordinate system (integer, vector or ename)
- ;; to : destination coordinate system (integer, vector or ename)
- (defun gc:TMatrixFromTo (from to)
- (append
- (mapcar
- (function
- (lambda (v o)
- (append (trans v from to T) (list o))
- )
- )
- '((1. 0. 0.) (0. 1. 0.) (0. 0. 1.))
- (trans '(0. 0. 0.) to from)
- )
- '((0. 0. 0. 1.))
- )
- )
-
- ;; gc:UcsBoundingBox
- ;; Returns the UCS coordinates of the entity extents (bounding box)
- ;; about the current UCS
- ;;
- ;; Arguments
- ;; obj: an entity (ENAME or VLA-OBJCET)
- ;; _OutputMinPtSym: a quoted symbol (output)
- ;; _OutputMaxPtSym: a quoted symbol (output)
-
- (defun gc:UcsBoundingBox (obj _OutputMinPtSym _OutputMaxPtSym)
- (vl-load-com)
- (and (= (type obj) 'ENAME)
- (setq obj (vlax-ename->vla-object obj))
- )
- (vla-TransformBy obj (vlax-tmatrix (gc:TMatrixFromTo 1 0)))
- (vla-GetBoundingBox obj _OutputMinPtSym _OutputMaxPtSym)
- (vla-TransformBy obj (vlax-tmatrix (gc:TMatrixFromTo 0 1)))
- (set _OutputMinPtSym (vlax-safearray->list (eval _OutputMinPtSym)))
- (set _OutputMaxPtSym (vlax-safearray->list (eval _OutputMaxPtSym)))
- )
使用: - (gc:UcsBoundingBox (car (entsel)) 'minPt 'maxPt)
- (command "_.rectang" "_non" minPt "_non" maxPt)
。
|