以上两位发的是伪源码,我来个直接能用的。代码均来自明经,我只是组合了一下。
- (defun c:11 (/ ssinters ss osm e ptlist p)
- (vl-load-com)
- (defun ssinters (ss / i num obj1 obj2 j interpts ptlist)
- (setq i 0 num (sslength ss) )
- (while (< i (1- num))
- (setq obj1 (ssname ss i) obj1 (vlax-ename->vla-object obj1) j (1+ i) )
- (while (< j num)
- (setq obj2 (ssname ss j)
- obj2 (vlax-ename->vla-object obj2)
- interpts (vla-intersectwith
- obj1
- obj2
- 0
- )
- interpts (vlax-variant-value interpts)
- )
- (if (> (vlax-safearray-get-u-bound interpts 1) 0)
- (progn
- (setq interpts (vlax-safearray->list interpts) )
- (while (> (length interpts) 0)
- (setq ptlist (cons (list (car interpts) (cadr interpts)(caddr interpts)) ptlist ) )
- (setq interpts (cdddr interpts))
- )
- )
- )
- (setq j (1+ j))
- )
- (setq i (1+ i))
- )
- ptlist)
-
- (setvar "cmdecho" 0)
- (setq osm (getvar "osmode"))
- (setvar "osmode" 16384) ;;关闭捕捉
- (setq ss (ssget ":S" '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
- (sssetfirst nil ss)
- (setq e(car(entsel "\n拾取基准线")))
- (setq ptlist (ssinters ss))
- (foreach p ptlist
- (entmakex (list'(0 . "line") (cons 10(setq p(vlax-curve-getclosestpointto e p))) (cons 62 1)
- (cons 11(polar p(+(angle p(mapcar'+(vlax-curve-getfirstDeriv e(vlax-curve-getParamAtPoint e p))p))(* pi 0.5)) 800))))
- )
- (sssetfirst nil nil)
- (setvar "osmode" osm)
- (setvar "cmdecho" 1)
- (princ))
|