1.如下:- ;函数:GetInterPOint
- ;功能:返回两个对象的所有交点
- ;参数: ent1、ent2 均为ename对象
- (defun GetInterPoint (ent1 ent2 / ax_ent_1 ax_ent_2 intpoints points i)
- (setq ax_ent_1 (vlax-ename->vla-object ent1)
- ax_ent_2 (vlax-ename->vla-object ent2)
- )
- (setq intpoints (vla-intersectwith ax_ent_1 ax_ent_2 acextendnone))
- (setq intpoints (vlax-variant-value intpoints))
- (setq i 0)
- (if (> (vlax-safearray-get-u-bound intpoints 1) 0)
- (repeat (/ (+ 1
- (- (vlax-safearray-get-u-bound intpoints 1)
- (vlax-safearray-get-l-bound intpoints 1)
- )
- )
- 3
- )
- (setq points (append points (list (list
- (vlax-safearray-get-element intpoints i)
- (vlax-safearray-get-element intpoints (+ i 1))
- (vlax-safearray-get-element intpoints (+ i 2))
- )))
- )
- (setq i (+ 3 i))
- )
- )
- points
- )
- ;主函数,命令:TEST
- (defun c:test( / ent1 ent2 pts i pt ang)
- (setq ent1 (car (entsel "\n选择曲线...")))
- (setq ent2 (car (entsel "\n选择直线...")))
- (setq pts (GetInterPoint ent1 ent2))
- (setq i 0)
- (repeat (length pts)
- (setq pt (nth i pts))
- (setq ang (angle '(0 0 0) (vlax-curve-getFirstDeriv ent1 (vlax-curve-getParamAtPoint ent1 pt))))
- (command "_.line" pt (polar pt ang 100) "")
- (setq i (1+ i))
- )
- (princ)
- )
2.怎样算对齐? |