entmake法镜像
本帖最后由 飞雪神光 于 2023-5-8 15:28 编辑也许并没有什么用 就是写着玩 还有待完善 有需要的可以自己去优化
目前支持直线 圆 圆弧 多段线(支持凸度)
attach://126849.flv 大佬可以用矩阵玩玩,然后看看耗时对比 liuhe 发表于 2023-5-8 16:27
大佬可以用矩阵玩玩,然后看看耗时对比
矩阵? 我根本不懂 liuhe 发表于 2023-5-8 16:27
大佬可以用矩阵玩玩,然后看看耗时对比
(defun BF-Mat-ApplyMatrixTransformation (target matrix vector)
(cond
((eq 'VLA-OBJECT (type target))
(vla-TransformBy target
(vlax-tMatrix
(append (mapcar (function (lambda (x v) (append x (list v)))) matrix vector)
'((0. 0. 0. 1.))
)
)
)
)
((listp target)
(mapcar
(function
(lambda (point) (mapcar '+ (BF-Mat-MxV matrix point) vector))
)
target
)
)
)
)
(defun BF-Mat-MxV (m v)
(mapcar (function (lambda (r) (apply '+ (mapcar '* r v)))) m)
)
(defun BF-Mat-ReflectByMatrix (target p1 p2 / m)
(
(lambda ( a / m )
(BF-Mat-ApplyMatrixTransformation target
(setq m
(list
(list (cos a) (sin a)0.)
(list (sin a) (- (cos a)) 0.)
(list 0. 0. 1.)
)
)
(mapcar '- p1 (BF-Mat-MxV m p1))
)
)
(* 2. (angle p1 p2))
)
)
(BF-Mat-ReflectByMatrix (vlax-ename->vla-object(car(entsel))) (getpoint)(getpoint))
找到一个这个 直接看不懂 飞雪神光 发表于 2023-5-8 19:27
找到一个这个 直接看不懂
;;;-----------------------------------------------------------;;
;;; 二维镜像变换矩阵 ;;
;;; 参数: ;;
;;; p1 - 镜像向量第一点 ;;
;;; p2 - 镜像向量第二点 ;;
;;;-----------------------------------------------------------;;
;;;----------------=={ Reflect by Matrix }==------------------;;
;;; ;;
;;; Reflects a VLA-Object or Point List using a ;;
;;; Transformation Matrix ;;
;;;-----------------------------------------------------------;;
;;; Author: Lee Mac, Copyright ? 2010 - www.lee-mac.com ;;
;;;-----------------------------------------------------------;;
;;; Arguments: ;;
;;; target - VLA-Object or Point List to transform ;;
;;; p1, p2 - Points representing vector in which to reflect ;;
;;;-----------------------------------------------------------;;
(defun MAT:Reflect ( p1 p2 / a c s x y)
(setq a (angle p1 p2) a (+ a a))
(setq c (cos a) s (sin a))
(setq x (car p1) y (cadr p1))
(list
(list c s0. (- x (+ (* c x) (* s y))))
(list s (- c) 0. (- y (- (* s x) (* c y))))
'(0. 0. 1. 0.)
'(0. 0. 0. 1.)
)
)
(defun c:tt ()
(setq ss(ssget) ;选择集镜像
pt1 (getpoint)
pt2 (getpoint pt1)
i 0
mat (mat:reflect pt1 pt2)
)
(repeat (sslength ss)
(setq e (ssname ss i)
obj (vla-copy (vlax-ename->vla-object e))
i (1+ i)
)
;;; (vla-Mirror obj (vlax-3D-point pt1)(vlax-3D-point pt2))
(vla-transformby obj (vlax-tmatrix mat))
)
)
这个看着简单, 速度上没啥优势
页:
[1]