另一种方式:
- (defun ssInter (ss / vLst i j obj1 obj2 iArr iLst)
- (setq vLst (mapcar 'vlax-ename->vla-object
- (vl-remove-if 'listp
- (mapcar 'cadr (ssnamex ss))))
- i (length vLst))
- (while (not (minusp (setq j (1- i) i (1- i))))
- (setq obj1 (nth i vLst))
- (while (not (minusp (setq j (1- j))))
- (setq obj2 (nth j vLst)
- iArr (vlax-variant-value
- (vla-IntersectWith obj1 obj2 acExtendNone)))
- (if (> (vlax-safearray-get-u-bound iArr 1) 0)
- (progn
- (setq iLst (vlax-safearray->list iArr))
- (while (not (zerop (length iLst)))
- (setq ptLst (cons (list (car iLst) (cadr iLst) (caddr iLst)) ptLst)
- iLst (cdddr iLst))))))))
- (defun c:test (/ ptLst)
- (vl-load-com)
- (ssInter (ssget))
- (alert (vl-princ-to-string ptLst))
- (princ))
|