本帖最后由 雨的节奏 于 2023-10-17 09:15 编辑
- (defun c:gsauditing (/ vps oldverp x pt temppt code oldverp vsize ocpt opt whs vp vpindex ovpcpt vpcpt)
- (setq vps (vports))
- (if (= 1 (length vps)) (progn (vl-cmdf "-vports" "si" "-vports" "2" "v") (setvar "cvport" (car (last (setq vps (vports)))))))
- ;;此时一定是有多视口的
- (if (null vpsandptlist)
- (progn
- (setq vpsandptlist ())
- (setq oldverp (getvar "cvport"))
- (foreach x vps
- ;;得到视口名和点表
- (setvar "cvport" (car x))
- (setq pt (getpoint "\n请指定当前激活视口的参考原点"))
- (if (null pt) (vl-exit-with-value ""))
- (setq vpsandptlist (cons (cons (car x) pt) vpsandptlist))
- )
- (setvar "cvport" oldverp)
- )
- )
- (princ "\n输入S可以设置对比参考点")
- ;;这个时候得到了视口名与坐标点的数据,来注册一个事件
- (setq temppt (getvar 'ViewCtr))
- (while (and
- (setq code (grread T 8))
- (/= 32 (car code))
- (/= 25 (car code))
- (/= 3 (car code))
- )
- (if (and (= 2 (car code)) (or (= 83 (cadr code)) (= 115 (cadr code))))
- (progn
- (setq vpsandptlist ())
- (setq oldverp (getvar "cvport"))
- (foreach x vps
- ;;得到视口名和点表
- (setvar "cvport" (car x))
- (setq pt (getpoint "\n请指定当前激活视口的参考原点"))
- (if (null pt) (vl-exit-with-value ""))
- (setq vpsandptlist (cons (cons (car x) pt) vpsandptlist))
- )
- (setvar "cvport" oldverp)
-
- )
- )
- (setq oldverp (getvar "cvport")
- vsize (getvar "viewsize")
- ocpt (getvar 'ViewCtr)
- opt (cdr (assoc oldverp vpsandptlist))
- whs (mapcar '- ocpt opt)
- )
- (if (null (equal temppt ocpt))
- (progn
- (foreach vp vps
- (if (null (equal (car vp) oldverp))
- (progn
- (setq vpindex (car vp))
- (setvar "cvport" vpindex)
- (setq ovpcpt (cdr (assoc vpindex vpsandptlist))
- vpcpt (mapcar '+ ovpcpt whs)
- )
- (vla-ZoomCenter (vlax-get-acad-object) (vlax-3d-point vpcpt) vsize)
-
-
- )
- )
- )
- ;;把对比值改成当前值
- (setvar "cvport" oldverp)
- (setq temppt ocpt)
- )
- )
-
- )
-
- (princ "\n完成对比")
- (prin1)
- )
注意事项:
1、只在当前图对比
2、对比点只设置一次,后面要再设置,输入s即可
3、随便拿去用,也不用注明出处,反正我也是在论坛找别人的东西参考着写的
|