试试这个:
- ;; Finds all Intersections between obj1 & obj2
- ;; Args: obj1,obj2
- ;; VLA-Objects with Intersectwith method available
- ;; Returns: List of Intersections (or nil)
- (defun GetIntersections (obj1 obj2 / GroupByNum)
- ;; Lee Mac ~ 16.04.10
-
- (defun GroupByNum (lst num / rtn) (setq rtn nil)
-
- (if lst
- (cons (reverse
- (repeat num
- (progn
- (setq rtn (cons (car lst) rtn)
- lst (cdr lst))
- rtn)))
- (GroupByNum lst num))))
- (GroupByNum (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3))
测试功能:
- (defun c:test (/ e1 e2)
- (vl-load-com)
- (if (apply (function and)
- (mapcar
- (function
- (lambda (str sym)
- (set sym (car (entsel str)))))
- '("\nSelect First Object: " "\nSelect Second Object: ") '(e1 e2)))
- (print (apply (function GetIntersections)
- (mapcar (function vlax-ename->vla-object) (list e1 e2)))))
- (princ))
|