- (defun c:T0406( / COUNT NUM S1 S2 OS1 OS2 Len1 Len2 PTS1 PTS2 I J P1 P2 REV)
- ;使用步骤:
- ;1.选择曲线1
- ;2.选择曲线2
- ;3.输入曲线1 与 曲线2之间的内插根数
- ;4.如果曲线1 与 曲线2的起点不在一起,提示是否反向时输入 y或Y ,否则输入N或n!!!
- ;注1:此工具对拆线支持的不太友好
- ;注2:为方便,此工具对不做过多的类型判断,使用时需要按提示输入
- (setvar "osmode" 0)
- (setq COUNT 100);等分数 如果觉得画得不够细腻,此值设大一点
- (setq S1 (car (entsel "\n选择曲线1:")))
- (setq S2 (car (entsel "\n选择曲线2:")))
- (setq NUM (getint "\n输入插入根数"))
- (setq REV (getstring "\n是否反向某一根线(Y/N):"))
- (setq OS1 (vlax-ename->vla-object S1))
- (setq OS2 (vlax-ename->vla-object S2))
- (setq Len1 (/ (vlax-curve-getDistAtParam OS1 (vlax-curve-getEndParam OS1)) COUNT)) ;获取线1的每份长度
- (setq Len2 (/ (vlax-curve-getDistAtParam OS2 (vlax-curve-getEndParam OS2)) COUNT)) ;获取线2的每份长度
- (setq Index 1)
- (setq PTS1 (list (vlax-curve-getStartPoint OS1)))
- (setq PTS2 (list (vlax-curve-getStartPoint OS2)))
- (while (< Index COUNT)
- (setq PTS1 (append PTS1 (list (vlax-curve-getPointAtDist OS1 (* Index Len1)))))
- (setq PTS2 (append PTS2 (list (vlax-curve-getPointAtDist OS2 (* Index Len2)))))
- (setq Index (1+ Index))
- )
- (setq PTS1 (append PTS1 (list (vlax-curve-getEndPoint OS1))))
- (setq PTS2 (append PTS2 (list (vlax-curve-getEndPoint OS2))))
- (if (= "Y" (strcase REV))
- (setq PTS2 (reverse PTS2))
- )
- (setq I 1 NUM(1+ NUM) COUNT (length PTS1))
- (while (< I NUM)
- (setq J 0)
- (command "SPLINE")
- (while (< J COUNT)
- (setq P1 (nth J PTS1) P2 (nth J PTS2))
- (command (polar P1 (angle P1 P2) (/ (* (distance P1 P2) I) NUM)))
- (setq J (1+ J))
- )
- (command "")(command "")(command "")
- (setq I (1+ I))
- )
- )
-
|