2个程序都是从论坛下载的,发现他们同时启动加载就会冲突,使用最大块包围框的程序时,就会弹出如下对话框;
并且CAD就一直弹框报错,关都要强行关掉。
我还发现这个包围框的程序和【Gu_xl】版主的自动切换图层也会冲突,估计是这个包围框程序的问题?
有大神能帮忙改一下吗,让他们可以兼容使用,本人不会写程序,只是想找一些程序来提高工作效率,谢谢大家~
以下是自动图层 以下是最大块包围框
- ;;;几何关系判断
- (defun c:tt (/ box e i ss lst bound rects)
- (defun ebox (e / pa pb)
- (and (= 'ename (type e)) (setq e (vlax-ename->vla-object e)))
- (vlax-invoke-method e 'GetBoundingBox 'pa 'pb)
- (setq pa (trans (vlax-safearray->list pa) 0 1)
- pb (trans (vlax-safearray->list pb) 0 1)
- )
- (list pa pb)
- )
- (defun area (pts) (apply '* (cdr (reverse (apply 'mapcar (cons '- pts)))))) ;_求面积
- (defun pt4 (pt2)
- (list (car pt2) (list (caadr pt2) (cadar pt2)) (cadr pt2) (list (caar pt2) (cadadr pt2)))
- ) ;_对角点生成四角点
- (defun PtInPoly (pt pts)
- (equal pi
- (abs
- (apply '+ (mapcar '(lambda (x y) (rem (- (angle pt x) (angle pt y)) pi)) (cons (last pts) pts) pts))
- )
- 1e-6
- )
- ) ;_点是否在凸多边形内(角度法)
- ;;
- (setq ss (ssget '((0 . "INSERT"))))
- (repeat (setq i (sslength ss))
- (setq e (ssname ss (setq i (1- i))))
- (setq lst (cons (ebox e) lst)) ;_提取边界对角点,不生产矩形
- )
- (setq lst (vl-sort lst '(lambda (x1 x2) (> (area x1) (area x2))))) ;_按面积大小排序
- (while lst
- (setq rects (cons (car lst) rects)) ;_矩形对角点集
- (setq bound (pt4 (car lst))) ;_矩形边界
- (setq lst (vl-remove-if '(lambda (x) (and (PtInPoly (car x) bound) (PtInPoly (cadr x) bound))) (cdr lst))) ;_移除大矩形边界内的小矩形
- )
- (mapcar '(lambda (x) (command-s "rectang" (car x) (cadr x))) rects) ;_批量生成矩形
- (princ)
- )
|