本帖最后由 fools 于 2017-11-6 15:49 编辑
用这个函数
- ;;;-----------------------------------------------------------;;
- ;;; 功能: 某点在块内坐标系统和世界或者用户坐标系统的转换 ;;
- ;;; 参数: pt 要变换的点。 ;;
- ;;; rlst 用 nentselp或者nentsel得到的表的最后一项 ;;
- ;;; from 坐标系:0,WCS; 1,当前UCS; 2,块参照坐标系RCS ;;
- ;;; to 坐标系:0,WCS; 1,当前UCS; 2,块参照坐标系RCS ;;
- ;;;-----------------------------------------------------------;;
- ;;; MAT:TransNested (gile) ;;
- ;;; Translates a point coordinates from WCS or UCS to RCS ;;
- ;;; -coordinates system of a ;;
- ;;; reference (xref or block) whatever its nested level- ;;
- ;;; ;;
- ;;; Arguments ;;
- ;;; pt : the point to translate ;;
- ;;; rlst : the parents entities list from the deepest nested ;;
- ;;; to the one inserted in current space -same as ;;
- ;;; (last (nentsel)) or (last (nentselp)) ;;
- ;;; from to : as with trans function: 0.WCS, 1.UCS, 2.RCS ;;
- ;;;-----------------------------------------------------------;;
- (defun MAT:TransNested (pt rlst from to / GEOM)
- (and (= 1 from) (setq pt (trans pt 1 0)))
- (and (= 2 to) (setq rlst (reverse rlst)))
- (and (or (= 2 from) (= 2 to))
- (while rlst
- (setq geom (if (= 2 to)
- (MAT:RevRefGeom (car rlst))
- (MAT:RefGeom (car rlst))
- )
- rlst (cdr rlst)
- pt (mapcar '+ (MAT:mxv (car geom) pt) (cadr geom))
- )
- )
- )
- (if (= 1 to)
- (trans pt 0 1)
- pt
- )
- )
|