- (defun c:tt (/ en en1 en2 int lst1 lst2 n pt space ss)
- (setq en1 (car (entsel "\n图层1"))
- en2 (car (entsel "\n图层2"))
- ss (ssget "w"
- (setq pt (getpoint "\n窗口第一点:"))
- (getcorner pt "\n窗口第二点:")
- (list '(-4 . "<or")
- (setq en1 (assoc 8 (entget en1)))
- (setq en2 (assoc 8 (entget en2)))
- '(-4 . "or>")))
- space (vlax-get-property
- (vlax-get-property
- (vlax-get-acad-object)
- "activedocument")
- "ModelSpace"))
- (repeat (setq n (sslength ss))
- (setq en (ssname ss (setq n (1- n))))
- (if (equal en1 (assoc 8 (entget en)))
- (setq lst1 (cons (vlax-ename->vla-object en) lst1))
- (setq lst2 (cons (vlax-ename->vla-object en) lst2))))
- (while lst1
- (setq en1 (car lst1)
- lst1 (cdr lst1))
- (foreach n lst2
- (if (null (vl-catch-all-error-p
- (setq int (vl-catch-all-apply
- 'vlax-safearray->list
- (list (vlax-variant-value
- (vlax-invoke-method
- en1
- "intersectwith"
- n
- acextendnone)))))))
- (while int
- (vlax-invoke-method
- space
- "addcircle"
- (vlax-3d-point (car int) (cadr int) (caddr int))
- 50)
- (setq int (cdddr int)))))))
我也来凑个热闹,极不严谨的代码 |